@@ -459,22 +459,22 @@ class CNode
459
459
mapAskFor.insert (std::make_pair (nRequestTime, inv));
460
460
}
461
461
462
+ // A lock on cs_vSend must be taken before calling this function
462
463
void BeginMessage (const char * pszCommand)
463
464
{
464
- ENTER_CRITICAL_SECTION (cs_vSend);
465
465
assert (ssSend.size () == 0 );
466
466
ssSend << CMessageHeader (pszCommand, 0 );
467
467
}
468
468
469
+ // A lock on cs_vSend must be taken before calling this function
469
470
void AbortMessage ()
470
471
{
471
472
ssSend.clear ();
472
473
473
- LEAVE_CRITICAL_SECTION (cs_vSend);
474
-
475
474
LogPrint (BCLog::LogFlags::NOISY, " (aborted)" );
476
475
}
477
476
477
+ // A lock on cs_vSend must be taken before calling this function
478
478
void EndMessage ()
479
479
{
480
480
if (ssSend.size () == 0 )
@@ -500,8 +500,6 @@ class CNode
500
500
// If write queue empty, attempt "optimistic write"
501
501
if (it == vSendMsg.begin ())
502
502
SocketSendData (this );
503
-
504
- LEAVE_CRITICAL_SECTION (cs_vSend);
505
503
}
506
504
507
505
void PushVersion ();
@@ -521,6 +519,8 @@ class CNode
521
519
522
520
void PushMessage (const char * pszCommand)
523
521
{
522
+ LOCK (cs_vSend);
523
+
524
524
try
525
525
{
526
526
BeginMessage (pszCommand);
@@ -536,6 +536,8 @@ class CNode
536
536
template <typename ... Args>
537
537
void PushMessage (const char * pszCommand, Args... args)
538
538
{
539
+ LOCK (cs_vSend);
540
+
539
541
try
540
542
{
541
543
BeginMessage (pszCommand);
0 commit comments