From e6e457e4a72b77ca3c9d8a6154d78cb9bbf1c786 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 20 Jan 2020 15:25:46 +0100 Subject: [PATCH] Fix dangling goroutine on session expiration The timer channel may already have been drained by `case <-timer.C`. In this case, we need not to drain it again or we'll block forever. To fix this, stop draining the timer channel. Since we're not going to use the timer again anyway, it should be fine. --- session.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/session.go b/session.go index 44af8d1..08c6724 100644 --- a/session.go +++ b/session.go @@ -237,9 +237,7 @@ func (sm *SessionManager) Put(username, password string) (*Session, error) { } } - if !timer.Stop() { - <-timer.C - } + timer.Stop() s.locker.Lock() if s.imapConn != nil {