Skip to content

Commit d491030

Browse files
author
MarcoFalke
committed
Merge #14772: refactor: Convert comments to thread safety annotations
fa71eb5 Convert comments to thread safety annotations (MarcoFalke) Pull request description: Convert human-only-readable annotations to human-and-machine-readable annotations. Tree-SHA512: 98a97b32b50e8ec816626ed853d56c9afb31065eb14f058cda8f22a16ddd2b0c02911f9e30478aa347f466891f972496d89a828eb6e4662fb712d7d9e7643d49
2 parents a4eaaa6 + fa71eb5 commit d491030

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/net.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ bool CConnman::AttemptToEvictConnection()
10111011
continue;
10121012
if (node->fDisconnect)
10131013
continue;
1014+
LOCK(node->cs_filter);
10141015
NodeEvictionCandidate candidate = {node->GetId(), node->nTimeConnected, node->nMinPingUsecTime,
10151016
node->nLastBlockTime, node->nLastTXTime,
10161017
HasAllDesirableServiceFlags(node->nServices),

src/net.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -677,10 +677,10 @@ class CNode
677677
// a) it allows us to not relay tx invs before receiving the peer's version message
678678
// b) the peer may tell us in its version message that we should not relay tx invs
679679
// unless it loads a bloom filter.
680-
bool fRelayTxes; //protected by cs_filter
680+
bool fRelayTxes GUARDED_BY(cs_filter);
681681
bool fSentAddr;
682682
CSemaphoreGrant grantOutbound;
683-
CCriticalSection cs_filter;
683+
mutable CCriticalSection cs_filter;
684684
std::unique_ptr<CBloomFilter> pfilter;
685685
std::atomic<int> nRefCount;
686686

@@ -718,10 +718,9 @@ class CNode
718718
std::multimap<int64_t, CInv> mapAskFor;
719719
int64_t nNextInvSend;
720720
// Used for headers announcements - unfiltered blocks to relay
721-
// Also protected by cs_inventory
722-
std::vector<uint256> vBlockHashesToAnnounce;
723-
// Used for BIP35 mempool sending, also protected by cs_inventory
724-
bool fSendMempool;
721+
std::vector<uint256> vBlockHashesToAnnounce GUARDED_BY(cs_inventory);
722+
// Used for BIP35 mempool sending
723+
bool fSendMempool GUARDED_BY(cs_inventory);
725724

726725
// Last time a "MEMPOOL" request was serviced.
727726
std::atomic<int64_t> timeLastMempoolReq;

src/validation.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,8 +1680,7 @@ void ThreadScriptCheck() {
16801680
scriptcheckqueue.Thread();
16811681
}
16821682

1683-
// Protected by cs_main
1684-
VersionBitsCache versionbitscache;
1683+
VersionBitsCache versionbitscache GUARDED_BY(cs_main);
16851684

16861685
int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params)
16871686
{
@@ -1722,8 +1721,7 @@ class WarningBitsConditionChecker : public AbstractThresholdConditionChecker
17221721
}
17231722
};
17241723

1725-
// Protected by cs_main
1726-
static ThresholdConditionCache warningcache[VERSIONBITS_NUM_BITS];
1724+
static ThresholdConditionCache warningcache[VERSIONBITS_NUM_BITS] GUARDED_BY(cs_main);
17271725

17281726
// 0.13.0 was shipped with a segwit deployment defined for testnet, but not for
17291727
// mainnet. We no longer need to support disabling the segwit deployment

0 commit comments

Comments
 (0)