Skip to content

Commit

Permalink
Don't join thread in CQuorum::~CQuorum when called from within the th…
Browse files Browse the repository at this point in the history
…read (dashpay#3223)
  • Loading branch information
codablock committed Dec 6, 2019
1 parent e69c6c3 commit 2fef21f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/llmq/quorums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ CQuorum::~CQuorum()
{
// most likely the thread is already done
stopCachePopulatorThread = true;
if (cachePopulatorThread.joinable()) {
// watch out to not join the thread when we're called from inside the thread, which might happen on shutdown. This
// is because on shutdown the thread is the last owner of the shared CQuorum instance and thus the destroyer of it.
if (cachePopulatorThread.joinable() && cachePopulatorThread.get_id() != std::this_thread::get_id()) {
cachePopulatorThread.join();
}
}
Expand Down

0 comments on commit 2fef21f

Please sign in to comment.