Fix cancellation for global requesting

This commit is contained in:
Matt Joiner 2021-09-20 15:24:24 +10:00
parent 63f3e8d3de
commit 110b6f3fd3
1 changed files with 5 additions and 6 deletions

View File

@ -4,6 +4,7 @@ import (
"time"
"unsafe"
"github.com/RoaringBitmap/roaring"
"github.com/anacrolix/missinggo/v2/bitmap"
"github.com/anacrolix/chansync"
@ -208,12 +209,10 @@ func (p *Peer) applyNextRequestState() bool {
return false
}
more := true
current.Requests.Iterate(func(req uint32) bool {
if !next.Requests.Contains(req) {
more = p.cancel(req)
return more
}
return true
cancel := roaring.AndNot(&current.Requests, &next.Requests)
cancel.Iterate(func(req uint32) bool {
more = p.cancel(req)
return more
})
if !more {
return false