mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
parent
3ebf97e721
commit
652c66e9d4
1 changed files with 11 additions and 3 deletions
|
|
@ -313,7 +313,7 @@ func (d *Downloader) UnregisterPeer(id string) error {
|
||||||
d.cancelLock.RUnlock()
|
d.cancelLock.RUnlock()
|
||||||
|
|
||||||
if master {
|
if master {
|
||||||
d.Cancel()
|
d.cancel()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -511,8 +511,10 @@ func (d *Downloader) spawnSync(fetchers []func() error) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cancel cancels all of the operations and resets the queue.
|
// cancel aborts all of the operations and resets the queue. However, cancel does
|
||||||
func (d *Downloader) Cancel() {
|
// not wait for the running download goroutines to finish. This method should be
|
||||||
|
// used when cancelling the downloads from inside the downloader.
|
||||||
|
func (d *Downloader) cancel() {
|
||||||
// Close the current cancel channel
|
// Close the current cancel channel
|
||||||
d.cancelLock.Lock()
|
d.cancelLock.Lock()
|
||||||
if d.cancelCh != nil {
|
if d.cancelCh != nil {
|
||||||
|
|
@ -524,6 +526,12 @@ func (d *Downloader) Cancel() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d.cancelLock.Unlock()
|
d.cancelLock.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel aborts all of the operations and waits for all download goroutines to
|
||||||
|
// finish before returning.
|
||||||
|
func (d *Downloader) Cancel() {
|
||||||
|
d.cancel()
|
||||||
d.cancelWg.Wait()
|
d.cancelWg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue