From: Timo Sirainen Date: Tue, 19 Apr 2016 21:29:49 +0000 (+0300) Subject: lib-index: Fixed calling mail_cache_open_and_verify() on an already open cache. X-Git-Tag: 2.3.0.rc1~3993 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=46d91e9ea8bf41e56c5436c064372171c5876d81;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Fixed calling mail_cache_open_and_verify() on an already open cache. This was done at least by index_index_rebuild_init(). Either the currently open cache->fd was leaked, or if the cache file open() failed we left the cache in an inconsistent state where cache->fd == -1, but cache->hdr != NULL, so it caused MAIL_CACHE_IS_UNUSABLE() to also be TRUE. This could have ended up in an assert: Panic: file mail-index-lock.c: line 31 (mail_index_lock_fd): assertion failed: (MAIL_INDEX_IS_IN_MEMORY(index)) --- diff --git a/src/lib-index/mail-cache.c b/src/lib-index/mail-cache.c index 34c05c5d84..53b45d58e3 100644 --- a/src/lib-index/mail-cache.c +++ b/src/lib-index/mail-cache.c @@ -487,6 +487,8 @@ int mail_cache_open_and_verify(struct mail_cache *cache) { int ret; + if (cache->opened) + return 0; ret = mail_cache_try_open(cache); if (ret > 0) ret = mail_cache_header_fields_read(cache);