From d6513ee4ecc2e841c8d49972f1c27cbe6e252732 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Mon, 28 May 2018 14:02:09 +0200 Subject: [PATCH] test case for 0 timeout --- common/signal/timer.go | 1 + common/signal/timer_test.go | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/common/signal/timer.go b/common/signal/timer.go index 34f65388f..67ec5f13a 100644 --- a/common/signal/timer.go +++ b/common/signal/timer.go @@ -42,6 +42,7 @@ func (t *ActivityTimer) finish() { if t.onTimeout != nil { t.onTimeout() + t.onTimeout = nil } if t.checkTask != nil { t.checkTask.Close() // nolint: errcheck diff --git a/common/signal/timer_test.go b/common/signal/timer_test.go index f299b308b..c104d44aa 100644 --- a/common/signal/timer_test.go +++ b/common/signal/timer_test.go @@ -44,3 +44,12 @@ func TestActivityTimerNonBlocking(t *testing.T) { timer.SetTimeout(1) timer.SetTimeout(2) } + +func TestActivityTimerZeroTimeout(t *testing.T) { + assert := With(t) + + ctx, cancel := context.WithCancel(context.Background()) + timer := CancelAfterInactivity(ctx, cancel, 0) + assert(ctx, HasDone) + runtime.KeepAlive(timer) +}