]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix request heap pop bug
authorMatt Joiner <anacrolix@gmail.com>
Mon, 11 Sep 2023 00:10:13 +0000 (10:10 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 11 Sep 2023 00:10:13 +0000 (10:10 +1000)
Missed in the changed interface from 613470861e67fdb11c9661930f3490cba0aa19b2. Caused very poor performance. Thanks to @AskAlexSharov for raising the flag in https://github.com/anacrolix/torrent/issues/859#issuecomment-1706059960.

requesting.go

index 46796bd29d772f9db793991a2bb4f74373986d3f..8b9db971b537630e65dd41ca9618f8a708f6a698 100644 (file)
@@ -265,7 +265,7 @@ func (p *Peer) applyRequestState(next desiredRequestState) {
                        originalRequestCount, p.needRequestUpdate))
        }
        for requestHeap.Len() != 0 && maxRequests(current.Requests.GetCardinality()+current.Cancelled.GetCardinality()) < p.nominalMaxRequests() {
-               req := requestHeap.Pop()
+               req := heap.Pop(requestHeap)
                existing := t.requestingPeer(req)
                if existing != nil && existing != p {
                        // Don't steal from the poor.