aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-03-10 18:56:32 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-03-10 18:58:46 +0800
commite3f2b541f2bd0433e997d0f8060934b181a5d0e0 (patch)
tree5f32869c1119674b47244471078229f629a5541c /eth
parentedd7aa054c0f9860c799748439255722e51feccc (diff)
downloadgo-tangerine-e3f2b541f2bd0433e997d0f8060934b181a5d0e0.tar
go-tangerine-e3f2b541f2bd0433e997d0f8060934b181a5d0e0.tar.gz
go-tangerine-e3f2b541f2bd0433e997d0f8060934b181a5d0e0.tar.bz2
go-tangerine-e3f2b541f2bd0433e997d0f8060934b181a5d0e0.tar.lz
go-tangerine-e3f2b541f2bd0433e997d0f8060934b181a5d0e0.tar.xz
go-tangerine-e3f2b541f2bd0433e997d0f8060934b181a5d0e0.tar.zst
go-tangerine-e3f2b541f2bd0433e997d0f8060934b181a5d0e0.zip
eth/downloader: fix a throughput estimation data race
Diffstat (limited to 'eth')
-rw-r--r--eth/downloader/peer.go4
1 files 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 {