aboutsummaryrefslogtreecommitdiff
path: root/session.go
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-01-20 15:25:46 +0100
committerSimon Ser <contact@emersion.fr>2020-01-20 15:25:46 +0100
commite6e457e4a72b77ca3c9d8a6154d78cb9bbf1c786 (patch)
tree5840013c0835dd9865786ac114677c3b2e89ce53 /session.go
parent8b10324ab64c3c99e46ed272dd5d32c89ff156a1 (diff)
downloadalps-e6e457e4a72b77ca3c9d8a6154d78cb9bbf1c786.tar.gz
alps-e6e457e4a72b77ca3c9d8a6154d78cb9bbf1c786.zip
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.
Diffstat (limited to 'session.go')
-rw-r--r--session.go4
1 files changed, 1 insertions, 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 {