gitccl opened a new pull request, #2986: URL: https://github.com/apache/brpc/pull/2986
### What problem does this PR solve? ### Problem Summary: During shutdown, `stop_and_join()` sets `_stop = true`, sets `_nearest_run_time = 0`, and calls `futex_wake_private()` to wake up the timer thread. However, due to a race condition, the timer thread may: 1. See `_stop == false` and enter the wait loop. 2. Block on acquiring `_mutex` while `stop_and_join()` holds it. 3. After `stop_and_join()` releases the mutex, the timer thread acquires it and sets `_nearest_run_time = int64_max`, **overwriting the earlier** `_nearest_run_time = 0`. 4. Miss the wake-up signal because at the time `stop_and_join()` called `futex_wake_private()`, the timer thread had not yet entered futex wait. As a result, after finishing all remaining tasks, the timer thread may enter futex wait **with no further wake-up**, causing the program to hang on `pthread_join`. ### What is changed and the side effects? Changed: Side effects: - Performance effects: - Breaking backward compatibility: --- ### Check List: - Please make sure your changes are compilable. - When providing us with a new feature, it is best to add related tests. - Please follow [Contributor Covenant Code of Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org