Add missing locking annotations
This commit is contained in:
parent
600b85bb41
commit
b312cd7707
3 changed files with 24 additions and 33 deletions
15
src/net.cpp
15
src/net.cpp
|
@ -82,8 +82,8 @@ bool fDiscover = true;
|
||||||
bool fListen = true;
|
bool fListen = true;
|
||||||
bool fRelayTxes = true;
|
bool fRelayTxes = true;
|
||||||
CCriticalSection cs_mapLocalHost;
|
CCriticalSection cs_mapLocalHost;
|
||||||
std::map<CNetAddr, LocalServiceInfo> mapLocalHost;
|
std::map<CNetAddr, LocalServiceInfo> mapLocalHost GUARDED_BY(cs_mapLocalHost);
|
||||||
static bool vfLimited[NET_MAX] = {};
|
static bool vfLimited[NET_MAX] GUARDED_BY(cs_mapLocalHost) = {};
|
||||||
std::string strSubVersion;
|
std::string strSubVersion;
|
||||||
|
|
||||||
limitedmap<uint256, int64_t> mapAlreadyAskedFor(MAX_INV_SZ);
|
limitedmap<uint256, int64_t> mapAlreadyAskedFor(MAX_INV_SZ);
|
||||||
|
@ -874,16 +874,7 @@ const uint256& CNetMessage::GetMessageHash() const
|
||||||
return data_hash;
|
return data_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t CConnman::SocketSendData(CNode *pnode) const EXCLUSIVE_LOCKS_REQUIRED(pnode->cs_vSend)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// requires LOCK(cs_vSend)
|
|
||||||
size_t CConnman::SocketSendData(CNode *pnode) const
|
|
||||||
{
|
{
|
||||||
auto it = pnode->vSendMsg.begin();
|
auto it = pnode->vSendMsg.begin();
|
||||||
size_t nSentSize = 0;
|
size_t nSentSize = 0;
|
||||||
|
|
38
src/net.h
38
src/net.h
|
@ -400,12 +400,12 @@ private:
|
||||||
|
|
||||||
std::vector<ListenSocket> vhListenSocket;
|
std::vector<ListenSocket> vhListenSocket;
|
||||||
std::atomic<bool> fNetworkActive;
|
std::atomic<bool> fNetworkActive;
|
||||||
banmap_t setBanned;
|
banmap_t setBanned GUARDED_BY(cs_setBanned);
|
||||||
CCriticalSection cs_setBanned;
|
CCriticalSection cs_setBanned;
|
||||||
bool setBannedIsDirty;
|
bool setBannedIsDirty GUARDED_BY(cs_setBanned);
|
||||||
bool fAddressesInitialized;
|
bool fAddressesInitialized;
|
||||||
CAddrMan addrman;
|
CAddrMan addrman;
|
||||||
std::deque<std::string> vOneShots;
|
std::deque<std::string> vOneShots GUARDED_BY(cs_vOneShots);
|
||||||
CCriticalSection cs_vOneShots;
|
CCriticalSection cs_vOneShots;
|
||||||
std::vector<std::string> vAddedNodes GUARDED_BY(cs_vAddedNodes);
|
std::vector<std::string> vAddedNodes GUARDED_BY(cs_vAddedNodes);
|
||||||
CCriticalSection cs_vAddedNodes;
|
CCriticalSection cs_vAddedNodes;
|
||||||
|
@ -540,7 +540,7 @@ struct LocalServiceInfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CCriticalSection cs_mapLocalHost;
|
extern CCriticalSection cs_mapLocalHost;
|
||||||
extern std::map<CNetAddr, LocalServiceInfo> mapLocalHost;
|
extern std::map<CNetAddr, LocalServiceInfo> mapLocalHost GUARDED_BY(cs_mapLocalHost);
|
||||||
typedef std::map<std::string, uint64_t> mapMsgCmdSize; //command, total bytes
|
typedef std::map<std::string, uint64_t> mapMsgCmdSize; //command, total bytes
|
||||||
|
|
||||||
class CNodeStats
|
class CNodeStats
|
||||||
|
@ -630,23 +630,23 @@ class CNode
|
||||||
public:
|
public:
|
||||||
// socket
|
// socket
|
||||||
std::atomic<ServiceFlags> nServices;
|
std::atomic<ServiceFlags> nServices;
|
||||||
SOCKET hSocket;
|
SOCKET hSocket GUARDED_BY(cs_hSocket);
|
||||||
size_t nSendSize; // total size of all vSendMsg entries
|
size_t nSendSize; // total size of all vSendMsg entries
|
||||||
size_t nSendOffset; // offset inside the first vSendMsg already sent
|
size_t nSendOffset; // offset inside the first vSendMsg already sent
|
||||||
uint64_t nSendBytes;
|
uint64_t nSendBytes GUARDED_BY(cs_vSend);
|
||||||
std::deque<std::vector<unsigned char>> vSendMsg;
|
std::deque<std::vector<unsigned char>> vSendMsg GUARDED_BY(cs_vSend);
|
||||||
CCriticalSection cs_vSend;
|
CCriticalSection cs_vSend;
|
||||||
CCriticalSection cs_hSocket;
|
CCriticalSection cs_hSocket;
|
||||||
CCriticalSection cs_vRecv;
|
CCriticalSection cs_vRecv;
|
||||||
|
|
||||||
CCriticalSection cs_vProcessMsg;
|
CCriticalSection cs_vProcessMsg;
|
||||||
std::list<CNetMessage> vProcessMsg;
|
std::list<CNetMessage> vProcessMsg GUARDED_BY(cs_vProcessMsg);
|
||||||
size_t nProcessQueueSize;
|
size_t nProcessQueueSize;
|
||||||
|
|
||||||
CCriticalSection cs_sendProcessing;
|
CCriticalSection cs_sendProcessing;
|
||||||
|
|
||||||
std::deque<CInv> vRecvGetData;
|
std::deque<CInv> vRecvGetData;
|
||||||
uint64_t nRecvBytes;
|
uint64_t nRecvBytes GUARDED_BY(cs_vRecv);
|
||||||
std::atomic<int> nRecvVersion;
|
std::atomic<int> nRecvVersion;
|
||||||
|
|
||||||
std::atomic<int64_t> nLastSend;
|
std::atomic<int64_t> nLastSend;
|
||||||
|
@ -662,7 +662,7 @@ public:
|
||||||
// to be printed out, displayed to humans in various forms and so on. So we sanitize it and
|
// to be printed out, displayed to humans in various forms and so on. So we sanitize it and
|
||||||
// store the sanitized version in cleanSubVer. The original should be used when dealing with
|
// store the sanitized version in cleanSubVer. The original should be used when dealing with
|
||||||
// the network or wire types and the cleaned string used when displayed or logged.
|
// the network or wire types and the cleaned string used when displayed or logged.
|
||||||
std::string strSubVer, cleanSubVer;
|
std::string strSubVer GUARDED_BY(cs_SubVer), cleanSubVer GUARDED_BY(cs_SubVer);
|
||||||
CCriticalSection cs_SubVer; // used for both cleanSubVer and strSubVer
|
CCriticalSection cs_SubVer; // used for both cleanSubVer and strSubVer
|
||||||
bool fWhitelisted; // This peer can bypass DoS banning.
|
bool fWhitelisted; // This peer can bypass DoS banning.
|
||||||
bool fFeeler; // If true this node is being used as a short lived feeler.
|
bool fFeeler; // If true this node is being used as a short lived feeler.
|
||||||
|
@ -681,7 +681,7 @@ public:
|
||||||
bool fSentAddr;
|
bool fSentAddr;
|
||||||
CSemaphoreGrant grantOutbound;
|
CSemaphoreGrant grantOutbound;
|
||||||
mutable CCriticalSection cs_filter;
|
mutable CCriticalSection cs_filter;
|
||||||
std::unique_ptr<CBloomFilter> pfilter;
|
std::unique_ptr<CBloomFilter> pfilter PT_GUARDED_BY(cs_filter);
|
||||||
std::atomic<int> nRefCount;
|
std::atomic<int> nRefCount;
|
||||||
|
|
||||||
const uint64_t nKeyedNetGroup;
|
const uint64_t nKeyedNetGroup;
|
||||||
|
@ -690,7 +690,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
mapMsgCmdSize mapSendBytesPerMsgCmd;
|
mapMsgCmdSize mapSendBytesPerMsgCmd;
|
||||||
mapMsgCmdSize mapRecvBytesPerMsgCmd;
|
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint256 hashContinue;
|
uint256 hashContinue;
|
||||||
|
@ -701,18 +701,18 @@ public:
|
||||||
CRollingBloomFilter addrKnown;
|
CRollingBloomFilter addrKnown;
|
||||||
bool fGetAddr;
|
bool fGetAddr;
|
||||||
std::set<uint256> setKnown;
|
std::set<uint256> setKnown;
|
||||||
int64_t nNextAddrSend;
|
int64_t nNextAddrSend GUARDED_BY(cs_sendProcessing);
|
||||||
int64_t nNextLocalAddrSend;
|
int64_t nNextLocalAddrSend GUARDED_BY(cs_sendProcessing);
|
||||||
|
|
||||||
// inventory based relay
|
// inventory based relay
|
||||||
CRollingBloomFilter filterInventoryKnown;
|
CRollingBloomFilter filterInventoryKnown GUARDED_BY(cs_inventory);
|
||||||
// Set of transaction ids we still have to announce.
|
// Set of transaction ids we still have to announce.
|
||||||
// They are sorted by the mempool before relay, so the order is not important.
|
// They are sorted by the mempool before relay, so the order is not important.
|
||||||
std::set<uint256> setInventoryTxToSend;
|
std::set<uint256> setInventoryTxToSend;
|
||||||
// List of block ids we still have announce.
|
// List of block ids we still have announce.
|
||||||
// There is no final sorting before sending, as they are always sent immediately
|
// There is no final sorting before sending, as they are always sent immediately
|
||||||
// and in the order requested.
|
// and in the order requested.
|
||||||
std::vector<uint256> vInventoryBlockToSend;
|
std::vector<uint256> vInventoryBlockToSend GUARDED_BY(cs_inventory);
|
||||||
CCriticalSection cs_inventory;
|
CCriticalSection cs_inventory;
|
||||||
std::set<uint256> setAskFor;
|
std::set<uint256> setAskFor;
|
||||||
std::multimap<int64_t, CInv> mapAskFor;
|
std::multimap<int64_t, CInv> mapAskFor;
|
||||||
|
@ -741,7 +741,7 @@ public:
|
||||||
// Whether a ping is requested.
|
// Whether a ping is requested.
|
||||||
std::atomic<bool> fPingQueued;
|
std::atomic<bool> fPingQueued;
|
||||||
// Minimum fee rate with which to filter inv's to this node
|
// Minimum fee rate with which to filter inv's to this node
|
||||||
CAmount minFeeFilter;
|
CAmount minFeeFilter GUARDED_BY(cs_feeFilter);
|
||||||
CCriticalSection cs_feeFilter;
|
CCriticalSection cs_feeFilter;
|
||||||
CAmount lastSentFeeFilter;
|
CAmount lastSentFeeFilter;
|
||||||
int64_t nextSendTimeFeeFilter;
|
int64_t nextSendTimeFeeFilter;
|
||||||
|
@ -761,10 +761,10 @@ private:
|
||||||
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
|
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
|
||||||
|
|
||||||
mutable CCriticalSection cs_addrName;
|
mutable CCriticalSection cs_addrName;
|
||||||
std::string addrName;
|
std::string addrName GUARDED_BY(cs_addrName);
|
||||||
|
|
||||||
// Our address, as reported by the peer
|
// Our address, as reported by the peer
|
||||||
CService addrLocal;
|
CService addrLocal GUARDED_BY(cs_addrLocal);
|
||||||
mutable CCriticalSection cs_addrLocal;
|
mutable CCriticalSection cs_addrLocal;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
static proxyType proxyInfo[NET_MAX];
|
|
||||||
static proxyType nameProxy;
|
|
||||||
static CCriticalSection cs_proxyInfos;
|
static CCriticalSection cs_proxyInfos;
|
||||||
|
static proxyType proxyInfo[NET_MAX] GUARDED_BY(cs_proxyInfos);
|
||||||
|
static proxyType nameProxy GUARDED_BY(cs_proxyInfos);
|
||||||
int nConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
|
int nConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
|
||||||
bool fNameLookup = DEFAULT_NAME_LOOKUP;
|
bool fNameLookup = DEFAULT_NAME_LOOKUP;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue