From 673254515a2f97e53dd8c7335c836b083ba7e31a Mon Sep 17 00:00:00 2001 From: John Newbery Date: Sun, 27 Dec 2020 09:22:04 +0000 Subject: [PATCH] [net] Move RecordBytesSent() call out of cs_vSend lock --- src/net.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 7df0d11d37..3b1c19f60a 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1512,16 +1512,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);