Skip to content

Commit

Permalink
eth: fix shutdown regression to abort downloads, not just cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
karalabe committed Apr 27, 2020
1 parent 1aa8329 commit b0bbd47
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion eth/downloader/downloader.go
Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion eth/sync.go
Expand Up @@ -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
Expand Down

0 comments on commit b0bbd47

Please sign in to comment.