Skip to content

Commit fdb0586

Browse files
codablockUdjinM6
authored andcommitted
Don't join thread in CQuorum::~CQuorum when called from within the thread (#3223)
1 parent 4c00d98 commit fdb0586

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/llmq/quorums.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ CQuorum::~CQuorum()
4444
{
4545
// most likely the thread is already done
4646
stopCachePopulatorThread = true;
47-
if (cachePopulatorThread.joinable()) {
47+
// watch out to not join the thread when we're called from inside the thread, which might happen on shutdown. This
48+
// is because on shutdown the thread is the last owner of the shared CQuorum instance and thus the destroyer of it.
49+
if (cachePopulatorThread.joinable() && cachePopulatorThread.get_id() != std::this_thread::get_id()) {
4850
cachePopulatorThread.join();
4951
}
5052
}

0 commit comments

Comments
 (0)