Skip to content

Commit a070e23

Browse files
authored
Merge pull request #20988 from karalabe/catchup-shutdown
eth: fix shutdown regression to abort downloads, not just cancel
2 parents 1aa8329 + b0bbd47 commit a070e23

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

eth/downloader/downloader.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,8 @@ func (d *Downloader) spawnSync(fetchers []func() error) error {
557557
func (d *Downloader) cancel() {
558558
// Close the current cancel channel
559559
d.cancelLock.Lock()
560+
defer d.cancelLock.Unlock()
561+
560562
if d.cancelCh != nil {
561563
select {
562564
case <-d.cancelCh:
@@ -565,7 +567,6 @@ func (d *Downloader) cancel() {
565567
close(d.cancelCh)
566568
}
567569
}
568-
d.cancelLock.Unlock()
569570
}
570571

571572
// Cancel aborts all of the operations and waits for all download goroutines to

eth/sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func (cs *chainSyncer) loop() {
222222

223223
case <-cs.pm.quitSync:
224224
if cs.doneCh != nil {
225-
cs.pm.downloader.Cancel()
225+
cs.pm.downloader.Terminate() // Double term is fine, Cancel would block until queue is emptied
226226
<-cs.doneCh
227227
}
228228
return

0 commit comments

Comments
 (0)