Skip to content
Snippets Groups Projects
Commit 3564f8f3 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Simplify the timeout handling

parent 38842402
No related branches found
No related tags found
1 merge request!53Release
......@@ -162,8 +162,6 @@ func (t *Tracker) Start() (stoppable.Stoppable, error) {
// start starts a long-running thread used to monitor and report on network
// health.
func (t *Tracker) start(stop *stoppable.Single) {
timer := time.NewTimer(t.timeout)
for {
var heartbeat network.Heartbeat
select {
......@@ -179,18 +177,9 @@ func (t *Tracker) start(stop *stoppable.Single) {
return
case heartbeat = <-t.heartbeat:
if healthy(heartbeat) {
// Stop and reset timer
if !timer.Stop() {
select {
// per docs explicitly drain
case <-timer.C:
default:
}
}
timer.Reset(t.timeout)
t.setHealth(true)
}
case <-timer.C:
case <-time.After(t.timeout):
if !t.isHealthy {
jww.WARN.Printf("Network health tracker timed out, network is no longer healthy...")
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment