Skip to content

Commit f143e39

Browse files
committed
Fix clang warnings on critical section cs_vSend in net.h
1 parent e4b7628 commit f143e39

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/net.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -459,22 +459,22 @@ class CNode
459459
mapAskFor.insert(std::make_pair(nRequestTime, inv));
460460
}
461461

462+
// A lock on cs_vSend must be taken before calling this function
462463
void BeginMessage(const char* pszCommand)
463464
{
464-
ENTER_CRITICAL_SECTION(cs_vSend);
465465
assert(ssSend.size() == 0);
466466
ssSend << CMessageHeader(pszCommand, 0);
467467
}
468468

469+
// A lock on cs_vSend must be taken before calling this function
469470
void AbortMessage()
470471
{
471472
ssSend.clear();
472473

473-
LEAVE_CRITICAL_SECTION(cs_vSend);
474-
475474
LogPrint(BCLog::LogFlags::NOISY, "(aborted)");
476475
}
477476

477+
// A lock on cs_vSend must be taken before calling this function
478478
void EndMessage()
479479
{
480480
if (ssSend.size() == 0)
@@ -500,8 +500,6 @@ class CNode
500500
// If write queue empty, attempt "optimistic write"
501501
if (it == vSendMsg.begin())
502502
SocketSendData(this);
503-
504-
LEAVE_CRITICAL_SECTION(cs_vSend);
505503
}
506504

507505
void PushVersion();
@@ -521,6 +519,8 @@ class CNode
521519

522520
void PushMessage(const char* pszCommand)
523521
{
522+
LOCK(cs_vSend);
523+
524524
try
525525
{
526526
BeginMessage(pszCommand);
@@ -536,6 +536,8 @@ class CNode
536536
template<typename... Args>
537537
void PushMessage(const char* pszCommand, Args... args)
538538
{
539+
LOCK(cs_vSend);
540+
539541
try
540542
{
541543
BeginMessage(pszCommand);

0 commit comments

Comments
 (0)