Merge pull request #4472

9f4da19 Use pong receive time rather than processing time (Pieter Wuille)
pull/4476/head
Wladimir J. van der Laan 11 years ago
commit e1f7c7d173
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6

@ -3535,7 +3535,7 @@ void static ProcessGetData(CNode* pfrom)
} }
} }
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived)
{ {
RandAddSeedPerfmon(); RandAddSeedPerfmon();
LogPrint("net", "received: %s (%u bytes) peer=%d\n", strCommand, vRecv.size(), pfrom->id); LogPrint("net", "received: %s (%u bytes) peer=%d\n", strCommand, vRecv.size(), pfrom->id);
@ -4045,7 +4045,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
else if (strCommand == "pong") else if (strCommand == "pong")
{ {
int64_t pingUsecEnd = GetTimeMicros(); int64_t pingUsecEnd = nTimeReceived;
uint64_t nonce = 0; uint64_t nonce = 0;
size_t nAvail = vRecv.in_avail(); size_t nAvail = vRecv.in_avail();
bool bPingFinished = false; bool bPingFinished = false;
@ -4296,7 +4296,7 @@ bool ProcessMessages(CNode* pfrom)
bool fRet = false; bool fRet = false;
try try
{ {
fRet = ProcessMessage(pfrom, strCommand, vRecv); fRet = ProcessMessage(pfrom, strCommand, vRecv, msg.nTime);
boost::this_thread::interruption_point(); boost::this_thread::interruption_point();
} }
catch (std::ios_base::failure& e) catch (std::ios_base::failure& e)

@ -655,6 +655,9 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes)
pch += handled; pch += handled;
nBytes -= handled; nBytes -= handled;
if (msg.complete())
msg.nTime = GetTimeMicros();
} }
return true; return true;

@ -173,11 +173,14 @@ public:
CDataStream vRecv; // received message data CDataStream vRecv; // received message data
unsigned int nDataPos; unsigned int nDataPos;
int64_t nTime; // time (in microseconds) of message receipt.
CNetMessage(int nTypeIn, int nVersionIn) : hdrbuf(nTypeIn, nVersionIn), vRecv(nTypeIn, nVersionIn) { CNetMessage(int nTypeIn, int nVersionIn) : hdrbuf(nTypeIn, nVersionIn), vRecv(nTypeIn, nVersionIn) {
hdrbuf.resize(24); hdrbuf.resize(24);
in_data = false; in_data = false;
nHdrPos = 0; nHdrPos = 0;
nDataPos = 0; nDataPos = 0;
nTime = 0;
} }
bool complete() const bool complete() const

Loading…
Cancel
Save