aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorMarcoFalke <[email protected]>2018-08-06 12:08:35 -0400
committerMarcoFalke <[email protected]>2018-08-06 16:35:41 -0400
commitfaab63111d8f27335aa1f09c1a48da3be45135de (patch)
tree6877121b635e8ae5b69fe7ef473abf5643a4bad2 /src/init.cpp
parentMerge #13255: trivial: Fixed typos and cleaned up language (diff)
downloaddiscoin-faab63111d8f27335aa1f09c1a48da3be45135de.tar.xz
discoin-faab63111d8f27335aa1f09c1a48da3be45135de.zip
shutdown: Stop threads before resetting ptrs
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 21445929d..5c2973691 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -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();
}