diff options
author | Matt Corallo <git@bluematt.me> | 2018-02-06 13:32:53 -0500 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-02-08 10:07:24 +0100 |
commit | 09fc859ef05adb5a3adac8ce9e60790d99375af5 (patch) | |
tree | afd7c87c200d0a5febbfe8af7ec8350b2622dd6d /src | |
parent | da84760701dc08954dfb8cd0639b8fa17a44916d (diff) |
Fix fast-shutdown hang on ThreadImport+GenesisWait
If the user somehow manages to get into ShutdownRequested before
ThreadImport gets to ActivateBestChain() we may hang waiting on
condvar_GenesisWait forever. A simple wait_for and
ShutdownRequested resolves this case.
Github-Pull: #12367
Rebased-From: 1c9394ad477d0c1ca0ab1caa6024a7e70c125d15
Tree-SHA512: fb0751ef32d2005520738bf3b0a0f41ae3f9314d700d2a85eb50f023e87e109ce806cdcdf4a08f49a4d9c1001e27df7f461d3fd52b1f5a57885260ce9375260f
Diffstat (limited to 'src')
-rw-r--r-- | src/init.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/init.cpp b/src/init.cpp index 238da00ee2..c02917aac1 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1645,12 +1645,19 @@ bool AppInitMain() // Wait for genesis block to be processed { WaitableLock lock(cs_GenesisWait); - while (!fHaveGenesis) { - condvar_GenesisWait.wait(lock); + // We previously could hang here if StartShutdown() is called prior to + // ThreadImport getting started, so instead we just wait on a timer to + // check ShutdownRequested() regularly. + while (!fHaveGenesis && !ShutdownRequested()) { + condvar_GenesisWait.wait_for(lock, std::chrono::milliseconds(500)); } uiInterface.NotifyBlockTip.disconnect(BlockNotifyGenesisWait); } + if (ShutdownRequested()) { + return false; + } + // ********************************************************* Step 11: start node int chain_active_height; |