This is an automated email from the ASF dual-hosted git repository.
wwbmmm 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 d4e46bdd Fix race condition that causes TimerThread to hang during
shutdown (#2986)
d4e46bdd is described below
commit d4e46bddc1771daf7f65c5643c60118651eb7b5b
Author: Chen Chuanle <[email protected]>
AuthorDate: Mon Jun 16 10:07:51 2025 +0800
Fix race condition that causes TimerThread to hang during shutdown (#2986)
* Fix race condition that causes TimerThread to hang during shutdown
* fix ut
* optimize timer_thread stop check
---
src/bthread/timer_thread.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/bthread/timer_thread.cpp b/src/bthread/timer_thread.cpp
index ee80568c..8d61b857 100644
--- a/src/bthread/timer_thread.cpp
+++ b/src/bthread/timer_thread.cpp
@@ -347,6 +347,11 @@ void TimerThread::run() {
// would run the consumed tasks.
{
BAIDU_SCOPED_LOCK(_mutex);
+ // This check of _stop ensures we won't miss the reset of
_nearest_run_time
+ // to 0 in stop_and_join, avoiding potential race conditions.
+ if (BAIDU_UNLIKELY(_stop.load(butil::memory_order_relaxed))) {
+ break;
+ }
_nearest_run_time = std::numeric_limits<int64_t>::max();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]