make wakeup_waiter more safety when timeout.

This commit is contained in:
shuxin   zheng 2024-03-23 16:49:39 +08:00
parent 369b7b1038
commit 904dfc103f

View File

@ -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.