Skip to content

Commit 07398e8

Browse files
committed
init: allow shutdown during 'Activating best chain...'
Two-line patch to make it possible to shut down bitcoind cleanly during the initial ActivateBestChain. Fixes bitcoin#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...)
1 parent 1b2460b commit 07398e8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,6 +2877,8 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
28772877
CBlockIndex *pindexMostWork = NULL;
28782878
do {
28792879
boost::this_thread::interruption_point();
2880+
if (ShutdownRequested())
2881+
break;
28802882

28812883
CBlockIndex *pindexNewTip = NULL;
28822884
const CBlockIndex *pindexFork;

0 commit comments

Comments
 (0)