From 9c93192bb4fa9d8f0bc76adda0b84fd39cfe450a Mon Sep 17 00:00:00 2001 From: Xie Han <63350856@qq.com> Date: Tue, 17 Oct 2023 21:21:42 +0800 Subject: [PATCH] Optimize timed thread/go task's state when timer failed. --- src/factory/WFTaskFactory.cc | 13 +++++++++++-- src/factory/WFTaskFactory.inl | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/factory/WFTaskFactory.cc b/src/factory/WFTaskFactory.cc index 0ab289b8..35557c38 100644 --- a/src/factory/WFTaskFactory.cc +++ b/src/factory/WFTaskFactory.cc @@ -847,8 +847,17 @@ void __WFTimedGoTask::timer_callback(WFTimerTask *timer) if (--task->ref == 3) { - task->state = WFT_STATE_SYS_ERROR; - task->error = ETIMEDOUT; + if (timer->get_state() == WFT_STATE_SUCCESS) + { + task->state = WFT_STATE_SYS_ERROR; + task->error = ETIMEDOUT; + } + else + { + task->state = timer->get_state(); + task->error = timer->get_error(); + } + task->subtask_done(); } diff --git a/src/factory/WFTaskFactory.inl b/src/factory/WFTaskFactory.inl index 04e13afc..cf737744 100644 --- a/src/factory/WFTaskFactory.inl +++ b/src/factory/WFTaskFactory.inl @@ -820,8 +820,17 @@ void __WFTimedThreadTask::timer_callback(WFTimerTask *timer) if (--task->ref == 3) { - task->state = WFT_STATE_SYS_ERROR; - task->error = ETIMEDOUT; + if (timer->get_state() == WFT_STATE_SUCCESS) + { + task->state = WFT_STATE_SYS_ERROR; + task->error = ETIMEDOUT; + } + else + { + task->state = timer->get_state(); + task->error = timer->get_error(); + } + task->subtask_done(); }