diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-05-16 00:43:42 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-05-16 00:43:42 +0800 |
commit | 4f0d88cb023d51bdc5f38cdb54dd11c51765c98b (patch) | |
tree | 8ba9c18db3c3713807974c41299d434b3f875eef /eth/downloader | |
parent | 7d71a75d7715f97a86e0bd2e5aa9ac149d0ee4b5 (diff) | |
download | dexon-4f0d88cb023d51bdc5f38cdb54dd11c51765c98b.tar dexon-4f0d88cb023d51bdc5f38cdb54dd11c51765c98b.tar.gz dexon-4f0d88cb023d51bdc5f38cdb54dd11c51765c98b.tar.bz2 dexon-4f0d88cb023d51bdc5f38cdb54dd11c51765c98b.tar.lz dexon-4f0d88cb023d51bdc5f38cdb54dd11c51765c98b.tar.xz dexon-4f0d88cb023d51bdc5f38cdb54dd11c51765c98b.tar.zst dexon-4f0d88cb023d51bdc5f38cdb54dd11c51765c98b.zip |
eth/downloader: fix cancel channel double close
Diffstat (limited to 'eth/downloader')
-rw-r--r-- | eth/downloader/downloader.go | 11 |
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() |