aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-01-19 20:19:29 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2017-01-19 20:20:04 +0100
commit82274c02ed2d82537dc55f008a29edb1bc09bbc4 (patch)
treefa0f03543fae1b52dab95bbb607e8a3b1e73fae3
parentb25068697fdbfe3bc463b470f1295a44318c4467 (diff)
parent376b3c2c6e329357e4793c1d1b90d1dc0f30fed0 (diff)
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)
-rw-r--r--src/net.cpp25
-rw-r--r--src/net.h2
2 files changed, 12 insertions, 15 deletions
diff --git a/src/net.cpp b/src/net.cpp
index b275bdd809..1019d59544 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1147,12 +1147,10 @@ void CConnman::ThreadSocketHandler()
// * Hand off all complete messages to the processor, to be handled without
// blocking here.
{
- TRY_LOCK(pnode->cs_vSend, lockSend);
- if (lockSend) {
- if (!pnode->vSendMsg.empty()) {
- FD_SET(pnode->hSocket, &fdsetSend);
- continue;
- }
+ LOCK(pnode->cs_vSend);
+ if (!pnode->vSendMsg.empty()) {
+ FD_SET(pnode->hSocket, &fdsetSend);
+ continue;
}
}
{
@@ -1272,12 +1270,10 @@ void CConnman::ThreadSocketHandler()
continue;
if (FD_ISSET(pnode->hSocket, &fdsetSend))
{
- TRY_LOCK(pnode->cs_vSend, lockSend);
- if (lockSend) {
- size_t nBytes = SocketSendData(pnode);
- if (nBytes) {
- RecordBytesSent(nBytes);
- }
+ LOCK(pnode->cs_vSend);
+ size_t nBytes = SocketSendData(pnode);
+ if (nBytes) {
+ RecordBytesSent(nBytes);
}
}
@@ -1875,9 +1871,8 @@ void CConnman::ThreadMessageHandler()
// Send messages
{
- TRY_LOCK(pnode->cs_vSend, lockSend);
- if (lockSend)
- GetNodeSignals().SendMessages(pnode, *this, flagInterruptMsgProc);
+ LOCK(pnode->cs_sendProcessing);
+ GetNodeSignals().SendMessages(pnode, *this, flagInterruptMsgProc);
}
if (flagInterruptMsgProc)
return;
diff --git a/src/net.h b/src/net.h
index a9da38146b..505962f51a 100644
--- a/src/net.h
+++ b/src/net.h
@@ -618,6 +618,8 @@ public:
std::list<CNetMessage> vProcessMsg;
size_t nProcessQueueSize;
+ CCriticalSection cs_sendProcessing;
+
std::deque<CInv> vRecvGetData;
uint64_t nRecvBytes;
std::atomic<int> nRecvVersion;