aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/downloader.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-05-16 00:43:42 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-05-16 00:43:42 +0800
commit4f0d88cb023d51bdc5f38cdb54dd11c51765c98b (patch)
tree8ba9c18db3c3713807974c41299d434b3f875eef /eth/downloader/downloader.go
parent7d71a75d7715f97a86e0bd2e5aa9ac149d0ee4b5 (diff)
downloadgo-tangerine-4f0d88cb023d51bdc5f38cdb54dd11c51765c98b.tar
go-tangerine-4f0d88cb023d51bdc5f38cdb54dd11c51765c98b.tar.gz
go-tangerine-4f0d88cb023d51bdc5f38cdb54dd11c51765c98b.tar.bz2
go-tangerine-4f0d88cb023d51bdc5f38cdb54dd11c51765c98b.tar.lz
go-tangerine-4f0d88cb023d51bdc5f38cdb54dd11c51765c98b.tar.xz
go-tangerine-4f0d88cb023d51bdc5f38cdb54dd11c51765c98b.tar.zst
go-tangerine-4f0d88cb023d51bdc5f38cdb54dd11c51765c98b.zip
eth/downloader: fix cancel channel double close
Diffstat (limited to 'eth/downloader/downloader.go')
-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()