From 904dfc103fc82a5fe60e5d85d7edc8f88ca8ade1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?shuxin=20=E3=80=80=E3=80=80zheng?= Date: Sat, 23 Mar 2024 16:49:39 +0800 Subject: [PATCH] make wakeup_waiter more safety when timeout. --- lib_fiber/c/src/sync/sync_timer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_fiber/c/src/sync/sync_timer.c b/lib_fiber/c/src/sync/sync_timer.c index a37cdb681..209f51474 100644 --- a/lib_fiber/c/src/sync/sync_timer.c +++ b/lib_fiber/c/src/sync/sync_timer.c @@ -72,11 +72,13 @@ static void wakeup_waiter(SYNC_TIMER *timer UNUSED, SYNC_OBJ *obj) // The fiber must has been awakened by the other fiber or thread. if (obj->delay < 0) { - // No timer has been set if delay < 0, + // No timer has been set if delay < 0, + ring_detach(&obj->fb->me); // Safety detatch me from others. acl_fiber_ready(obj->fb); } else if (fiber_timer_del(obj->fb) == 1) { // Wakeup the waiting fiber before the timer arrives, // just remove it from the timer. + ring_detach(&obj->fb->me); // Safety detatch me from others. acl_fiber_ready(obj->fb); } // else: The fiber has been awakened by the timer.