From 9ba4c0842a55bc0b92eb2ae94c5a677b875566b7 Mon Sep 17 00:00:00 2001 From: Bright Chen Date: Wed, 1 Nov 2023 00:52:07 +0800 Subject: [PATCH] usleep returns ESTOP when schedule timer failed --- src/bthread/task_group.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bthread/task_group.cpp b/src/bthread/task_group.cpp index cbae7c5bfa..d2f89f915a 100644 --- a/src/bthread/task_group.cpp +++ b/src/bthread/task_group.cpp @@ -796,6 +796,11 @@ int TaskGroup::usleep(TaskGroup** pg, uint64_t timeout_us) { g->set_remained(_add_sleep_event, &e); sched(pg); g = *pg; + if (e.meta->current_sleep == 0) { + // // Fail to `_add_sleep_event'. + errno = ESTOP; + return -1; + } e.meta->current_sleep = 0; if (e.meta->interrupted) { // Race with set and may consume multiple interruptions, which are OK.