p2p/tracker: only reschedule wake if previous didn't run

This commit is contained in:
Péter Szilágyi 2021-04-27 21:47:59 +03:00
parent 55043eec45
commit ff3535e8e0
No known key found for this signature in database
GPG Key ID: E9AE538CEDF8293D

View File

@ -188,8 +188,9 @@ func (t *Tracker) Fulfil(peer string, version uint, code uint64, id uint64) {
t.expire.Remove(req.expire) t.expire.Remove(req.expire)
delete(t.pending, id) delete(t.pending, id)
if req.expire.Prev() == nil { if req.expire.Prev() == nil {
t.wake.Stop() if t.wake.Stop() {
t.schedule() t.schedule()
}
} }
g := fmt.Sprintf("%s/%s/%d/%#02x", trackedGaugeName, t.protocol, req.version, req.reqCode) g := fmt.Sprintf("%s/%s/%d/%#02x", trackedGaugeName, t.protocol, req.version, req.reqCode)
metrics.GetOrRegisterGauge(g, nil).Dec(1) metrics.GetOrRegisterGauge(g, nil).Dec(1)