From b0bbd4718511a8b2575e5feb8cbd54beb9675973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 27 Apr 2020 11:22:15 +0300 Subject: [PATCH] eth: fix shutdown regression to abort downloads, not just cancel --- eth/downloader/downloader.go | 3 ++- eth/sync.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index f8982f696..e2598e9bf 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -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 diff --git a/eth/sync.go b/eth/sync.go index d689200dc..6802fab0d 100644 --- a/eth/sync.go +++ b/eth/sync.go @@ -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