Skip to content

Commit 5473e25

Browse files
author
MarcoFalke
committed
Merge #14444: Add compile time checking for cs_main locks which we assert at run time
0089905 Add compile time checking for cs_main locks which we assert at run time (practicalswift) Pull request description: Assert locking requirements at compile-time (`EXCLUSIVE_LOCKS_REQUIRED(foo)`) instead of at run-time (`AssertLockHeld(…)`). Tree-SHA512: f4965ebf4bb5dbf5e7ed738cacf82c0f6cd55134fb968860bf84a84e29806485617f223910bb8c5461213f1829b0137c64ba1f6d6a2008b3cac3bb3a28df9324
2 parents 94cf1ec + 0089905 commit 5473e25

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/index/base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ bool BaseIndex::Init()
6565
return true;
6666
}
6767

68-
static const CBlockIndex* NextSyncBlock(const CBlockIndex* pindex_prev)
68+
static const CBlockIndex* NextSyncBlock(const CBlockIndex* pindex_prev) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
6969
{
7070
AssertLockHeld(cs_main);
7171

src/validation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ bool LoadGenesisBlock(const CChainParams& chainparams);
257257
* initializing state if we're running with -reindex. */
258258
bool LoadBlockIndex(const CChainParams& chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
259259
/** Update the chain tip based on database information. */
260-
bool LoadChainTip(const CChainParams& chainparams);
260+
bool LoadChainTip(const CChainParams& chainparams) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
261261
/** Unload database information */
262262
void UnloadBlockIndex();
263263
/** Run an instance of the script checking thread */
@@ -436,7 +436,7 @@ inline CBlockIndex* LookupBlockIndex(const uint256& hash)
436436
}
437437

438438
/** Find the last common block between the parameter chain and a locator. */
439-
CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator);
439+
CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& locator) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
440440

441441
/** Mark a block as precious and reorganize.
442442
*

0 commit comments

Comments
 (0)