From: Timo Sirainen Date: Tue, 18 Jul 2017 08:57:24 +0000 (+0300) Subject: lib-storage: If mail_index_header.first_recent_uid shrinks, reset \Recent flags X-Git-Tag: 2.2.32.rc1~73 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f5bfceed99d77760b578cebec3e76695d4b1893f;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: If mail_index_header.first_recent_uid shrinks, reset \Recent flags This should never happen. --- diff --git a/src/lib-storage/index/index-storage.h b/src/lib-storage/index/index-storage.h index b245117b2f..70c4a0ffd3 100644 --- a/src/lib-storage/index/index-storage.h +++ b/src/lib-storage/index/index-storage.h @@ -40,6 +40,7 @@ struct index_mailbox_context { struct mailbox_vsize_update *vsize_update; + uint32_t recent_flags_prev_first_recent_uid; uint32_t recent_flags_last_check_nextuid; time_t sync_last_check; diff --git a/src/lib-storage/index/index-sync.c b/src/lib-storage/index/index-sync.c index 6d180c4691..5ba5baacc9 100644 --- a/src/lib-storage/index/index-sync.c +++ b/src/lib-storage/index/index-sync.c @@ -278,8 +278,17 @@ void index_sync_update_recent_count(struct mailbox *box) uint32_t seq1, seq2; hdr = mail_index_get_header(box->view); + if (hdr->first_recent_uid < ibox->recent_flags_prev_first_recent_uid) { + mail_storage_set_critical(box->storage, + "Mailbox %s: first_recent_uid unexpectedly shrank: %u -> %u", + box->vname, ibox->recent_flags_prev_first_recent_uid, + hdr->first_recent_uid); + mailbox_recent_flags_reset(box); + } + if (hdr->first_recent_uid > box->recent_flags_prev_uid || hdr->next_uid > ibox->recent_flags_last_check_nextuid) { + ibox->recent_flags_prev_first_recent_uid = hdr->first_recent_uid; ibox->recent_flags_last_check_nextuid = hdr->next_uid; if (mail_index_lookup_seq_range(box->view, hdr->first_recent_uid,