From 5cb65082b8e3422bec2dc5f7d9cb37dc5268e4e4 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Fri, 10 Apr 2015 03:12:29 -0700 Subject: [PATCH] a fix, maybe, for #48 --- common/repeat_timer.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/repeat_timer.go b/common/repeat_timer.go index e2a5e183..ce491f20 100644 --- a/common/repeat_timer.go +++ b/common/repeat_timer.go @@ -42,13 +42,13 @@ func (t *RepeatTimer) fireRoutine(ticker *time.Ticker) { // Wait the duration again before firing. func (t *RepeatTimer) Reset() { + t.Stop() + t.mtx.Lock() // Lock defer t.mtx.Unlock() - if t.ticker != nil { - t.ticker.Stop() - } t.ticker = time.NewTicker(t.dur) + t.quit = make(chan struct{}) go t.fireRoutine(t.ticker) } @@ -60,6 +60,7 @@ func (t *RepeatTimer) Stop() bool { if exists { t.ticker.Stop() t.ticker = nil + close(t.quit) } return exists }