aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-01-30 12:34:11 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2018-01-30 13:04:30 +0100
commit3448907a68e0f719be3bf82f4d321a30975d3539 (patch)
tree9201e7e58e6104f72906bd8f10ca6bdcace8d7de /src/init.cpp
parent7936446268e2f63baa855d694df0243924b7e1a9 (diff)
parent082a61c69d7a539b5a48c4376a657f1c5aa92d81 (diff)
Merge #12266: Move scheduler/threadGroup into common-init instead of per-app
082a61c Move scheduler/threadGroup into common-init instead of per-app (Matt Corallo) Pull request description: This resolves #12229 which pointed out a shutdown deadlock due to scheduler/checkqueue having been shut down while network message processing is still running. Tree-SHA512: 0c0a76113996b164b0610d3b8c40b396f3e384d165bf098768e31fe3701b00763d0d810ef24702387e2e936fefb9fb900a6225f7417bb0175b585f365d542660
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 94702301a6..238da00ee2 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);
@@ -1190,7 +1198,7 @@ bool AppInitLockDataDirectory()
return true;
}
-bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
+bool AppInitMain()
{
const CChainParams& chainparams = Params();
// ********************************************************* Step 4a: application initialization
@@ -1257,7 +1265,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."));
}