mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2025-01-09 20:21:20 +00:00
p2p/discover: improve timer handling for reply timeouts
This commit is contained in:
parent
b8aeb04f6f
commit
0217652d1b
@ -267,11 +267,12 @@ func (t *udp) loop() {
|
|||||||
defer timeout.Stop()
|
defer timeout.Stop()
|
||||||
|
|
||||||
rearmTimeout := func() {
|
rearmTimeout := func() {
|
||||||
if len(pending) == 0 || nextDeadline == pending[0].deadline {
|
now := time.Now()
|
||||||
|
if len(pending) == 0 || now.Before(nextDeadline) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
nextDeadline = pending[0].deadline
|
nextDeadline = pending[0].deadline
|
||||||
timeout.Reset(nextDeadline.Sub(time.Now()))
|
timeout.Reset(nextDeadline.Sub(now))
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
Loading…
Reference in New Issue
Block a user