diff options
| author | Mike <contact@mikelittman.me> | 2026-10-22 12:19:49 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-10-23 00:19:49 +0800 |
| commit | 32721d1421819fcd8ca0776421e147d59dad60ab (patch) | |
| tree | 6b2a721c548609fb3bb7c70f0b2d0ab81f216b84 /indra/llcommon/threadpool.cpp | |
| parent | 0bd96379e6130481418cb25bdac5ba9416131afc (diff) | |
Do not abort when a shutdown thread joins itself (#40)
std::thread::join throws system_error if the caller is the thread being
joined. That uncaught exception aborted the process during shutdown.
Detach the current thread instead, and catch a join that still throws.
Diffstat (limited to 'indra/llcommon/threadpool.cpp')
| -rw-r--r-- | indra/llcommon/threadpool.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/indra/llcommon/threadpool.cpp b/indra/llcommon/threadpool.cpp index 6adbdffba8..668c8ba598 100644 --- a/indra/llcommon/threadpool.cpp +++ b/indra/llcommon/threadpool.cpp @@ -20,6 +20,7 @@ #include "commoncontrol.h" #include "llerror.h" #include "llevents.h" +#include "llthread.h" #include "llsd.h" #include "stringize.h" @@ -127,8 +128,17 @@ void LL::ThreadPoolBase::close() { if (pair.second.joinable()) { + // close() runs on a worker when the LLApp status listener + // fires on that thread. Joining it throws and aborts shutdown. + if (pair.second.get_id() == std::this_thread::get_id()) + { + LL_WARNS("ThreadPool") << mName << " detaching current thread " + << pair.first << LL_ENDL; + pair.second.detach(); + continue; + } LL_DEBUGS("ThreadPool") << mName << " waiting on thread " << pair.first << LL_ENDL; - pair.second.join(); + ll_join_thread(pair.second); } } LL_DEBUGS("ThreadPool") << mName << " shutdown complete" << LL_ENDL; |
