Mercurial > dovecot > core-2.2
changeset 20041:4d83654e61d6
lib-index: If opening a cache file fails, try again later.
The previous code would never retry opening the cache file within the same
session.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Wed, 20 Apr 2016 02:23:31 +0300 |
parents | 4da8d743d98f |
children | de84d5cccd61 |
files | src/lib-index/mail-cache-compress.c src/lib-index/mail-cache.c |
diffstat | 2 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-cache-compress.c Wed Apr 20 00:29:49 2016 +0300 +++ b/src/lib-index/mail-cache-compress.c Wed Apr 20 02:23:31 2016 +0300 @@ -363,6 +363,7 @@ } mail_cache_file_close(cache); + cache->opened = TRUE; cache->fd = fd; cache->st_ino = st.st_ino; cache->st_dev = st.st_dev;
--- a/src/lib-index/mail-cache.c Wed Apr 20 00:29:49 2016 +0300 +++ b/src/lib-index/mail-cache.c Wed Apr 20 02:23:31 2016 +0300 @@ -77,6 +77,7 @@ mail_cache_set_syscall_error(cache, "close()"); cache->fd = -1; } + cache->opened = FALSE; } static void mail_cache_init_file_cache(struct mail_cache *cache) @@ -101,14 +102,17 @@ { const void *data; + i_assert(!cache->opened); cache->opened = TRUE; if (MAIL_INDEX_IS_IN_MEMORY(cache->index)) return 0; + i_assert(cache->fd == -1); cache->fd = nfs_safe_open(cache->filepath, cache->index->readonly ? O_RDONLY : O_RDWR); if (cache->fd == -1) { + mail_cache_file_close(cache); if (errno == ENOENT) { cache->need_compress_file_seq = 0; return 0; @@ -120,8 +124,10 @@ mail_cache_init_file_cache(cache); - if (mail_cache_map(cache, 0, 0, &data) < 0) + if (mail_cache_map(cache, 0, 0, &data) < 0) { + mail_cache_file_close(cache); return -1; + } return 1; }