aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/net.cpp b/src/net.cpp
index de8543da59..8c0ada8f92 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1540,6 +1540,9 @@ void ThreadMessageHandler()
CNode* pnodeTrickle = NULL;
if (!vNodesCopy.empty())
pnodeTrickle = vNodesCopy[GetRand(vNodesCopy.size())];
+
+ bool fSleep = true;
+
BOOST_FOREACH(CNode* pnode, vNodesCopy)
{
if (pnode->fDisconnect)
@@ -1549,8 +1552,18 @@ void ThreadMessageHandler()
{
TRY_LOCK(pnode->cs_vRecvMsg, lockRecv);
if (lockRecv)
+ {
if (!g_signals.ProcessMessages(pnode))
pnode->CloseSocketDisconnect();
+
+ if (pnode->nSendSize < SendBufferSize())
+ {
+ if (!pnode->vRecvGetData.empty() || (!pnode->vRecvMsg.empty() && pnode->vRecvMsg[0].complete()))
+ {
+ fSleep = false;
+ }
+ }
+ }
}
boost::this_thread::interruption_point();
@@ -1568,8 +1581,9 @@ void ThreadMessageHandler()
BOOST_FOREACH(CNode* pnode, vNodesCopy)
pnode->Release();
}
-
- MilliSleep(100);
+
+ if (fSleep)
+ MilliSleep(100);
}
}