@@ -338,35 +338,35 @@ class CConnman
338338 // Network usage totals
339339 CCriticalSection cs_totalBytesRecv;
340340 CCriticalSection cs_totalBytesSent;
341- uint64_t nTotalBytesRecv;
342- uint64_t nTotalBytesSent;
341+ uint64_t nTotalBytesRecv GUARDED_BY (cs_totalBytesRecv) ;
342+ uint64_t nTotalBytesSent GUARDED_BY (cs_totalBytesSent) ;
343343
344344 // outbound limit & stats
345- uint64_t nMaxOutboundTotalBytesSentInCycle;
346- uint64_t nMaxOutboundCycleStartTime;
347- uint64_t nMaxOutboundLimit;
348- uint64_t nMaxOutboundTimeframe;
345+ uint64_t nMaxOutboundTotalBytesSentInCycle GUARDED_BY (cs_totalBytesSent) ;
346+ uint64_t nMaxOutboundCycleStartTime GUARDED_BY (cs_totalBytesSent) ;
347+ uint64_t nMaxOutboundLimit GUARDED_BY (cs_totalBytesSent) ;
348+ uint64_t nMaxOutboundTimeframe GUARDED_BY (cs_totalBytesSent) ;
349349
350350 // Whitelisted ranges. Any node connecting from these is automatically
351351 // whitelisted (as well as those connecting to whitelisted binds).
352- std::vector<CSubNet> vWhitelistedRange;
352+ std::vector<CSubNet> vWhitelistedRange GUARDED_BY (cs_vWhitelistedRange) ;
353353 CCriticalSection cs_vWhitelistedRange;
354354
355355 unsigned int nSendBufferMaxSize;
356356 unsigned int nReceiveFloodSize;
357357
358358 std::vector<ListenSocket> vhListenSocket;
359359 std::atomic<bool > fNetworkActive ;
360- banmap_t setBanned;
361- CCriticalSection cs_setBanned;
362- bool setBannedIsDirty;
360+ banmap_t setBanned GUARDED_BY (cs_setBanned) ;
361+ CCriticalSection cs_setBanned GUARDED_BY (cs_setBanned) ;
362+ bool setBannedIsDirty GUARDED_BY (cs_setBanned) ;
363363 bool fAddressesInitialized ;
364364 CAddrMan addrman;
365- std::deque<std::string> vOneShots;
365+ std::deque<std::string> vOneShots GUARDED_BY (cs_vOneShots) ;
366366 CCriticalSection cs_vOneShots;
367- std::vector<std::string> vAddedNodes;
367+ std::vector<std::string> vAddedNodes GUARDED_BY (cs_vAddedNodes) ;
368368 CCriticalSection cs_vAddedNodes;
369- std::vector<CNode*> vNodes;
369+ std::vector<CNode*> vNodes GUARDED_BY (cs_vNodes) ;
370370 std::list<CNode*> vNodesDisconnected;
371371 mutable CCriticalSection cs_vNodes;
372372 std::atomic<NodeId> nLastNodeId;
@@ -567,21 +567,21 @@ class CNode
567567 std::atomic<ServiceFlags> nServices;
568568 ServiceFlags nServicesExpected;
569569 SOCKET hSocket;
570- size_t nSendSize; // total size of all vSendMsg entries
571- size_t nSendOffset; // offset inside the first vSendMsg already sent
572- uint64_t nSendBytes;
573- std::deque<std::vector<unsigned char >> vSendMsg;
570+ size_t nSendSize GUARDED_BY (cs_vSend) ; // total size of all vSendMsg entries
571+ size_t nSendOffset GUARDED_BY (cs_vSend) ; // offset inside the first vSendMsg already sent
572+ uint64_t nSendBytes GUARDED_BY (cs_vSend) ;
573+ std::deque<std::vector<unsigned char >> vSendMsg GUARDED_BY (cs_vSend) ;
574574 CCriticalSection cs_vSend;
575575 CCriticalSection cs_vRecv;
576576
577577 CCriticalSection cs_vProcessMsg;
578- std::list<CNetMessage> vProcessMsg;
579- size_t nProcessQueueSize;
578+ std::list<CNetMessage> vProcessMsg GUARDED_BY (cs_vProcessMsg) ;
579+ size_t nProcessQueueSize GUARDED_BY (cs_vProcessMsg) ;
580580
581581 CCriticalSection cs_sendProcessing;
582582
583583 std::deque<CInv> vRecvGetData;
584- uint64_t nRecvBytes;
584+ uint64_t nRecvBytes GUARDED_BY (cs_vRecv) ;
585585 std::atomic<int > nRecvVersion;
586586
587587 std::atomic<int64_t > nLastSend;
@@ -594,7 +594,7 @@ class CNode
594594 // to be printed out, displayed to humans in various forms and so on. So we sanitize it and
595595 // store the sanitized version in cleanSubVer. The original should be used when dealing with
596596 // the network or wire types and the cleaned string used when displayed or logged.
597- std::string strSubVer, cleanSubVer;
597+ std::string strSubVer, cleanSubVer GUARDED_BY (cs_SubVer) ;
598598 CCriticalSection cs_SubVer; // used for both cleanSubVer and strSubVer
599599 bool fWhitelisted ; // This peer can bypass DoS banning.
600600 bool fFeeler ; // If true this node is being used as a short lived feeler.
@@ -608,11 +608,11 @@ class CNode
608608 // a) it allows us to not relay tx invs before receiving the peer's version message
609609 // b) the peer may tell us in its version message that we should not relay tx invs
610610 // unless it loads a bloom filter.
611- bool fRelayTxes ; // protected by cs_filter
611+ bool fRelayTxes GUARDED_BY (cs_filter) ; // protected by cs_filter
612612 bool fSentAddr ;
613613 CSemaphoreGrant grantOutbound;
614614 CCriticalSection cs_filter;
615- CBloomFilter* pfilter;
615+ CBloomFilter* pfilter GUARDED_BY (cs_filter) ;
616616 std::atomic<int > nRefCount;
617617 const NodeId id;
618618
@@ -621,8 +621,8 @@ class CNode
621621 std::atomic_bool fPauseSend ;
622622protected:
623623
624- mapMsgCmdSize mapSendBytesPerMsgCmd;
625- mapMsgCmdSize mapRecvBytesPerMsgCmd;
624+ mapMsgCmdSize mapSendBytesPerMsgCmd GUARDED_BY (cs_vSend) ;
625+ mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY (cs_vRecv) ;
626626
627627public:
628628 uint256 hashContinue;
@@ -637,23 +637,23 @@ class CNode
637637 int64_t nNextLocalAddrSend;
638638
639639 // inventory based relay
640- CRollingBloomFilter filterInventoryKnown;
640+ CRollingBloomFilter filterInventoryKnown GUARDED_BY (cs_inventory) ;
641641 // Set of transaction ids we still have to announce.
642642 // They are sorted by the mempool before relay, so the order is not important.
643- std::set<uint256> setInventoryTxToSend;
643+ std::set<uint256> setInventoryTxToSend GUARDED_BY (cs_inventory) ;
644644 // List of block ids we still have announce.
645645 // There is no final sorting before sending, as they are always sent immediately
646646 // and in the order requested.
647- std::vector<uint256> vInventoryBlockToSend;
647+ std::vector<uint256> vInventoryBlockToSend GUARDED_BY (cs_inventory) ;
648648 CCriticalSection cs_inventory;
649649 std::set<uint256> setAskFor;
650650 std::multimap<int64_t , CInv> mapAskFor;
651651 int64_t nNextInvSend;
652652 // Used for headers announcements - unfiltered blocks to relay
653653 // Also protected by cs_inventory
654- std::vector<uint256> vBlockHashesToAnnounce;
654+ std::vector<uint256> vBlockHashesToAnnounce GUARDED_BY (cs_inventory) ;
655655 // Used for BIP35 mempool sending, also protected by cs_inventory
656- bool fSendMempool ;
656+ bool fSendMempool GUARDED_BY (cs_inventory) ;
657657
658658 // Last time a "MEMPOOL" request was serviced.
659659 std::atomic<int64_t > timeLastMempoolReq;
@@ -674,7 +674,7 @@ class CNode
674674 // Whether a ping is requested.
675675 std::atomic<bool > fPingQueued ;
676676 // Minimum fee rate with which to filter inv's to this node
677- CAmount minFeeFilter;
677+ CAmount minFeeFilter GUARDED_BY (cs_feeFilter) ;
678678 CCriticalSection cs_feeFilter;
679679 CAmount lastSentFeeFilter;
680680 int64_t nextSendTimeFeeFilter;
@@ -695,9 +695,9 @@ class CNode
695695 std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
696696
697697 mutable CCriticalSection cs_addrName;
698- std::string addrName;
698+ std::string addrName GUARDED_BY (cs_addrName) ;
699699
700- CService addrLocal;
700+ CService addrLocal GUARDED_BY (cs_addrLocal) ;
701701 mutable CCriticalSection cs_addrLocal;
702702public:
703703
0 commit comments