diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-03-11 02:38:55 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-03-11 02:38:55 +0800 |
commit | 850f41b3747d61e0e7e6f0d30eeca12c3a98b08d (patch) | |
tree | 9f75e4aa95a22d3704a174ff3be4be6754779681 | |
parent | 8b58cd01907ff4dffdca4e7fe250b7371a574b61 (diff) | |
parent | e3f2b541f2bd0433e997d0f8060934b181a5d0e0 (diff) | |
download | go-tangerine-850f41b3747d61e0e7e6f0d30eeca12c3a98b08d.tar.gz go-tangerine-850f41b3747d61e0e7e6f0d30eeca12c3a98b08d.tar.zst go-tangerine-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.go | 4 |
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 { |