From 924401fbc141802bfb36da5f867ffe5119d5e0bb Mon Sep 17 00:00:00 2001 From: "James C. Owens" Date: Sun, 16 May 2021 00:23:14 -0400 Subject: [PATCH] Fix clang warnings on critical section cs_vSend in net.h --- src/net.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/net.h b/src/net.h index 38805107e6..c92b516b32 100644 --- a/src/net.h +++ b/src/net.h @@ -459,22 +459,22 @@ class CNode mapAskFor.insert(std::make_pair(nRequestTime, inv)); } + // A lock on cs_vSend must be taken before calling this function void BeginMessage(const char* pszCommand) { - ENTER_CRITICAL_SECTION(cs_vSend); assert(ssSend.size() == 0); ssSend << CMessageHeader(pszCommand, 0); } + // A lock on cs_vSend must be taken before calling this function void AbortMessage() { ssSend.clear(); - LEAVE_CRITICAL_SECTION(cs_vSend); - LogPrint(BCLog::LogFlags::NOISY, "(aborted)"); } + // A lock on cs_vSend must be taken before calling this function void EndMessage() { if (ssSend.size() == 0) @@ -500,8 +500,6 @@ class CNode // If write queue empty, attempt "optimistic write" if (it == vSendMsg.begin()) SocketSendData(this); - - LEAVE_CRITICAL_SECTION(cs_vSend); } void PushVersion(); @@ -521,6 +519,8 @@ class CNode void PushMessage(const char* pszCommand) { + LOCK(cs_vSend); + try { BeginMessage(pszCommand); @@ -536,6 +536,8 @@ class CNode template void PushMessage(const char* pszCommand, Args... args) { + LOCK(cs_vSend); + try { BeginMessage(pszCommand);