From 30c0a9fba471bcd023c8aeebb3901803bb35d31f Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Sat, 15 Feb 2020 12:37:18 +0100 Subject: imap: fix double closing idleStop The idle restart code is at the end of handleMessage in the worker. However if an unsupported msg comes in, we returned early, skipping the re-init. That lead to a crash due to double closing idleStop in the next iteration. --- worker/imap/worker.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'worker/imap') diff --git a/worker/imap/worker.go b/worker/imap/worker.go index 4d3e51cc..ddd95b6c 100644 --- a/worker/imap/worker.go +++ b/worker/imap/worker.go @@ -66,6 +66,8 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error { } } + var reterr error // will be returned at the end, needed to support idle + switch msg := msg.(type) { case *types.Unsupported: // No-op @@ -180,7 +182,7 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error { case *types.SearchDirectory: w.handleSearchDirectory(msg) default: - return errUnsupported + reterr = errUnsupported } if w.idleStop != nil { @@ -189,7 +191,7 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error { w.idleDone <- w.client.idle.IdleWithFallback(w.idleStop, 0) }() } - return nil + return reterr } func (w *IMAPWorker) handleImapUpdate(update client.Update) { -- cgit