Skip to content

Commit

Permalink
Fix clang warnings on critical section cs_vSend in net.h
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescowens committed May 16, 2021
1 parent 4131312 commit 924401f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
Expand All @@ -521,6 +519,8 @@ class CNode

void PushMessage(const char* pszCommand)
{
LOCK(cs_vSend);

try
{
BeginMessage(pszCommand);
Expand All @@ -536,6 +536,8 @@ class CNode
template<typename... Args>
void PushMessage(const char* pszCommand, Args... args)
{
LOCK(cs_vSend);

try
{
BeginMessage(pszCommand);
Expand Down

0 comments on commit 924401f

Please sign in to comment.