Skip to content

Commit 35aeabe

Browse files
committed
Make fReindex atomic to avoid race
1 parent 58d91af commit 35aeabe

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/validation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ CWaitableCriticalSection csBestBlock;
6666
CConditionVariable cvBlockChange;
6767
int nScriptCheckThreads = 0;
6868
std::atomic_bool fImporting(false);
69-
bool fReindex = false;
69+
std::atomic_bool fReindex(false);
7070
bool fTxIndex = false;
7171
bool fHavePruned = false;
7272
bool fPruneMode = false;
@@ -3523,7 +3523,7 @@ bool static LoadBlockIndexDB(const CChainParams& chainparams)
35233523
// Check whether we need to continue reindexing
35243524
bool fReindexing = false;
35253525
pblocktree->ReadReindexing(fReindexing);
3526-
fReindex |= fReindexing;
3526+
if(fReindexing) fReindex = true;
35273527

35283528
// Check whether we have a transaction index
35293529
pblocktree->ReadFlag("txindex", fTxIndex);

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ extern const std::string strMessageMagic;
167167
extern CWaitableCriticalSection csBestBlock;
168168
extern CConditionVariable cvBlockChange;
169169
extern std::atomic_bool fImporting;
170-
extern bool fReindex;
170+
extern std::atomic_bool fReindex;
171171
extern int nScriptCheckThreads;
172172
extern bool fTxIndex;
173173
extern bool fIsBareMultisigStd;

0 commit comments

Comments
 (0)