From 00a3f0eb600116dbe79b18d5f2a51296012e0944 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Thu, 6 Sep 2018 13:00:31 -0400 Subject: [PATCH] peer: Protect handlePongMsg with p.statsMtx --- peer/peer.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/peer/peer.go b/peer/peer.go index a174c5e9..4a57bc5f 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -947,11 +947,13 @@ func (p *Peer) handlePongMsg(msg *wire.MsgPong) { // and overlapping pings will be ignored. It is unlikely to occur // without large usage of the ping rpc call since we ping infrequently // enough that if they overlap we would have timed out the peer. + p.statsMtx.Lock() if p.lastPingNonce != 0 && msg.Nonce == p.lastPingNonce { p.lastPingMicros = time.Since(p.lastPingTime).Nanoseconds() p.lastPingMicros /= 1000 // convert to usec. p.lastPingNonce = 0 } + p.statsMtx.Unlock() } // readMessage reads the next wire message from the peer with logging.