From fa71eb5196fc157213d7b6364071530ab19df724 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Fri, 2 Feb 2018 18:11:01 -0500 Subject: Convert comments to thread safety annotations --- src/net.cpp | 1 + src/net.h | 11 +++++------ src/validation.cpp | 6 ++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 65a308780a..e065ac0f28 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1011,6 +1011,7 @@ bool CConnman::AttemptToEvictConnection() continue; if (node->fDisconnect) continue; + LOCK(node->cs_filter); NodeEvictionCandidate candidate = {node->GetId(), node->nTimeConnected, node->nMinPingUsecTime, node->nLastBlockTime, node->nLastTXTime, HasAllDesirableServiceFlags(node->nServices), diff --git a/src/net.h b/src/net.h index 164ec9080c..32cc02f5a9 100644 --- a/src/net.h +++ b/src/net.h @@ -677,10 +677,10 @@ public: // a) it allows us to not relay tx invs before receiving the peer's version message // b) the peer may tell us in its version message that we should not relay tx invs // unless it loads a bloom filter. - bool fRelayTxes; //protected by cs_filter + bool fRelayTxes GUARDED_BY(cs_filter); bool fSentAddr; CSemaphoreGrant grantOutbound; - CCriticalSection cs_filter; + mutable CCriticalSection cs_filter; std::unique_ptr pfilter; std::atomic nRefCount; @@ -718,10 +718,9 @@ public: std::multimap mapAskFor; int64_t nNextInvSend; // Used for headers announcements - unfiltered blocks to relay - // Also protected by cs_inventory - std::vector vBlockHashesToAnnounce; - // Used for BIP35 mempool sending, also protected by cs_inventory - bool fSendMempool; + std::vector vBlockHashesToAnnounce GUARDED_BY(cs_inventory); + // Used for BIP35 mempool sending + bool fSendMempool GUARDED_BY(cs_inventory); // Last time a "MEMPOOL" request was serviced. std::atomic timeLastMempoolReq; diff --git a/src/validation.cpp b/src/validation.cpp index 241957878e..6333dd98d2 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1680,8 +1680,7 @@ void ThreadScriptCheck() { scriptcheckqueue.Thread(); } -// Protected by cs_main -VersionBitsCache versionbitscache; +VersionBitsCache versionbitscache GUARDED_BY(cs_main); int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params) { @@ -1722,8 +1721,7 @@ public: } }; -// Protected by cs_main -static ThresholdConditionCache warningcache[VERSIONBITS_NUM_BITS]; +static ThresholdConditionCache warningcache[VERSIONBITS_NUM_BITS] GUARDED_BY(cs_main); // 0.13.0 was shipped with a segwit deployment defined for testnet, but not for // mainnet. We no longer need to support disabling the segwit deployment -- cgit v1.2.3