p2p/tracker: fix head detection in Fulfil to avoid unnecessary timer reschedules

This commit is contained in:
kurahin 2025-12-08 12:21:15 +02:00 committed by GitHub
parent e63e37be5e
commit 9f62d3b188
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -185,9 +185,10 @@ func (t *Tracker) Fulfil(peer string, version uint, code uint64, id uint64) {
return
}
// Everything matches, mark the request serviced and meter it
wasHead := t.expire.Front() == req.expire
t.expire.Remove(req.expire)
delete(t.pending, id)
if req.expire.Prev() == nil {
if wasHead {
if t.wake.Stop() {
t.schedule()
}