aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eth/downloader/downloader.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index f9bd5a635..a0a5b20a2 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -212,9 +212,14 @@ func (d *Downloader) Cancel() bool {
return false
}
// Close the current cancel channel
- d.cancelLock.RLock()
- close(d.cancelCh)
- d.cancelLock.RUnlock()
+ d.cancelLock.Lock()
+ select {
+ case <-d.cancelCh:
+ // Channel was already closed
+ default:
+ close(d.cancelCh)
+ }
+ d.cancelLock.Unlock()
// reset the queue
d.queue.Reset()