mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
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.
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
#include <rpc/server.h>
|
||||
#include <init.h>
|
||||
#include <noui.h>
|
||||
#include <scheduler.h>
|
||||
#include <util.h>
|
||||
#include <httpserver.h>
|
||||
#include <httprpc.h>
|
||||
@@ -40,7 +39,7 @@
|
||||
* Use the buttons <code>Namespaces</code>, <code>Classes</code> or <code>Files</code> at the top of the page to start navigating the code.
|
||||
*/
|
||||
|
||||
void WaitForShutdown(boost::thread_group* threadGroup)
|
||||
void WaitForShutdown()
|
||||
{
|
||||
bool fShutdown = ShutdownRequested();
|
||||
// Tell the main threads to shutdown.
|
||||
@@ -49,11 +48,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
|
||||
MilliSleep(200);
|
||||
fShutdown = ShutdownRequested();
|
||||
}
|
||||
if (threadGroup)
|
||||
{
|
||||
Interrupt(*threadGroup);
|
||||
threadGroup->join_all();
|
||||
}
|
||||
Interrupt();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -62,9 +57,6 @@ void WaitForShutdown(boost::thread_group* threadGroup)
|
||||
//
|
||||
bool AppInit(int argc, char* argv[])
|
||||
{
|
||||
boost::thread_group threadGroup;
|
||||
CScheduler scheduler;
|
||||
|
||||
bool fRet = false;
|
||||
|
||||
//
|
||||
@@ -165,7 +157,7 @@ bool AppInit(int argc, char* argv[])
|
||||
// If locking the data directory failed, exit immediately
|
||||
return false;
|
||||
}
|
||||
fRet = AppInitMain(threadGroup, scheduler);
|
||||
fRet = AppInitMain();
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
PrintExceptionContinue(&e, "AppInit()");
|
||||
@@ -175,10 +167,9 @@ bool AppInit(int argc, char* argv[])
|
||||
|
||||
if (!fRet)
|
||||
{
|
||||
Interrupt(threadGroup);
|
||||
threadGroup.join_all();
|
||||
Interrupt();
|
||||
} else {
|
||||
WaitForShutdown(&threadGroup);
|
||||
WaitForShutdown();
|
||||
}
|
||||
Shutdown();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user