diff options
| author | Matt Corallo <[email protected]> | 2018-02-06 13:32:53 -0500 |
|---|---|---|
| committer | Matt Corallo <[email protected]> | 2018-02-06 15:13:59 -0500 |
| commit | 1c9394ad477d0c1ca0ab1caa6024a7e70c125d15 (patch) | |
| tree | a5a75ace2bc0447d1b85b03ab4ea9ca8e61f0d33 /src/init.cpp | |
| parent | Merge #12050: [trivial] Implements a virtual destructor on the BaseRequestHan... (diff) | |
| download | discoin-1c9394ad477d0c1ca0ab1caa6024a7e70c125d15.tar.xz discoin-1c9394ad477d0c1ca0ab1caa6024a7e70c125d15.zip | |
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.
Diffstat (limited to 'src/init.cpp')
| -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 50643ff96..14dd8fc8a 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; |