Merge pull request #20988 from karalabe/catchup-shutdown

eth: fix shutdown regression to abort downloads, not just cancel
This commit is contained in:
Péter Szilágyi 2020-04-27 12:02:13 +03:00 committed by GitHub
commit a070e23178
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -557,6 +557,8 @@ func (d *Downloader) spawnSync(fetchers []func() error) error {
func (d *Downloader) cancel() {
// Close the current cancel channel
d.cancelLock.Lock()
defer d.cancelLock.Unlock()
if d.cancelCh != nil {
select {
case <-d.cancelCh:
@ -565,7 +567,6 @@ func (d *Downloader) cancel() {
close(d.cancelCh)
}
}
d.cancelLock.Unlock()
}
// Cancel aborts all of the operations and waits for all download goroutines to

View File

@ -222,7 +222,7 @@ func (cs *chainSyncer) loop() {
case <-cs.pm.quitSync:
if cs.doneCh != nil {
cs.pm.downloader.Cancel()
cs.pm.downloader.Terminate() // Double term is fine, Cancel would block until queue is emptied
<-cs.doneCh
}
return