diff options
author | Patrick Strateman <patrick.strateman@gmail.com> | 2013-10-28 13:20:21 -0700 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2013-11-26 10:15:49 +0100 |
commit | 7084756f4f4e34818659a10f62933fcfc77fe27f (patch) | |
tree | 8e3112cdd38a6fafba4492df09ecf7be5269b136 /src/net.cpp | |
parent | ef14a26b12ad63cbe109e24043b0b1ce5c07447a (diff) | |
download | bitcoin-7084756f4f4e34818659a10f62933fcfc77fe27f.tar.xz |
process received messages one at a time without sleeping between messages
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/net.cpp b/src/net.cpp index 30215d1bc5..e5f85d3290 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1629,6 +1629,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) @@ -1638,8 +1641,18 @@ void ThreadMessageHandler() { TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv) + { if (!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(); @@ -1658,7 +1671,8 @@ void ThreadMessageHandler() pnode->Release(); } - MilliSleep(100); + if (fSleep) + MilliSleep(100); } } |