From fddc8437c07a3345d1611ec4e825d3a49574c9b3 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Thu, 26 Jun 2025 13:02:42 +0800 Subject: [PATCH] eth/downloader: fix downloader cancel --- eth/downloader/downloader.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 539aaef40e..d655f547ad 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -630,15 +630,18 @@ func (d *Downloader) cancel() { // Cancel aborts all of the operations and waits for all download goroutines to // finish before returning. func (d *Downloader) Cancel() { - d.blockchain.InterruptInsert(true) d.cancel() d.cancelWg.Wait() - d.blockchain.InterruptInsert(false) } // Terminate interrupts the downloader, canceling all pending operations. // The downloader cannot be reused after calling Terminate. func (d *Downloader) Terminate() { + // Terminates chain insertion, which may result in an "aborted" error in + // the blockchain and ultimately lead to the corresponding peer being + // disconnected. This is acceptable behavior during Geth shutdown. + d.blockchain.InterruptInsert(true) + // Close the termination channel (make sure double close is allowed) d.quitLock.Lock() select {