}
}
+func (c *Peer) cancelAllRequests() (cancelled *roaring.Bitmap) {
+ cancelled = c.requestState.Requests.Clone()
+ cancelled.Iterate(func(x uint32) bool {
+ c.cancel(x)
+ return true
+ })
+ c.assertNoRequests()
+ return
+}
+
// This is called when something has changed that should wake the writer, such as putting stuff into
// the writeBuffer, or changing some state that the writer can act on.
func (c *PeerConn) tickleWriter() {
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")