From 89b8b78980429b5f0eff62ee97637bf56a2dedfb Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 23 Dec 2021 18:55:57 +1100 Subject: [PATCH] Include requests pending cancel in current request count This fix a situation where peers might be dropping our requests, and since we depend on all requests being satisfied before re-requesting, we get stuck waiting for the request to be filled. --- requesting.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requesting.go b/requesting.go index e480ed41..3b7359da 100644 --- a/requesting.go +++ b/requesting.go @@ -227,7 +227,7 @@ func (p *Peer) applyRequestState(next desiredRequestState) bool { requestHeap := &next.Requests t := p.t heap.Init(requestHeap) - for requestHeap.Len() != 0 && maxRequests(current.Requests.GetCardinality()) < p.nominalMaxRequests() { + for requestHeap.Len() != 0 && maxRequests(current.Requests.GetCardinality()+current.Cancelled.GetCardinality()) < p.nominalMaxRequests() { req := heap.Pop(requestHeap).(RequestIndex) existing := t.requestingPeer(req) if existing != nil && existing != p { -- 2.48.1