File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -306,7 +306,7 @@ func (d *Downloader) UnregisterPeer(id string) error {
306
306
d .cancelLock .RUnlock ()
307
307
308
308
if master {
309
- d .Cancel ()
309
+ d .cancel ()
310
310
}
311
311
return nil
312
312
}
@@ -501,8 +501,10 @@ func (d *Downloader) spawnSync(fetchers []func() error) error {
501
501
return err
502
502
}
503
503
504
- // Cancel cancels all of the operations and resets the queue.
505
- func (d * Downloader ) Cancel () {
504
+ // cancel aborts all of the operations and resets the queue. However, cancel does
505
+ // not wait for the running download goroutines to finish. This method should be
506
+ // used when cancelling the downloads from inside the downloader.
507
+ func (d * Downloader ) cancel () {
506
508
// Close the current cancel channel
507
509
d .cancelLock .Lock ()
508
510
if d .cancelCh != nil {
@@ -514,6 +516,12 @@ func (d *Downloader) Cancel() {
514
516
}
515
517
}
516
518
d .cancelLock .Unlock ()
519
+ }
520
+
521
+ // Cancel aborts all of the operations and waits for all download goroutines to
522
+ // finish before returning.
523
+ func (d * Downloader ) Cancel () {
524
+ d .cancel ()
517
525
d .cancelWg .Wait ()
518
526
}
519
527
You can’t perform that action at this time.
0 commit comments