mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
Merge pull request #994 from karalabe/fix-cancel-double-close
eth/downloader: fix cancel channel double close
This commit is contained in:
commit
164ba56a60
1 changed files with 8 additions and 3 deletions
|
|
@ -212,9 +212,14 @@ func (d *Downloader) Cancel() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// Close the current cancel channel
|
// Close the current cancel channel
|
||||||
d.cancelLock.RLock()
|
d.cancelLock.Lock()
|
||||||
close(d.cancelCh)
|
select {
|
||||||
d.cancelLock.RUnlock()
|
case <-d.cancelCh:
|
||||||
|
// Channel was already closed
|
||||||
|
default:
|
||||||
|
close(d.cancelCh)
|
||||||
|
}
|
||||||
|
d.cancelLock.Unlock()
|
||||||
|
|
||||||
// reset the queue
|
// reset the queue
|
||||||
d.queue.Reset()
|
d.queue.Reset()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue