aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-01-06 07:07:32 +0100
committerMarcoFalke <falke.marco@gmail.com>2021-01-06 07:07:35 +0100
commit4eada5d8b16e49b49a300f7935f0d92506f5b356 (patch)
treee2dec71d821f7c75f9ecdd91aad3af3ff12f273f /src/net.cpp
parent417f95fa453d97087a33d4176523ab278bef21a1 (diff)
parent378aedc45248cea82d9a3e6dc1038d6828008a76 (diff)
Merge #20816: net: Move RecordBytesSent() call out of cs_vSend lock
378aedc45248cea82d9a3e6dc1038d6828008a76 [net] Add cs_vSend lock annotations (John Newbery) 673254515a2f97e53dd8c7335c836b083ba7e31a [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 commit 378aedc which has two ACKs already. Any style issues can be fixed up in future PRs. troygiorshev: ACK 378aedc45248cea82d9a3e6dc1038d6828008a76 theStack: re-ACK 378aedc45248cea82d9a3e6dc1038d6828008a76 MarcoFalke: review ACK 378aedc45248cea82d9a3e6dc1038d6828008a76 🔌 Tree-SHA512: e9cd6c472b7e1479120c1bf2d1c640cf6d18c7d589a5f9b7dfc4875e5790adaab403a7a1b945a47e79e7249a614b8583270e4549f89b22e8a9edb2e4818b0d07
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 3938a233f0..ebd918d63e 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1506,16 +1506,10 @@ void CConnman::SocketHandler()
}
}
- //
- // Send
- //
- if (sendSet)
- {
- LOCK(pnode->cs_vSend);
- size_t nBytes = SocketSendData(pnode);
- if (nBytes) {
- RecordBytesSent(nBytes);
- }
+ if (sendSet) {
+ // Send data
+ size_t bytes_sent = WITH_LOCK(pnode->cs_vSend, return SocketSendData(pnode));
+ if (bytes_sent) RecordBytesSent(bytes_sent);
}
InactivityCheck(pnode);