Merge pull request #994 from karalabe/fix-cancel-double-close

eth/downloader: fix cancel channel double close
This commit is contained in:
Jeffrey Wilcke 2015-05-15 10:15:35 -07:00
commit 164ba56a60

@ -212,9 +212,14 @@ func (d *Downloader) Cancel() bool {
return false
}
// Close the current cancel channel
d.cancelLock.RLock()
d.cancelLock.Lock()
select {
case <-d.cancelCh:
// Channel was already closed
default:
close(d.cancelCh)
d.cancelLock.RUnlock()
}
d.cancelLock.Unlock()
// reset the queue
d.queue.Reset()