From 9e63d1fa32872246e9f7afedb7cecbea0ab1a53c Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Mon, 20 Jan 2014 16:46:01 -1000 Subject: [PATCH] CheckMonitor runs forever and runs the first check immediately --- command/agent/check.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/command/agent/check.go b/command/agent/check.go index ba6271dcab..d9fc559e7a 100644 --- a/command/agent/check.go +++ b/command/agent/check.go @@ -55,11 +55,15 @@ func (c *CheckMonitor) Stop() { // run is invoked by a goroutine to run until Stop() is called func (c *CheckMonitor) run() { - select { - case <-time.After(c.Interval): - c.check() - case <-c.stopCh: - return + next := time.After(0) + for { + select { + case <-next: + c.check() + next = time.After(c.Interval) + case <-c.stopCh: + return + } } }