aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2016-12-31 02:05:17 -0500
committerCory Fields <cory-nospam-@coryfields.com>2017-01-12 23:05:09 -0500
commit60befa3997b98d3f913010f2621bec734f643526 (patch)
tree0fc70214f870118c3363ce5c27dd0ff679664ee7
parent56212e20acf1534d443cb910c9bf3a30f84d0f02 (diff)
net: handle message accounting in ReceiveMsgBytes
This allows locking to be pushed down to only where it's needed Also reuse the current time rather than checking multiple times.
-rw-r--r--src/net.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 6d9971a0f1..776047171f 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -648,6 +648,9 @@ void CNode::copyStats(CNodeStats &stats)
bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete)
{
complete = false;
+ int64_t nTimeMicros = GetTimeMicros();
+ nLastRecv = nTimeMicros / 1000000;
+ nRecvBytes += nBytes;
while (nBytes > 0) {
// get current incomplete message, or create a new one
@@ -685,7 +688,7 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete
assert(i != mapRecvBytesPerMsgCmd.end());
i->second += msg.hdr.nMessageSize + CMessageHeader::HEADER_SIZE;
- msg.nTime = GetTimeMicros();
+ msg.nTime = nTimeMicros;
complete = true;
}
}
@@ -1237,8 +1240,6 @@ void CConnman::ThreadSocketHandler()
pnode->CloseSocketDisconnect();
if(notify)
condMsgProc.notify_one();
- pnode->nLastRecv = GetTime();
- pnode->nRecvBytes += nBytes;
RecordBytesRecv(nBytes);
}
else if (nBytes == 0)