diff options
author | Matt Corallo <git@bluematt.me> | 2018-01-24 21:15:56 -0500 |
---|---|---|
committer | Matt Corallo <git@bluematt.me> | 2018-01-25 11:35:34 -0500 |
commit | 082a61c69d7a539b5a48c4376a657f1c5aa92d81 (patch) | |
tree | ddfc5d6520551cf395629583ae9e6088aa179af0 /src/init.cpp | |
parent | 6970b30c6f1d2be7947295fe18f2390649b17a4b (diff) | |
download | bitcoin-082a61c69d7a539b5a48c4376a657f1c5aa92d81.tar.xz |
Move scheduler/threadGroup into common-init instead of per-app
This resolves #12229 which pointed out a shutdown deadlock due to
scheduler/checkqueue having been shut down while network message
processing is still running.
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/init.cpp b/src/init.cpp index d1d733af94..b9c78b8211 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -155,7 +155,10 @@ public: static std::unique_ptr<CCoinsViewErrorCatcher> pcoinscatcher; static std::unique_ptr<ECCVerifyHandle> globalVerifyHandle; -void Interrupt(boost::thread_group& threadGroup) +static boost::thread_group threadGroup; +static CScheduler scheduler; + +void Interrupt() { InterruptHTTPServer(); InterruptHTTPRPC(); @@ -164,7 +167,6 @@ void Interrupt(boost::thread_group& threadGroup) InterruptTorControl(); if (g_connman) g_connman->Interrupt(); - threadGroup.interrupt_all(); } void Shutdown() @@ -199,6 +201,12 @@ void Shutdown() g_connman.reset(); StopTorControl(); + + // After everything has been shut down, but before things get flushed, stop the + // CScheduler/checkqueue threadGroup + threadGroup.interrupt_all(); + threadGroup.join_all(); + if (fDumpMempoolLater && gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { DumpMempool(); } @@ -705,7 +713,7 @@ bool InitSanityCheck(void) return true; } -bool AppInitServers(boost::thread_group& threadGroup) +bool AppInitServers() { RPCServer::OnStarted(&OnRPCStarted); RPCServer::OnStopped(&OnRPCStopped); @@ -1184,7 +1192,7 @@ bool AppInitLockDataDirectory() return true; } -bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) +bool AppInitMain() { const CChainParams& chainparams = Params(); // ********************************************************* Step 4a: application initialization @@ -1251,7 +1259,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler) if (gArgs.GetBoolArg("-server", false)) { uiInterface.InitMessage.connect(SetRPCWarmupStatus); - if (!AppInitServers(threadGroup)) + if (!AppInitServers()) return InitError(_("Unable to start HTTP server. See debug log for details.")); } |