diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-05-13 19:01:08 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-05-13 19:01:08 +0800 |
commit | ec57aa64cda2e525687641971a54df15a04362d6 (patch) | |
tree | 4072c9abe5e0361dcd189e3f16e78099c32a0659 | |
parent | ee0c8923035f44a44cfc9120255b807e90baada9 (diff) | |
download | dexon-ec57aa64cda2e525687641971a54df15a04362d6.tar dexon-ec57aa64cda2e525687641971a54df15a04362d6.tar.gz dexon-ec57aa64cda2e525687641971a54df15a04362d6.tar.bz2 dexon-ec57aa64cda2e525687641971a54df15a04362d6.tar.lz dexon-ec57aa64cda2e525687641971a54df15a04362d6.tar.xz dexon-ec57aa64cda2e525687641971a54df15a04362d6.tar.zst dexon-ec57aa64cda2e525687641971a54df15a04362d6.zip |
eth/downloader: sync the cancel channel during cancel too
-rw-r--r-- | eth/downloader/downloader.go | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 04e9c3a21..0cbf42d30 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -190,32 +190,15 @@ func (d *Downloader) syncWithPeer(p *peer, hash common.Hash) (err error) { // Cancel cancels all of the operations and resets the queue. It returns true // if the cancel operation was completed. func (d *Downloader) Cancel() bool { - hs, bs := d.queue.Size() // If we're not syncing just return. + hs, bs := d.queue.Size() if atomic.LoadInt32(&d.synchronising) == 0 && hs == 0 && bs == 0 { return false } - + // Close the current cancel channel + d.cancelLock.RLock() close(d.cancelCh) - - // clean up -hashDone: - for { - select { - case <-d.hashCh: - default: - break hashDone - } - } - -blockDone: - for { - select { - case <-d.blockCh: - default: - break blockDone - } - } + d.cancelLock.RUnlock() // reset the queue d.queue.Reset() |