From 35aeabec62cf10f3c0de297b1189f0a669b69d6e Mon Sep 17 00:00:00 2001 From: MeshCollider Date: Thu, 24 Aug 2017 13:45:26 +1200 Subject: [PATCH] Make fReindex atomic to avoid race --- src/validation.cpp | 4 ++-- src/validation.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index d1a8b8460a6..0d4fdf79abf 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -66,7 +66,7 @@ CWaitableCriticalSection csBestBlock; CConditionVariable cvBlockChange; int nScriptCheckThreads = 0; std::atomic_bool fImporting(false); -bool fReindex = false; +std::atomic_bool fReindex(false); bool fTxIndex = false; bool fHavePruned = false; bool fPruneMode = false; @@ -3523,7 +3523,7 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams) // Check whether we need to continue reindexing bool fReindexing = false; pblocktree->ReadReindexing(fReindexing); - fReindex |= fReindexing; + if(fReindexing) fReindex = true; // Check whether we have a transaction index pblocktree->ReadFlag("txindex", fTxIndex); diff --git a/src/validation.h b/src/validation.h index d0f6cdc135e..10511fce31e 100644 --- a/src/validation.h +++ b/src/validation.h @@ -167,7 +167,7 @@ extern const std::string strMessageMagic; extern CWaitableCriticalSection csBestBlock; extern CConditionVariable cvBlockChange; extern std::atomic_bool fImporting; -extern bool fReindex; +extern std::atomic_bool fReindex; extern int nScriptCheckThreads; extern bool fTxIndex; extern bool fIsBareMultisigStd;