aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-02-08 08:40:55 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2018-02-08 08:41:18 +0100
commit7217ea2cc8dd17784a95574724e76303ac2e2823 (patch)
tree0436ac31a688ecb1b59660a5e02abc1473bd06b6 /src/validation.cpp
parent0277173b1defb63216d40a8d8805ae6d5d563c26 (diff)
parentdd2de47c6288654abb2c3eef29edcd1cc5f39fc9 (diff)
Merge #12367: Fix two fast-shutdown bugs
dd2de47 Fix fast-shutdown crash if genesis block was not loaded (Matt Corallo) 1c9394a Fix fast-shutdown hang on ThreadImport+GenesisWait (Matt Corallo) Pull request description: The second commit is a much simpler alternative fix for the issue fixed in #12349. To test I made ShutdownRequested() always StartShutdown() after a certain number of calls, which turned up one other hang, fixed in the first commit. Tree-SHA512: 86bde6ac4b8b4e2cb99fff87dafeed02c0d9514acee6d94455637fb2da9ffc274b5ad31b0a6b9f5bd7b700ae35395f28ddb14ffc65ddda3619aa28df28a5607d
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index 16b656c7f5..f1abe6f46d 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2581,9 +2581,6 @@ bool CChainState::ActivateBestChain(CValidationState &state, const CChainParams&
SyncWithValidationInterfaceQueue();
}
- if (ShutdownRequested())
- break;
-
const CBlockIndex *pindexFork;
bool fInitialDownload;
{
@@ -2630,6 +2627,13 @@ bool CChainState::ActivateBestChain(CValidationState &state, const CChainParams&
}
if (nStopAtHeight && pindexNewTip && pindexNewTip->nHeight >= nStopAtHeight) StartShutdown();
+
+ // We check shutdown only after giving ActivateBestChainStep a chance to run once so that we
+ // never shutdown before connecting the genesis block during LoadChainTip(). Previously this
+ // caused an assert() failure during shutdown in such cases as the UTXO DB flushing checks
+ // that the best block hash is non-null.
+ if (ShutdownRequested())
+ break;
} while (pindexNewTip != pindexMostWork);
CheckBlockIndex(chainparams.GetConsensus());