From f4d6ade429850aa30b5f6a8aefc3ef5a00c2e584 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Fri, 16 Sep 2022 14:41:05 -0500 Subject: imap: prevent deadlock from posting actions to self The IMAP worker has a few methods that post a new Action to itself. This can create a deadlock when the worker.Actions channel is full: The worker can't accept a new Action because it's trying to post an action. This is most noticeable when cached headers are enabled and the message list is scrolled fast. Use a goroutine to post actions to the worker when posting from within the worker. Fixes: https://todo.sr.ht/~rjarry/aerc/45 Fixes: 7aa71d334b27 ("imap: add option to cache headers") Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- worker/imap/cache.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'worker/imap/cache.go') diff --git a/worker/imap/cache.go b/worker/imap/cache.go index 62d450e6..3c807c50 100644 --- a/worker/imap/cache.go +++ b/worker/imap/cache.go @@ -126,7 +126,8 @@ func (w *IMAPWorker) getCachedHeaders(msg *types.FetchMessageHeaders) []uint32 { }, nil) } if len(found) > 0 { - w.worker.PostAction(&types.FetchMessageFlags{ + // Post in a separate goroutine to prevent deadlocking + go w.worker.PostAction(&types.FetchMessageFlags{ Uids: found, }, nil) } -- cgit