From: Timo Sirainen Date: Mon, 30 Mar 2020 13:16:46 +0000 (+0300) Subject: lib-index: mail_cache_reopen_now() - Fix corruption handling remove checking if reset... X-Git-Tag: 2.3.11.2~401 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4e0ae5f50feb00610c4ea5c477e3d3cedb6527c;p=thirdparty%2Fdovecot%2Fcore.git lib-index: mail_cache_reopen_now() - Fix corruption handling remove checking if reset_id matches reset_id checking is already done by all of the callers. Also simplify the error vs corruption handling by using mail_cache_open_and_verify() --- diff --git a/src/lib-index/mail-cache.c b/src/lib-index/mail-cache.c index e7591eaaff..c3cab5f6dc 100644 --- a/src/lib-index/mail-cache.c +++ b/src/lib-index/mail-cache.c @@ -200,32 +200,8 @@ bool mail_cache_need_reopen(struct mail_cache *cache) int mail_cache_reopen(struct mail_cache *cache) { - struct mail_index_view *view; - const struct mail_index_ext *ext; - mail_cache_file_close(cache); - - if (mail_cache_try_open(cache) <= 0) - return -1; - - if (mail_cache_header_fields_read(cache) < 0) - return -1; - - view = mail_index_view_open(cache->index); - ext = mail_index_view_get_ext(view, cache->ext_id); - if (ext == NULL || cache->hdr->file_seq != ext->reset_id) { - /* still different - maybe a race condition or maybe the - file_seq really is corrupted. either way, this shouldn't - happen often so we'll just mark cache to be compressed - later which fixes this. */ - cache->need_compress_file_seq = cache->hdr->file_seq; - mail_index_view_close(&view); - return 0; - } - - mail_index_view_close(&view); - i_assert(!MAIL_CACHE_IS_UNUSABLE(cache)); - return 1; + return mail_cache_open_and_verify(cache); } static void mail_cache_update_need_compress(struct mail_cache *cache)