diff --git a/net/dcsctp/socket/heartbeat_handler.cc b/net/dcsctp/socket/heartbeat_handler.cc index d5ff6fc778..424f073686 100644 --- a/net/dcsctp/socket/heartbeat_handler.cc +++ b/net/dcsctp/socket/heartbeat_handler.cc @@ -100,8 +100,7 @@ HeartbeatHandler::HeartbeatHandler(absl::string_view log_prefix, interval_timer_(timer_manager_->CreateTimer( "heartbeat-interval", absl::bind_front(&HeartbeatHandler::OnIntervalTimerExpiry, this), - TimerOptions(interval_duration_, - TimerBackoffAlgorithm::kFixed))), + TimerOptions(interval_duration_, TimerBackoffAlgorithm::kFixed))), timeout_timer_(timer_manager_->CreateTimer( "heartbeat-timeout", absl::bind_front(&HeartbeatHandler::OnTimeoutTimerExpiry, this), @@ -121,8 +120,7 @@ void HeartbeatHandler::RestartTimer() { if (interval_duration_should_include_rtt_) { // The RTT should be used, but it's not easy accessible. The RTO will // suffice. - interval_timer_->set_duration( - interval_duration_ + ctx_->current_rto()); + interval_timer_->set_duration(interval_duration_ + ctx_->current_rto()); } else { interval_timer_->set_duration(interval_duration_); } diff --git a/net/dcsctp/timer/task_queue_timeout.cc b/net/dcsctp/timer/task_queue_timeout.cc index 7612f98f3a..ef891e186d 100644 --- a/net/dcsctp/timer/task_queue_timeout.cc +++ b/net/dcsctp/timer/task_queue_timeout.cc @@ -60,34 +60,37 @@ void TaskQueueTimeoutFactory::TaskQueueTimeout::Start(DurationMs duration_ms, posted_task_expiration_ = timeout_expiration_; parent_.task_queue_.PostDelayedTaskWithPrecision( precision_, - webrtc::SafeTask( - pending_task_safety_flag_, - [timeout_id, this]() { - RTC_DLOG(LS_VERBOSE) << "Timout expired: " << timeout_id.value(); - RTC_DCHECK_RUN_ON(&parent_.thread_checker_); - RTC_DCHECK(!posted_task_expiration_.IsPlusInfinity()); - posted_task_expiration_ = Timestamp::PlusInfinity(); + webrtc::SafeTask(pending_task_safety_flag_, + [timeout_id, this]() { + RTC_DLOG(LS_VERBOSE) + << "Timout expired: " << timeout_id.value(); + RTC_DCHECK_RUN_ON(&parent_.thread_checker_); + RTC_DCHECK(!posted_task_expiration_.IsPlusInfinity()); + posted_task_expiration_ = Timestamp::PlusInfinity(); - if (timeout_expiration_.IsPlusInfinity()) { - // The timeout was stopped before it expired. Very common. - } else { - // Note that the timeout might have been restarted, which updated - // `timeout_expiration_` but left the scheduled task running. So - // if it's not quite time to trigger the timeout yet, schedule a - // new delayed task with what's remaining and retry at that point - // in time. - TimeDelta remaining = timeout_expiration_ - parent_.Now(); - timeout_expiration_ = Timestamp::PlusInfinity(); - if (remaining > TimeDelta::Zero()) { - Start(DurationMs(remaining.ms()), timeout_id_); - } else { - // It has actually triggered. - RTC_DLOG(LS_VERBOSE) - << "Timout triggered: " << timeout_id.value(); - parent_.on_expired_(timeout_id_); - } - } - }), + if (timeout_expiration_.IsPlusInfinity()) { + // The timeout was stopped before it expired. Very + // common. + } else { + // Note that the timeout might have been restarted, + // which updated `timeout_expiration_` but left the + // scheduled task running. So if it's not quite time + // to trigger the timeout yet, schedule a new delayed + // task with what's remaining and retry at that point + // in time. + TimeDelta remaining = + timeout_expiration_ - parent_.Now(); + timeout_expiration_ = Timestamp::PlusInfinity(); + if (remaining > TimeDelta::Zero()) { + Start(DurationMs(remaining.ms()), timeout_id_); + } else { + // It has actually triggered. + RTC_DLOG(LS_VERBOSE) + << "Timout triggered: " << timeout_id.value(); + parent_.on_expired_(timeout_id_); + } + } + }), webrtc::TimeDelta::Millis(duration_ms.value())); }