From 3564f8f3dbe9e3cad4cf074911805d4d502ab500 Mon Sep 17 00:00:00 2001
From: "Richard T. Carback III" <rick.carback@gmail.com>
Date: Fri, 24 Sep 2021 03:13:27 +0000
Subject: [PATCH] Simplify the timeout handling

---
 network/health/tracker.go | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/network/health/tracker.go b/network/health/tracker.go
index 7d5b6a7d9..69fdb0b13 100644
--- a/network/health/tracker.go
+++ b/network/health/tracker.go
@@ -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...")
 			}
-- 
GitLab