Преглед на файлове

eth/downloader: fix a throughput estimation data race

Péter Szilágyi преди 9 години
родител
ревизия
e3f2b541f2
променени са 1 файла, в които са добавени 2 реда и са изтрити 2 реда
  1. 2 2
      eth/downloader/peer.go

+ 2 - 2
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 {