From 650e00972d036014530594bbd781579166889a5e Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Mon, 7 Nov 2022 13:40:05 -0600 Subject: maildir: drain limit channel on parse error when sorting Commit 155f0c3f28a1 ("maildir/sort: get MessageInfos in parallel") added parallel parsing of maildir messages. The parsing is limitted to 2x the number of CPUs using a buffered channel. The channel is drained at the end of the parsing, however it is not drained if a parse error is encountered. With enough errors, this can lead to a deadlock. Drain the channel when an error occurs. Fixes: 155f0c3f28a1 ("maildir/sort: get MessageInfos in parallel") Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- worker/maildir/worker.go | 1 + 1 file changed, 1 insertion(+) (limited to 'worker/maildir/worker.go') diff --git a/worker/maildir/worker.go b/worker/maildir/worker.go index d6c05ff0..2cf7897a 100644 --- a/worker/maildir/worker.go +++ b/worker/maildir/worker.go @@ -461,6 +461,7 @@ func (w *Worker) sort(uids []uint32, criteria []*types.SortCriterion) ([]uint32, info, err := w.msgHeadersFromUid(uid) if err != nil { logging.Errorf("could not get message info: %v", err) + <-limit return } mu.Lock() -- cgit