From 4226aacdba7d0e1e22555dac69363b3b460a166b Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 6 Apr 2016 10:27:51 +0200 Subject: init: allow shutdown during 'Activating best chain...' Two-line patch to make it possible to shut down bitcoind cleanly during the initial ActivateBestChain. Fixes #6459 (among other complaints). To reproduce: - shutdown bitcoind - copy chainstate - start bitcoind - let the chain sync a bit - shutdown bitcoind - copy back old chainstate - start bitcoind - bitcoind will catch up with all blocks during Init() (the `boost::this_thread::interruption_point` / `ShutdownRequested()` dance is ugly, this should be refactored all over bitcoind at some point when moving from boost::threads to c++11 threads, but it works...) Github-Pull: #7821 Rebased-From: 07398e8e9d2ef807e63abd0978a6e98549bdf271 --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 14f70cdf5f..27d8a4a17d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2867,6 +2867,8 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams, CBlockIndex *pindexMostWork = NULL; do { boost::this_thread::interruption_point(); + if (ShutdownRequested()) + break; CBlockIndex *pindexNewTip = NULL; const CBlockIndex *pindexFork; -- cgit v1.2.3