mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 01:41:36 +00:00
p2p/discover: fix timeout loop early exit when removing expired matchers
Save `el.Next()` before calling `plist.Remove(el)` so iteration continues correctly. Previously the loop exited after removing the first expired matcher because `Remove` invalidates the element's links.
This commit is contained in:
parent
fc43170cdd
commit
a37824d1f8
1 changed files with 3 additions and 1 deletions
|
|
@ -499,13 +499,15 @@ func (t *UDPv4) loop() {
|
|||
nextTimeout = nil
|
||||
|
||||
// Notify and remove callbacks whose deadline is in the past.
|
||||
for el := plist.Front(); el != nil; el = el.Next() {
|
||||
for el := plist.Front(); el != nil; {
|
||||
next := el.Next()
|
||||
p := el.Value.(*replyMatcher)
|
||||
if now.After(p.deadline) || now.Equal(p.deadline) {
|
||||
p.errc <- errTimeout
|
||||
plist.Remove(el)
|
||||
contTimeouts++
|
||||
}
|
||||
el = next
|
||||
}
|
||||
// If we've accumulated too many timeouts, do an NTP time sync check
|
||||
if contTimeouts > ntpFailureThreshold {
|
||||
|
|
|
|||
Loading…
Reference in a new issue