diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2013-03-24 16:52:24 +0100 |
---|---|---|
committer | Pieter Wuille <sipa@ulyssis.org> | 2013-03-29 23:56:26 +0100 |
commit | 41b052ad87633d5a8a989c512c8710b875f2ba88 (patch) | |
tree | 0337b36bb1ced74a3f1400d840c191f9c738dd3d /src/main.cpp | |
parent | 967f24590b43f0f84148f669d886b40fe45aa978 (diff) |
Use per-message send buffer, rather than per connection
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp index 0c80f23df9..77061fabd6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3104,7 +3104,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) // Change version pfrom->PushMessage("verack"); - pfrom->vSend.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); + pfrom->ssSend.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); if (!pfrom->fInbound) { @@ -3722,9 +3722,9 @@ bool ProcessMessages(CNode* pfrom) bool fOk = true; std::deque<CNetMessage>::iterator it = pfrom->vRecvMsg.begin(); - while (it != pfrom->vRecvMsg.end()) { + while (!pfrom->fDisconnect && it != pfrom->vRecvMsg.end()) { // Don't bother if send buffer is too full to respond anyway - if (pfrom->vSend.size() >= SendBufferSize()) + if (pfrom->nSendSize >= SendBufferSize()) break; // get next message @@ -3811,7 +3811,10 @@ bool ProcessMessages(CNode* pfrom) printf("ProcessMessage(%s, %u bytes) FAILED\n", strCommand.c_str(), nMessageSize); } - pfrom->vRecvMsg.erase(pfrom->vRecvMsg.begin(), it); + // In case the connection got shut down, its receive buffer was wiped + if (!pfrom->fDisconnect) + pfrom->vRecvMsg.erase(pfrom->vRecvMsg.begin(), it); + return fOk; } @@ -3826,7 +3829,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) // Keep-alive ping. We send a nonce of zero because we don't use it anywhere // right now. - if (pto->nLastSend && GetTime() - pto->nLastSend > 30 * 60 && pto->vSend.empty()) { + if (pto->nLastSend && GetTime() - pto->nLastSend > 30 * 60 && pto->vSendMsg.empty()) { uint64 nonce = 0; if (pto->nVersion > BIP0031_VERSION) pto->PushMessage("ping", nonce); |