mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-17 12:21:38 +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
|
nextTimeout = nil
|
||||||
|
|
||||||
// Notify and remove callbacks whose deadline is in the past.
|
// 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)
|
p := el.Value.(*replyMatcher)
|
||||||
if now.After(p.deadline) || now.Equal(p.deadline) {
|
if now.After(p.deadline) || now.Equal(p.deadline) {
|
||||||
p.errc <- errTimeout
|
p.errc <- errTimeout
|
||||||
plist.Remove(el)
|
plist.Remove(el)
|
||||||
contTimeouts++
|
contTimeouts++
|
||||||
}
|
}
|
||||||
|
el = next
|
||||||
}
|
}
|
||||||
// If we've accumulated too many timeouts, do an NTP time sync check
|
// If we've accumulated too many timeouts, do an NTP time sync check
|
||||||
if contTimeouts > ntpFailureThreshold {
|
if contTimeouts > ntpFailureThreshold {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue