Some fixes to CNetMessage processing

* Change CNode::vRecvMsg to be a deque instead of a vector (less copying)
* Make sure to acquire cs_vRecvMsg in CNode::CloseSocketDisconnect (as it
  may be called without that lock).
This commit is contained in:
Pieter Wuille
2013-03-01 01:41:28 +01:00
committed by Pieter Wuille
parent b9ff2970b9
commit 967f24590b
3 changed files with 28 additions and 21 deletions

View File

@@ -176,7 +176,7 @@ public:
CDataStream vSend;
CCriticalSection cs_vSend;
std::vector<CNetMessage> vRecvMsg;
std::deque<CNetMessage> vRecvMsg;
CCriticalSection cs_vRecvMsg;
int nRecvVersion;
@@ -297,8 +297,8 @@ public:
unsigned int GetTotalRecvSize()
{
unsigned int total = 0;
for (unsigned int i = 0; i < vRecvMsg.size(); i++)
total += vRecvMsg[i].vRecv.size();
BOOST_FOREACH(const CNetMessage &msg, vRecvMsg)
total += msg.vRecv.size() + 24;
return total;
}
@@ -309,8 +309,8 @@ public:
void SetRecvVersion(int nVersionIn)
{
nRecvVersion = nVersionIn;
for (unsigned int i = 0; i < vRecvMsg.size(); i++)
vRecvMsg[i].SetVersion(nVersionIn);
BOOST_FOREACH(CNetMessage &msg, vRecvMsg)
msg.SetVersion(nVersionIn);
}
CNode* AddRef(int64 nTimeout=0)