Skip to content

Commit 82274c0

Browse files
committed
Merge #9535: Split CNode::cs_vSend: message processing and message sending
376b3c2 Make the cs_sendProcessing a LOCK instead of a TRY_LOCK (Matt Corallo) d7c58ad Split CNode::cs_vSend: message processing and message sending (Matt Corallo)
2 parents b250686 + 376b3c2 commit 82274c0

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/net.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,12 +1147,10 @@ void CConnman::ThreadSocketHandler()
11471147
// * Hand off all complete messages to the processor, to be handled without
11481148
// blocking here.
11491149
{
1150-
TRY_LOCK(pnode->cs_vSend, lockSend);
1151-
if (lockSend) {
1152-
if (!pnode->vSendMsg.empty()) {
1153-
FD_SET(pnode->hSocket, &fdsetSend);
1154-
continue;
1155-
}
1150+
LOCK(pnode->cs_vSend);
1151+
if (!pnode->vSendMsg.empty()) {
1152+
FD_SET(pnode->hSocket, &fdsetSend);
1153+
continue;
11561154
}
11571155
}
11581156
{
@@ -1272,12 +1270,10 @@ void CConnman::ThreadSocketHandler()
12721270
continue;
12731271
if (FD_ISSET(pnode->hSocket, &fdsetSend))
12741272
{
1275-
TRY_LOCK(pnode->cs_vSend, lockSend);
1276-
if (lockSend) {
1277-
size_t nBytes = SocketSendData(pnode);
1278-
if (nBytes) {
1279-
RecordBytesSent(nBytes);
1280-
}
1273+
LOCK(pnode->cs_vSend);
1274+
size_t nBytes = SocketSendData(pnode);
1275+
if (nBytes) {
1276+
RecordBytesSent(nBytes);
12811277
}
12821278
}
12831279

@@ -1875,9 +1871,8 @@ void CConnman::ThreadMessageHandler()
18751871

18761872
// Send messages
18771873
{
1878-
TRY_LOCK(pnode->cs_vSend, lockSend);
1879-
if (lockSend)
1880-
GetNodeSignals().SendMessages(pnode, *this, flagInterruptMsgProc);
1874+
LOCK(pnode->cs_sendProcessing);
1875+
GetNodeSignals().SendMessages(pnode, *this, flagInterruptMsgProc);
18811876
}
18821877
if (flagInterruptMsgProc)
18831878
return;

src/net.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,8 @@ class CNode
618618
std::list<CNetMessage> vProcessMsg;
619619
size_t nProcessQueueSize;
620620

621+
CCriticalSection cs_sendProcessing;
622+
621623
std::deque<CInv> vRecvGetData;
622624
uint64_t nRecvBytes;
623625
std::atomic<int> nRecvVersion;

0 commit comments

Comments
 (0)