From c9a3ba964784512b739699254b79be7aa9acc994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Mon, 10 May 2021 15:09:43 +0200 Subject: #47: Exhaust messages to avoid deadlock --- internal/imap/connection.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/imap/connection.go b/internal/imap/connection.go index 213171e..3d537ea 100644 --- a/internal/imap/connection.go +++ b/internal/imap/connection.go @@ -170,7 +170,14 @@ func (conn *connection) fetchFlags(uid uint32) ([]string, error) { done <- conn.c.UidFetch(seqSet, fetchItem, messages) }() - msg := <-messages + var msg *imap.Message + for m := range messages { + if msg == nil { + msg = m + } else { + panic(fmt.Sprintf("Duplicate message for uid %d. Found: %s(%d) and %s(%d)", uid, msg.Envelope.MessageId, msg.SeqNum, m.Envelope.MessageId, m.SeqNum)) + } + } err := <-done if err != nil { -- cgit v1.2.3