diff --git a/internal/utils/timer.go b/internal/utils/timer.go index 1fefc6ec8..a4f5e67aa 100644 --- a/internal/utils/timer.go +++ b/internal/utils/timer.go @@ -46,3 +46,8 @@ func (t *Timer) Reset(deadline time.Time) { func (t *Timer) SetRead() { t.read = true } + +// Stop stops the timer +func (t *Timer) Stop() { + t.t.Stop() +} diff --git a/internal/utils/timer_test.go b/internal/utils/timer_test.go index 679492797..0cbb4a011 100644 --- a/internal/utils/timer_test.go +++ b/internal/utils/timer_test.go @@ -77,4 +77,11 @@ var _ = Describe("Timer", func() { Eventually(t.Chan()).Should(Receive()) Consistently(t.Chan()).ShouldNot(Receive()) }) + + It("stops", func() { + t := NewTimer() + t.Reset(time.Now().Add(50 * time.Millisecond)) + t.Stop() + Consistently(t.Chan()).ShouldNot(Receive()) + }) }) diff --git a/session.go b/session.go index e738865ee..ab4fcb22b 100644 --- a/session.go +++ b/session.go @@ -605,6 +605,7 @@ runLoop: s.logger.Infof("Connection %s closed.", s.logID) s.cryptoStreamHandler.Close() s.sendQueue.Close() + s.timer.Stop() return closeErr.err }