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:
Matt Corallo
2018-01-24 21:15:56 -05:00
parent 6970b30c6f
commit 082a61c69d
4 changed files with 22 additions and 27 deletions

View File

@@ -28,7 +28,6 @@
#include <init.h>
#include <rpc/server.h>
#include <scheduler.h>
#include <ui_interface.h>
#include <util.h>
#include <warnings.h>
@@ -193,8 +192,6 @@ Q_SIGNALS:
void runawayException(const QString &message);
private:
boost::thread_group threadGroup;
CScheduler scheduler;
/// Pass fatal exception message to UI thread
void handleRunawayException(const std::exception *e);
@@ -300,7 +297,7 @@ void BitcoinCore::initialize()
try
{
qDebug() << __func__ << ": Running initialization in thread";
bool rv = AppInitMain(threadGroup, scheduler);
bool rv = AppInitMain();
Q_EMIT initializeResult(rv);
} catch (const std::exception& e) {
handleRunawayException(&e);
@@ -314,8 +311,7 @@ void BitcoinCore::shutdown()
try
{
qDebug() << __func__ << ": Running Shutdown in thread";
Interrupt(threadGroup);
threadGroup.join_all();
Interrupt();
Shutdown();
qDebug() << __func__ << ": Shutdown finished";
Q_EMIT shutdownResult();