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.