Skip to content

Commit daad009

Browse files
committed
validation: replace lock with annotation in UnloadBlockIndex()
1 parent 6ac637f commit daad009

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/test/util/setup_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ ChainTestingSetup::~ChainTestingSetup()
180180
m_node.banman.reset();
181181
m_node.addrman.reset();
182182
m_node.args = nullptr;
183-
UnloadBlockIndex(m_node.mempool.get(), *m_node.chainman);
183+
WITH_LOCK(::cs_main, UnloadBlockIndex(m_node.mempool.get(), *m_node.chainman));
184184
m_node.mempool.reset();
185185
m_node.scheduler.reset();
186186
m_node.chainman->Reset();

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4028,7 +4028,7 @@ void CChainState::UnloadBlockIndex() {
40284028
// block index state
40294029
void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman)
40304030
{
4031-
LOCK(cs_main);
4031+
AssertLockHeld(::cs_main);
40324032
chainman.Unload();
40334033
pindexBestHeader = nullptr;
40344034
if (mempool) mempool->clear();

src/validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ extern CBlockIndex *pindexBestHeader;
138138
extern const std::vector<std::string> CHECKLEVEL_DOC;
139139

140140
/** Unload database information */
141-
void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman);
141+
void UnloadBlockIndex(CTxMemPool* mempool, ChainstateManager& chainman) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
142142
/** Run instances of script checking worker threads */
143143
void StartScriptCheckWorkerThreads(int threads_num);
144144
/** Stop all of the script checking worker threads */

0 commit comments

Comments
 (0)