From eded407e623eb37799e326389a5de8f38c335026 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..0a785601e6 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 && !e.meta->interrupted) { + // 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.