diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -940,16 +940,12 @@ boost::thread t(runCommand, strCmd); // thread runs free } -static bool fHaveGenesis = false; -static boost::mutex cs_GenesisWait; +static std::atomic fHaveGenesis = false; static CConditionVariable condvar_GenesisWait; static void BlockNotifyGenesisWait(bool, const CBlockIndex *pBlockIndex) { if (pBlockIndex != nullptr) { - { - boost::unique_lock lock_GenesisWait(cs_GenesisWait); - fHaveGenesis = true; - } + fHaveGenesis.store(true, std::memory_order_release); condvar_GenesisWait.notify_all(); } } @@ -2178,7 +2174,7 @@ if (chainActive.Tip() == nullptr) { uiInterface.NotifyBlockTip.connect(BlockNotifyGenesisWait); } else { - fHaveGenesis = true; + fHaveGenesis.store(true, std::memory_order_release); } if (gArgs.IsArgSet("-blocknotify")) { @@ -2196,13 +2192,10 @@ boost::bind(&ThreadImport, std::ref(config), vImportFiles)); // Wait for genesis block to be processed - { - boost::unique_lock lock(cs_GenesisWait); - while (!fHaveGenesis) { - condvar_GenesisWait.wait(lock); - } - uiInterface.NotifyBlockTip.disconnect(BlockNotifyGenesisWait); + while (!fHaveGenesis.load(std::memory_order_acquire)) { + condvar_GenesisWait.wait(lock); } + uiInterface.NotifyBlockTip.disconnect(BlockNotifyGenesisWait); // Step 11: start node