changeset 20780:6fd8e7d2a497

lib-storage: Update mailbox.recent_flags_count correctly. The counter was increased even if the UID was already in recent_flags. This is the only place where I found that recent_flags and recent_flags_count could become desynced (which they definitely were in a core dump), so hopefully this fixes assert-crashes like: Panic: file index-status.c: line 130 (index_storage_get_open_status): assertion failed: (status_r->recent <= status_r->messages)
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 27 Sep 2016 13:28:15 +0300
parents 8a47f278ee2b
children 94ec056b78fb
files src/lib-storage/mailbox-recent-flags.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/mailbox-recent-flags.c	Tue Sep 27 13:50:51 2016 +0300
+++ b/src/lib-storage/mailbox-recent-flags.c	Tue Sep 27 13:28:15 2016 +0300
@@ -23,8 +23,10 @@
 {
 	box->recent_flags_prev_uid = uid;
 
-	seq_range_array_add_with_init(&box->recent_flags, 64, uid);
-	box->recent_flags_count++;
+	if (!mailbox_recent_flags_have_uid(box, uid)) {
+		seq_range_array_add_with_init(&box->recent_flags, 64, uid);
+		box->recent_flags_count++;
+	}
 }
 
 void mailbox_recent_flags_set_seqs(struct mailbox *box,