aboutsummaryrefslogtreecommitdiffstats
path: root/worker/imap/worker.go
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-02-15 12:37:18 +0100
committerDrew DeVault <sir@cmpwn.com>2020-02-16 10:41:11 -0500
commit30c0a9fba471bcd023c8aeebb3901803bb35d31f (patch)
treebb5943328da9082cd2d59d3910513ea6ccccb0d6 /worker/imap/worker.go
parent3e7e236f50265d53528b3168c192a0254413db06 (diff)
downloadaerc-30c0a9fba471bcd023c8aeebb3901803bb35d31f.tar.gz
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.
Diffstat (limited to 'worker/imap/worker.go')
-rw-r--r--worker/imap/worker.go6
1 files changed, 4 insertions, 2 deletions
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) {