From 4e9d042c8de446d671e0565a381931a2fd522dee Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Tue, 19 Mar 2024 16:31:06 +0800 Subject: [PATCH] fix timeout crash --- src/timer/task_queue_timeout.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/timer/task_queue_timeout.cc b/src/timer/task_queue_timeout.cc index 2599232..678781d 100644 --- a/src/timer/task_queue_timeout.cc +++ b/src/timer/task_queue_timeout.cc @@ -11,7 +11,7 @@ TaskQueueTimeoutFactory::TaskQueueTimeout::TaskQueueTimeout(TaskQueueTimeoutFact safety_flag_(PendingTaskSafetyFlag::Create()) {} -TaskQueueTimeoutFactory::TaskQueueTimeout::~TaskQueueTimeout() {} +TaskQueueTimeoutFactory::TaskQueueTimeout::~TaskQueueTimeout() { safety_flag_->SetNotAlive(); } void TaskQueueTimeoutFactory::TaskQueueTimeout::Start(DurationMs duration_ms, TimeoutID timeout_id) @@ -31,12 +31,14 @@ TaskQueueTimeoutFactory::TaskQueueTimeout::Start(DurationMs duration_ms, Timeout posted_task_expiration_ = timeout_expiration_; auto safety_flag = safety_flag_; + parent_.task_queue_.PostDelayedTaskWithPrecision( precision_, SafeTask(safety_flag_, [timeout_id, this]() { // if (timeout_id != this->timeout_id_) { return; } LOGV("timer", "Timeout expired: {}", timeout_id); + // FIXME: this is a bug, the posted_task_expiration_ should be reset to max ASSERT(posted_task_expiration_ != std::numeric_limits::max(), ""); posted_task_expiration_ = std::numeric_limits::max();