]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Include requests pending cancel in current request count
authorMatt Joiner <anacrolix@gmail.com>
Thu, 23 Dec 2021 07:55:57 +0000 (18:55 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 23 Dec 2021 07:55:57 +0000 (18:55 +1100)
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

index e480ed41c5d4c65609d7dbf0c547924eb15f70b8..3b7359da6aa7e66679bf163e8c931a736c9b0cac 100644 (file)
@@ -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 {