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