From 2fef21fd802570e3131ba6570abea7e86454a143 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Fri, 6 Dec 2019 10:06:13 +0100 Subject: [PATCH] Don't join thread in CQuorum::~CQuorum when called from within the thread (#3223) --- src/llmq/quorums.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/llmq/quorums.cpp b/src/llmq/quorums.cpp index ec938f0a1c..1bf177d266 100644 --- a/src/llmq/quorums.cpp +++ b/src/llmq/quorums.cpp @@ -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(); } }