This is an automated email from the ASF dual-hosted git repository.

lorinlee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new eded407e usleep returns ESTOP when schedule timer failed
     new 9b15c3b7 Merge pull request #2435 from chenBright/fix_usleep
eded407e is described below

commit eded407e623eb37799e326389a5de8f38c335026
Author: Bright Chen <[email protected]>
AuthorDate: Wed Nov 1 00:52:07 2023 +0800

    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 cbae7c5b..0a785601 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.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to