]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Wake connections that could send a request for a deleted piece
authorMatt Joiner <anacrolix@gmail.com>
Tue, 17 Jul 2018 11:29:54 +0000 (21:29 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 17 Jul 2018 11:29:54 +0000 (21:29 +1000)
I'm not sure this is entirely correct, but not doing it is probably less correct. It should help prevent stalls where writers aren't requesting because they're starved out of opportunities by other connections.

connection.go

index 0393497c5cec07d4523fde04c9aa741a9f1a85b6..883d6c8ecb5da60714a7ef4ce41684ffa5913256 100644 (file)
@@ -1483,8 +1483,11 @@ func (c *connection) deleteRequest(r request) bool {
                panic(n)
        }
        c.updateRequests()
-       // TODO: Other connections that aren't interested, and can provide this
-       // chunk might be wakeable?
+       for _c := range c.t.conns {
+               if !_c.Interested && _c != c && c.PeerHasPiece(pieceIndex(r.Index)) {
+                       _c.updateRequests()
+               }
+       }
        return true
 }