aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-03-11 02:38:55 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-03-11 02:38:55 +0800
commit850f41b3747d61e0e7e6f0d30eeca12c3a98b08d (patch)
tree9f75e4aa95a22d3704a174ff3be4be6754779681
parent8b58cd01907ff4dffdca4e7fe250b7371a574b61 (diff)
parente3f2b541f2bd0433e997d0f8060934b181a5d0e0 (diff)
downloaddexon-850f41b3747d61e0e7e6f0d30eeca12c3a98b08d.tar
dexon-850f41b3747d61e0e7e6f0d30eeca12c3a98b08d.tar.gz
dexon-850f41b3747d61e0e7e6f0d30eeca12c3a98b08d.tar.bz2
dexon-850f41b3747d61e0e7e6f0d30eeca12c3a98b08d.tar.lz
dexon-850f41b3747d61e0e7e6f0d30eeca12c3a98b08d.tar.xz
dexon-850f41b3747d61e0e7e6f0d30eeca12c3a98b08d.tar.zst
dexon-850f41b3747d61e0e7e6f0d30eeca12c3a98b08d.zip
Merge pull request #2321 from karalabe/downloader-throughput-datarace
eth/downloader: fix a throughput estimation data race
-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 {