Skip to content

Commit

Permalink
init: allow shutdown during 'Activating best chain...'
Browse files Browse the repository at this point in the history
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...)
  • Loading branch information
laanwj committed Apr 6, 2016
1 parent 1b2460b commit 07398e8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2877,6 +2877,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;
Expand Down

0 comments on commit 07398e8

Please sign in to comment.