]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Fixed calling mail_cache_open_and_verify() on an already open cache.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 19 Apr 2016 21:29:49 +0000 (00:29 +0300)
committerGitLab <gitlab@git.dovecot.net>
Wed, 20 Apr 2016 14:14:48 +0000 (17:14 +0300)
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))

src/lib-index/mail-cache.c

index 34c05c5d84babd67cdc2064413a4c727e5403917..53b45d58e32e7641bc8672d7f6ff48e311cb8c79 100644 (file)
@@ -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);