]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Don't cancel request on current peer when receiving chunk
authorMatt Joiner <anacrolix@gmail.com>
Thu, 28 Jan 2021 03:26:10 +0000 (14:26 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 28 Jan 2021 03:26:10 +0000 (14:26 +1100)
peerconn.go

index ac43e8d5b4517a53510be9fc509b8bd6bcc88bfc..b994f3be7b95263dabb8c5e6b01036fc73764ecb 100644 (file)
@@ -1403,10 +1403,13 @@ func (c *Peer) receiveChunk(msg *pp.Message) error {
        // waiting for it to be written to storage.
        piece.unpendChunkIndex(chunkIndex(req.ChunkSpec, t.chunkSize))
 
-       // Cancel pending requests for this chunk.
-       for c := range t.conns {
-               c.postCancel(req)
-       }
+       // Cancel pending requests for this chunk from *other* peers.
+       t.iterPeers(func(p *Peer) {
+               if p == c {
+                       return
+               }
+               p.postCancel(req)
+       })
 
        err := func() error {
                cl.unlock()