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.
This commit is contained in:
Reto Brunner 2020-02-15 12:37:18 +01:00 committed by Drew DeVault
parent 3e7e236f50
commit 30c0a9fba4
1 changed files with 4 additions and 2 deletions

View File

@ -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) {