From e3f2b541f2bd0433e997d0f8060934b181a5d0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 10 Mar 2016 12:56:32 +0200 Subject: [PATCH] eth/downloader: fix a throughput estimation data race --- eth/downloader/peer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eth/downloader/peer.go b/eth/downloader/peer.go index 80f08b68f..c4846194b 100644 --- a/eth/downloader/peer.go +++ b/eth/downloader/peer.go @@ -251,8 +251,8 @@ func (p *peer) setIdle(started time.Time, delivered int, throughput *float64, id // Irrelevant of the scaling, make sure the peer ends up idle defer atomic.StoreInt32(idle, 0) - p.lock.RLock() - defer p.lock.RUnlock() + p.lock.Lock() + defer p.lock.Unlock() // If nothing was delivered (hard timeout / unavailable data), reduce throughput to minimum if delivered == 0 {