Use per-message send buffer, rather than per connection
This commit is contained in:
committed by
Pieter Wuille
parent
967f24590b
commit
41b052ad87
13
src/main.cpp
13
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);
|
||||
|
||||
Reference in New Issue
Block a user