aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-05-16 01:15:35 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-05-16 01:15:35 +0800
commit164ba56a60411161f67aad4eda5301b89a27b1a4 (patch)
tree8ba9c18db3c3713807974c41299d434b3f875eef
parent7d71a75d7715f97a86e0bd2e5aa9ac149d0ee4b5 (diff)
parent4f0d88cb023d51bdc5f38cdb54dd11c51765c98b (diff)
downloadgo-tangerine-164ba56a60411161f67aad4eda5301b89a27b1a4.tar.gz
go-tangerine-164ba56a60411161f67aad4eda5301b89a27b1a4.tar.zst
go-tangerine-164ba56a60411161f67aad4eda5301b89a27b1a4.zip
Merge pull request #994 from karalabe/fix-cancel-double-close
eth/downloader: fix cancel channel double close
-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()