aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2017-06-27 19:07:52 -0400
committerMatt Corallo <git@bluematt.me>2017-07-07 12:55:57 -0400
commit3192975f1d177aa9f0bbd823c6387cfbfa943610 (patch)
treec14016ecb6fc50d7fc33b002368348efa8e12745 /src/init.cpp
parent08096bbbc6d6fef86943ca8ce5e6de18744d58ea (diff)
downloadbitcoin-3192975f1d177aa9f0bbd823c6387cfbfa943610.tar.xz
Flush CValidationInterface callbacks prior to destruction
Note that the CScheduler thread cant be running at this point, it has already been stopped with the rest of the init threadgroup. Thus, just calling any remaining loose callbacks during Shutdown() is sane.
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 94bba6820e..12f29a4ca8 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -215,6 +215,19 @@ void Shutdown()
fFeeEstimatesInitialized = false;
}
+ // FlushStateToDisk generates a SetBestChain callback, which we should avoid missing
+ FlushStateToDisk();
+
+ // After there are no more peers/RPC left to give us new data which may generate
+ // CValidationInterface callbacks, flush them...
+ GetMainSignals().FlushBackgroundCallbacks();
+
+ // Any future callbacks will be dropped. This should absolutely be safe - if
+ // missing a callback results in an unrecoverable situation, unclean shutdown
+ // would too. The only reason to do the above flushes is to let the wallet catch
+ // up with our current chain to avoid any strange pruning edge cases and make
+ // next startup faster by avoiding rescan.
+
{
LOCK(cs_main);
if (pcoinsTip != NULL) {