diff --git a/common/signal/timer.go b/common/signal/timer.go index 7b92e610..44ac8a5c 100644 --- a/common/signal/timer.go +++ b/common/signal/timer.go @@ -24,12 +24,16 @@ func (t *realActivityTimer) Update() { } func (t *realActivityTimer) run() { + ticker := time.NewTicker(t.timeout) + defer ticker.Stop() + for { select { - case <-time.After(t.timeout): + case <-ticker.C: case <-t.ctx.Done(): return } + select { case <-t.updated: // Updated keep waiting. @@ -37,7 +41,6 @@ func (t *realActivityTimer) run() { t.cancel() return } - } }