1
0
mirror of https://git.sr.ht/~sircmpwn/aerc synced 2024-11-23 08:32:12 +01:00

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

@ -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) { switch msg := msg.(type) {
case *types.Unsupported: case *types.Unsupported:
// No-op // No-op
@ -180,7 +182,7 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error {
case *types.SearchDirectory: case *types.SearchDirectory:
w.handleSearchDirectory(msg) w.handleSearchDirectory(msg)
default: default:
return errUnsupported reterr = errUnsupported
} }
if w.idleStop != nil { 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) w.idleDone <- w.client.idle.IdleWithFallback(w.idleStop, 0)
}() }()
} }
return nil return reterr
} }
func (w *IMAPWorker) handleImapUpdate(update client.Update) { func (w *IMAPWorker) handleImapUpdate(update client.Update) {