]> Sergey Matveev's repositories - btrtrc.git/blobdiff - webseed-peer.go
Add Peer.cancelAllRequests for webseedPeer
[btrtrc.git] / webseed-peer.go
index 08a7be2cbc86c86cf7b131ff5240ce016ea6eed4..f2ef7a81b39e0072dfe2733e7e1b0707160dc101 100644 (file)
@@ -129,10 +129,8 @@ func (ws *webseedPeer) handleUpdateRequests() {
 
 func (ws *webseedPeer) onClose() {
        ws.peer.logger.WithLevel(log.Debug).Print("closing")
-       ws.peer.deleteAllRequests()
-       for _, r := range ws.activeRequests {
-               r.Cancel()
-       }
+       // Just deleting them means we would have to manually cancel active requests.
+       ws.peer.cancelAllRequests()
        ws.peer.t.iterPeers(func(p *Peer) {
                if p.isLowOnRequests() {
                        p.updateRequests("webseedPeer.onClose")