diff --git a/src/init.cpp b/src/init.cpp index f4ec8a5db9a54..2210c79dfcd5d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1804,12 +1804,19 @@ bool AppInit2(const std::vector& words) LogPrintf("Waiting for genesis block to be imported...\n"); { std::unique_lock lockG(cs_GenesisWait); - while (!fHaveGenesis) { - condvar_GenesisWait.wait(lockG); + // 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(lockG, std::chrono::milliseconds(500)); } uiInterface.NotifyBlockTip.disconnect(BlockNotifyGenesisWait); } + if (ShutdownRequested()) { + return false; + } + // ********************************************************* Step 10: setup ObfuScation uiInterface.InitMessage(_("Loading masternode cache..."));