summaryrefslogtreecommitdiff
path: root/indra/llcommon/threadpool.cpp
diff options
context:
space:
mode:
authorMike <contact@mikelittman.me>2026-10-22 11:36:21 -0400
committerGitHub <noreply@github.com>2026-10-22 23:36:21 +0800
commitf2a1ad0e53632ad69729c9bd55edcdfe8ef98368 (patch)
tree3c323a88a92d145dab4bd11f5e432bcefe0a796e /indra/llcommon/threadpool.cpp
parentb087c0c8d818bace45a9d0d2dec3661f1261896d (diff)
Do not abort when a shutdown thread joins itself (#37)
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.cpp12
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;