aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2017-07-23 13:29:06 -0400
committerMatt Corallo <git@bluematt.me>2017-08-01 16:35:02 -0400
commitefac91e65452dd89a9b891e79bdd191208d2b44d (patch)
treee630961bac6c0763c637faf915935fd0d0274462 /src
parentf66c59650527022b4f7abd98ff0a1a4e4741bd34 (diff)
downloadbitcoin-efac91e65452dd89a9b891e79bdd191208d2b44d.tar.xz
Always wait for threadGroup to exit in bitcoind shutdown
This resolves a possible-assert-on-shutdown race introduced in 1f668b646806f94acd851acdbd9939c24e0492d3 when early shutdown occurs. Previously this was not done to avoid any cases where the threadGroup might not exit due to a blocking thread, but at this point the threadGroup isn't used all that much, plus Qt already does this, and its good to keep their init/shutdown consistent. For those curious, the threadGroup is only used in a few places: * Its used to run the CCheckQueues in script validation, but these use the boost mutex/condition variable primitives, so they respect the interrupt pretty trivially. * Its used for the import thread, which should exit rather quickly as mostly it just calls LoadExternalBlockFile, which has an interruption_point right before each block loaded. * Its used in the scheduler thread, which is only used for: * validationinterface has an effectively-dummy reference to it. * wallet compaction, which should not last long * addr/banlist dumping from CConnman, which should also be fast
Diffstat (limited to 'src')
-rw-r--r--src/bitcoind.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index f3844e9d47..ff61b9065b 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -176,9 +176,7 @@ bool AppInit(int argc, char* argv[])
if (!fRet)
{
Interrupt(threadGroup);
- // threadGroup.join_all(); was left out intentionally here, because we didn't re-test all of
- // the startup-failure cases to make sure they don't result in a hang due to some
- // thread-blocking-waiting-for-another-thread-during-startup case
+ threadGroup.join_all();
} else {
WaitForShutdown(&threadGroup);
}