aboutsummaryrefslogtreecommitdiffstats
path: root/worker/imap/flags.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-09-16 14:41:05 -0500
committerRobin Jarry <robin@jarry.cc>2022-09-20 00:03:36 +0200
commitf4d6ade429850aa30b5f6a8aefc3ef5a00c2e584 (patch)
tree0d2b97ffe799f9a5afee2b9a94eb0b0a4f2e0724 /worker/imap/flags.go
parente808b96d63ecab9990cbb295e786010be66243be (diff)
downloadaerc-f4d6ade429850aa30b5f6a8aefc3ef5a00c2e584.tar.gz
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 <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'worker/imap/flags.go')
-rw-r--r--worker/imap/flags.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/worker/imap/flags.go b/worker/imap/flags.go
index bda47e9d..0cd0bb78 100644
--- a/worker/imap/flags.go
+++ b/worker/imap/flags.go
@@ -48,7 +48,8 @@ func (imapw *IMAPWorker) handleAnsweredMessages(msg *types.AnsweredMessages) {
emitErr(err)
return
}
- imapw.worker.PostAction(&types.FetchMessageHeaders{
+ // Post in a separate goroutine to prevent deadlocking
+ go imapw.worker.PostAction(&types.FetchMessageHeaders{
Uids: msg.Uids,
}, func(_msg types.WorkerMessage) {
switch m := _msg.(type) {
@@ -79,7 +80,8 @@ func (imapw *IMAPWorker) handleFlagMessages(msg *types.FlagMessages) {
emitErr(err)
return
}
- imapw.worker.PostAction(&types.FetchMessageHeaders{
+ // Post in a separate goroutine to prevent deadlocking
+ go imapw.worker.PostAction(&types.FetchMessageHeaders{
Uids: msg.Uids,
}, func(_msg types.WorkerMessage) {
switch m := _msg.(type) {