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)
This commit is contained in:
parent
a84f8da136
commit
f8b880f4d8
11
src/net.cpp
11
src/net.cpp
@ -1190,14 +1190,12 @@ void CConnman::ThreadSocketHandler()
|
|||||||
// * Hand off all complete messages to the processor, to be handled without
|
// * Hand off all complete messages to the processor, to be handled without
|
||||||
// blocking here.
|
// blocking here.
|
||||||
{
|
{
|
||||||
TRY_LOCK(pnode->cs_vSend, lockSend);
|
LOCK(pnode->cs_vSend);
|
||||||
if (lockSend) {
|
|
||||||
if (!pnode->vSendMsg.empty()) {
|
if (!pnode->vSendMsg.empty()) {
|
||||||
FD_SET(pnode->hSocket, &fdsetSend);
|
FD_SET(pnode->hSocket, &fdsetSend);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
{
|
{
|
||||||
if (!pnode->fPauseRecv)
|
if (!pnode->fPauseRecv)
|
||||||
FD_SET(pnode->hSocket, &fdsetRecv);
|
FD_SET(pnode->hSocket, &fdsetRecv);
|
||||||
@ -1309,14 +1307,12 @@ void CConnman::ThreadSocketHandler()
|
|||||||
continue;
|
continue;
|
||||||
if (FD_ISSET(pnode->hSocket, &fdsetSend))
|
if (FD_ISSET(pnode->hSocket, &fdsetSend))
|
||||||
{
|
{
|
||||||
TRY_LOCK(pnode->cs_vSend, lockSend);
|
LOCK(pnode->cs_vSend);
|
||||||
if (lockSend) {
|
|
||||||
size_t nBytes = SocketSendData(pnode);
|
size_t nBytes = SocketSendData(pnode);
|
||||||
if (nBytes) {
|
if (nBytes) {
|
||||||
RecordBytesSent(nBytes);
|
RecordBytesSent(nBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Inactivity checking
|
// Inactivity checking
|
||||||
@ -1948,8 +1944,7 @@ void CConnman::ThreadMessageHandler()
|
|||||||
|
|
||||||
// Send messages
|
// Send messages
|
||||||
{
|
{
|
||||||
TRY_LOCK(pnode->cs_vSend, lockSend);
|
LOCK(pnode->cs_sendProcessing);
|
||||||
if (lockSend)
|
|
||||||
GetNodeSignals().SendMessages(pnode, *this, flagInterruptMsgProc);
|
GetNodeSignals().SendMessages(pnode, *this, flagInterruptMsgProc);
|
||||||
}
|
}
|
||||||
if (flagInterruptMsgProc)
|
if (flagInterruptMsgProc)
|
||||||
|
@ -687,6 +687,8 @@ public:
|
|||||||
std::list<CNetMessage> vProcessMsg;
|
std::list<CNetMessage> vProcessMsg;
|
||||||
size_t nProcessQueueSize;
|
size_t nProcessQueueSize;
|
||||||
|
|
||||||
|
CCriticalSection cs_sendProcessing;
|
||||||
|
|
||||||
std::deque<CInv> vRecvGetData;
|
std::deque<CInv> vRecvGetData;
|
||||||
uint64_t nRecvBytes;
|
uint64_t nRecvBytes;
|
||||||
std::atomic<int> nRecvVersion;
|
std::atomic<int> nRecvVersion;
|
||||||
|
Loading…
Reference in New Issue
Block a user