Unverified Commit 905ed109 authored by gary rong's avatar gary rong Committed by GitHub

eth/downloader: fix data race around the ancientlimit (#21681)

* eth/downloader: fix data race around the ancientlimit

* eth/downloader: initialize the ancientlimit as 0
parent 43cd31ea
...@@ -515,6 +515,8 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I ...@@ -515,6 +515,8 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I
d.ancientLimit = d.checkpoint d.ancientLimit = d.checkpoint
} else if height > fullMaxForkAncestry+1 { } else if height > fullMaxForkAncestry+1 {
d.ancientLimit = height - fullMaxForkAncestry - 1 d.ancientLimit = height - fullMaxForkAncestry - 1
} else {
d.ancientLimit = 0
} }
frozen, _ := d.stateDB.Ancients() // Ignore the error here since light client can also hit here. frozen, _ := d.stateDB.Ancients() // Ignore the error here since light client can also hit here.
...@@ -606,9 +608,6 @@ func (d *Downloader) cancel() { ...@@ -606,9 +608,6 @@ func (d *Downloader) cancel() {
func (d *Downloader) Cancel() { func (d *Downloader) Cancel() {
d.cancel() d.cancel()
d.cancelWg.Wait() d.cancelWg.Wait()
d.ancientLimit = 0
log.Debug("Reset ancient limit to zero")
} }
// Terminate interrupts the downloader, canceling all pending operations. // Terminate interrupts the downloader, canceling all pending operations.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment