Fix peer request sleepiness

New requests weren't being issued to the current peer when being deleted. For webseeds, this would cause them to not bother issuing new requests indefinitely.

(cherry picked from commit 146a16df4ea26d33b0ce0391c8220de14c9e18f4)
This commit is contained in:
Matt Joiner 2020-10-29 10:45:38 +11:00
parent 27b89f08c9
commit 7410e28329
1 changed files with 14 additions and 5 deletions

View File

@ -1493,17 +1493,26 @@ func (c *peer) deleteRequest(r request) bool {
if n < 0 {
panic(n)
}
// If a request is rejected, updating the requests for the current peer first will miss the
// opportunity to try other peers for that request instead. I'm not sure about the interested
// check in the following loop however.
if false {
// If a request fails, updating the requests for the current peer first may miss the opportunity
// to try other peers for that request instead, depending on the request strategy. This might
// only affect webseed peers though, since they synchronously issue new requests: PeerConns do
// it in the writer routine.
const updateCurrentConnRequestsFirst = false
if updateCurrentConnRequestsFirst {
c.updateRequests()
}
// Give other conns a chance to pick up the request.
c.t.iterPeers(func(_c *peer) {
if !_c.interested && _c != c && c.peerHasPiece(pieceIndex(r.Index)) {
// We previously checked that the peer wasn't interested to to only wake connections that
// were unable to issue requests due to starvation by the request strategy. There could be
// performance ramifications.
if _c != c && c.peerHasPiece(pieceIndex(r.Index)) {
_c.updateRequests()
}
})
if !updateCurrentConnRequestsFirst {
c.updateRequests()
}
return true
}