aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2016-04-18 21:33:54 -0400
committerCory Fields <cory-nospam-@coryfields.com>2016-09-08 12:24:06 -0400
commitee44fa95761724a83a76dd862a36bd9af0fc021f (patch)
treeea026cedd0635c5d424041536c83f84a3b12ec8a /src/net.cpp
parent960cf2e4058a9c195bf64e1aecb46024f9ef022a (diff)
net: move messageHandlerCondition to CConnman
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 71b4b01688..a62ee2291c 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -89,7 +89,6 @@ std::string strSubVersion;
limitedmap<uint256, int64_t> mapAlreadyAskedFor(MAX_INV_SZ);
static CSemaphore *semOutbound = NULL;
-boost::condition_variable messageHandlerCondition;
// Signals for message handling
static CNodeSignals g_signals;
@@ -688,8 +687,9 @@ void CNode::copyStats(CNodeStats &stats)
#undef X
// requires LOCK(cs_vRecvMsg)
-bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes)
+bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete)
{
+ complete = false;
while (nBytes > 0) {
// get current incomplete message, or create a new one
@@ -728,7 +728,7 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes)
i->second += msg.hdr.nMessageSize + CMessageHeader::HEADER_SIZE;
msg.nTime = GetTimeMicros();
- messageHandlerCondition.notify_one();
+ complete = true;
}
}
@@ -1247,8 +1247,11 @@ void CConnman::ThreadSocketHandler()
int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT);
if (nBytes > 0)
{
- if (!pnode->ReceiveMsgBytes(pchBuf, nBytes))
+ bool notify = false;
+ if (!pnode->ReceiveMsgBytes(pchBuf, nBytes, notify))
pnode->CloseSocketDisconnect();
+ if(notify)
+ messageHandlerCondition.notify_one();
pnode->nLastRecv = GetTime();
pnode->nRecvBytes += nBytes;
pnode->RecordBytesRecv(nBytes);