diff --git a/src/init.cpp b/src/init.cpp index 4dfa7a452d..992ce8ebdc 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -130,6 +130,7 @@ static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat"; // std::atomic fRequestShutdown(false); +std::atomic fDumpMempoolLater(false); void StartShutdown() { @@ -211,7 +212,8 @@ void Shutdown() StopTorControl(); UnregisterNodeSignals(GetNodeSignals()); - DumpMempool(); + if (fDumpMempoolLater) + DumpMempool(); if (fFeeEstimatesInitialized) { @@ -669,6 +671,7 @@ void ThreadImport(std::vector vImportFiles) } } // End scope of CImportingNow LoadMempool(); + fDumpMempoolLater = !fRequestShutdown; } /** Sanity checks diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 16b5893753..72f5f4aac9 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -444,6 +444,8 @@ void BitcoinApplication::requestShutdown() delete clientModel; clientModel = 0; + StartShutdown(); + // Request shutdown from core thread Q_EMIT requestedShutdown(); } diff --git a/src/validation.cpp b/src/validation.cpp index 648fed8bc6..37a4186e0a 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4099,6 +4099,8 @@ bool LoadMempool(void) } else { ++skipped; } + if (ShutdownRequested()) + return false; } std::map mapDeltas; file >> mapDeltas;