mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
parent
48f93a8cc5
commit
e34aea99f0
1 changed files with 4 additions and 1 deletions
|
|
@ -574,10 +574,13 @@ func (s *Service) reportLatency(conn *connWrapper) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Wait for the pong request to arrive back
|
// Wait for the pong request to arrive back
|
||||||
|
timer := time.NewTimer(5 * time.Second)
|
||||||
|
defer timer.Stop()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-s.pongCh:
|
case <-s.pongCh:
|
||||||
// Pong delivered, report the latency
|
// Pong delivered, report the latency
|
||||||
case <-time.After(5 * time.Second):
|
case <-timer.C:
|
||||||
// Ping timeout, abort
|
// Ping timeout, abort
|
||||||
return errors.New("ping timed out")
|
return errors.New("ping timed out")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue