Fix request heap pop bug

Missed in the changed interface from 613470861e. Caused very poor performance. Thanks to @AskAlexSharov for raising the flag in https://github.com/anacrolix/torrent/issues/859#issuecomment-1706059960.
This commit is contained in:
Matt Joiner 2023-09-11 10:10:13 +10:00
parent 72c1152b39
commit 87f6cdc1e9
No known key found for this signature in database
GPG Key ID: 6B990B8185E7F782
1 changed files with 1 additions and 1 deletions

View 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.