From: Timo Sirainen Date: Tue, 18 Jul 2017 09:39:44 +0000 (+0300) Subject: lib-storage: Don't allow removing \Recent flags with mail_update_flags() X-Git-Tag: 2.2.32.rc1~72 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=934650a50e859d167fd1aa22e86f653aecbd13da;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Don't allow removing \Recent flags with mail_update_flags() Reverts an ancient commit 7deb24e7453249d09741641bff0f269f68165033. I don't know why it was added in the first place. Normally \Recent flags are removed during sync with MAIL_INDEX_SYNC_FLAG_DROP_RECENT. This should be enough, especially since it's not even possible to remove a single \Recent flag - only update the first_recent_uid. The code was also wrong: It was dropping \Recent flags even when modify_type/flags combination didn't ask for it. Even if this was fixed, there would still be race conditions with multiple processes since this update is done without locking. Fixes: Error: Recent flags state corrupted for mailbox --- diff --git a/src/lib-storage/index/index-mail.c b/src/lib-storage/index/index-mail.c index 500eb100a0..feca8fe98f 100644 --- a/src/lib-storage/index/index-mail.c +++ b/src/lib-storage/index/index-mail.c @@ -2109,19 +2109,6 @@ void index_mail_cache_parse_deinit(struct mail *_mail, time_t received_date, (void)index_mail_parse_body_finish(mail, 0, success); } -static void index_mail_drop_recent_flag(struct mail *mail) -{ - const struct mail_index_header *hdr; - uint32_t first_recent_uid = mail->uid + 1; - - hdr = mail_index_get_header(mail->transaction->view); - if (hdr->first_recent_uid < first_recent_uid) { - mail_index_update_header(mail->transaction->itrans, - offsetof(struct mail_index_header, first_recent_uid), - &first_recent_uid, sizeof(first_recent_uid), FALSE); - } -} - static bool index_mail_update_pvt_flags(struct mail *_mail, enum modify_type modify_type, enum mail_flags pvt_flags) @@ -2157,9 +2144,6 @@ void index_mail_update_flags(struct mail *_mail, enum modify_type modify_type, enum mail_flags pvt_flags_mask, pvt_flags = 0; bool update_modseq = FALSE; - if ((flags & MAIL_RECENT) == 0 && - mailbox_recent_flags_have_uid(_mail->box, _mail->uid)) - index_mail_drop_recent_flag(_mail); flags &= MAIL_FLAGS_NONRECENT | MAIL_INDEX_MAIL_FLAG_BACKEND; if (_mail->box->view_pvt != NULL) {