shutdown: Stop threads before resetting ptrs

This commit is contained in:
MarcoFalke 2018-08-06 12:08:35 -04:00
parent 1ef57a96b8
commit faab63111d
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548
1 changed files with 7 additions and 5 deletions

View File

@ -209,11 +209,7 @@ void Shutdown()
// using the other before destroying them.
if (peerLogic) UnregisterValidationInterface(peerLogic.get());
if (g_connman) g_connman->Stop();
peerLogic.reset();
g_connman.reset();
if (g_txindex) {
g_txindex.reset();
}
if (g_txindex) g_txindex->Stop();
StopTorControl();
@ -222,6 +218,12 @@ void Shutdown()
threadGroup.interrupt_all();
threadGroup.join_all();
// After the threads that potentially access these pointers have been stopped,
// destruct and reset all to nullptr.
peerLogic.reset();
g_connman.reset();
g_txindex.reset();
if (g_is_mempool_loaded && gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) {
DumpMempool();
}