aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/net.cpp14
-rw-r--r--src/net.h8
2 files changed, 9 insertions, 13 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);
diff --git a/src/net.h b/src/net.h
index 10a550735e..cbc2a3dc38 100644
--- a/src/net.h
+++ b/src/net.h
@@ -849,8 +849,10 @@ public:
// socket
std::atomic<ServiceFlags> nServices{NODE_NONE};
SOCKET hSocket GUARDED_BY(cs_hSocket);
- size_t nSendSize{0}; // total size of all vSendMsg entries
- size_t nSendOffset{0}; // offset inside the first vSendMsg already sent
+ /** Total size of all vSendMsg entries */
+ 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};
std::deque<std::vector<unsigned char>> vSendMsg GUARDED_BY(cs_vSend);
Mutex cs_vSend;
@@ -979,7 +981,7 @@ public:
Network ConnectedThroughNetwork() const;
protected:
- mapMsgCmdSize mapSendBytesPerMsgCmd;
+ mapMsgCmdSize mapSendBytesPerMsgCmd GUARDED_BY(cs_vSend);
mapMsgCmdSize mapRecvBytesPerMsgCmd GUARDED_BY(cs_vRecv);
public: