mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Merge #20816: net: Move RecordBytesSent() call out of cs_vSend lock
378aedc452[net] Add cs_vSend lock annotations (John Newbery)673254515a[net] Move RecordBytesSent() call out of cs_vSend lock (John Newbery) Pull request description: RecordBytesSent() does not require cs_vSend to be locked, so reduce the scope of cs_vSend. Also correctly annotate the CNode data members that are guarded by cs_vSend. This is a simpler alternative to #19673. ACKs for top commit: jnewbery: ok, reverting to commit378aedcwhich has two ACKs already. Any style issues can be fixed up in future PRs. troygiorshev: ACK378aedc452theStack: re-ACK378aedc452MarcoFalke: review ACK378aedc452🔌 Tree-SHA512: e9cd6c472b7e1479120c1bf2d1c640cf6d18c7d589a5f9b7dfc4875e5790adaab403a7a1b945a47e79e7249a614b8583270e4549f89b22e8a9edb2e4818b0d07
This commit is contained in:
14
src/net.cpp
14
src/net.cpp
@@ -1506,16 +1506,10 @@ void CConnman::SocketHandler()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
if (sendSet) {
|
||||||
// Send
|
// Send data
|
||||||
//
|
size_t bytes_sent = WITH_LOCK(pnode->cs_vSend, return SocketSendData(pnode));
|
||||||
if (sendSet)
|
if (bytes_sent) RecordBytesSent(bytes_sent);
|
||||||
{
|
|
||||||
LOCK(pnode->cs_vSend);
|
|
||||||
size_t nBytes = SocketSendData(pnode);
|
|
||||||
if (nBytes) {
|
|
||||||
RecordBytesSent(nBytes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InactivityCheck(pnode);
|
InactivityCheck(pnode);
|
||||||
|
|||||||
@@ -849,8 +849,10 @@ public:
|
|||||||
// socket
|
// socket
|
||||||
std::atomic<ServiceFlags> nServices{NODE_NONE};
|
std::atomic<ServiceFlags> nServices{NODE_NONE};
|
||||||
SOCKET hSocket GUARDED_BY(cs_hSocket);
|
SOCKET hSocket GUARDED_BY(cs_hSocket);
|
||||||
size_t nSendSize{0}; // total size of all vSendMsg entries
|
/** Total size of all vSendMsg entries */
|
||||||
size_t nSendOffset{0}; // offset inside the first vSendMsg already sent
|
size_t nSendSize GUARDED_BY(cs_vSend){0};
|
||||||
|
/** Offset inside the first vSendMsg already sent */
|
||||||
|
size_t nSendOffset GUARDED_BY(cs_vSend){0};
|
||||||
uint64_t nSendBytes GUARDED_BY(cs_vSend){0};
|
uint64_t nSendBytes GUARDED_BY(cs_vSend){0};
|
||||||
std::deque<std::vector<unsigned char>> vSendMsg GUARDED_BY(cs_vSend);
|
std::deque<std::vector<unsigned char>> vSendMsg GUARDED_BY(cs_vSend);
|
||||||
Mutex cs_vSend;
|
Mutex cs_vSend;
|
||||||
@@ -979,7 +981,7 @@ public:
|
|||||||
Network ConnectedThroughNetwork() const;
|
Network ConnectedThroughNetwork() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
mapMsgCmdSize mapSendBytesPerMsgCmd;
|
mapMsgCmdSize mapSendBytesPerMsgCmd GUARDED_BY(cs_vSend);
|
||||||
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv);
|
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user