Skip to content

Commit efac91e

Browse files
committed
Always wait for threadGroup to exit in bitcoind shutdown
This resolves a possible-assert-on-shutdown race introduced in 1f668b6 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
1 parent f66c596 commit efac91e

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/bitcoind.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ bool AppInit(int argc, char* argv[])
176176
if (!fRet)
177177
{
178178
Interrupt(threadGroup);
179-
// threadGroup.join_all(); was left out intentionally here, because we didn't re-test all of
180-
// the startup-failure cases to make sure they don't result in a hang due to some
181-
// thread-blocking-waiting-for-another-thread-during-startup case
179+
threadGroup.join_all();
182180
} else {
183181
WaitForShutdown(&threadGroup);
184182
}

0 commit comments

Comments
 (0)