Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8187:f1203dce2d8c HEAD
Mail cache: lock_method=dotlock could have caused a process to deadlock with itself.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 11 Sep 2008 16:52:47 +0300 |
parents | 2358ee07d2db |
children | 2db48458d73b |
files | src/lib-index/mail-cache-compress.c src/lib-index/mail-cache-private.h src/lib-index/mail-cache.c |
diffstat | 3 files changed, 25 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-cache-compress.c Thu Sep 11 16:37:32 2008 +0300 +++ b/src/lib-index/mail-cache-compress.c Thu Sep 11 16:52:47 2008 +0300 @@ -433,6 +433,7 @@ cache->fd = fd; cache->st_ino = st.st_ino; cache->st_dev = st.st_dev; + cache->field_header_write_pending = FALSE; if (cache->file_cache != NULL) file_cache_set_fd(cache->file_cache, cache->fd); @@ -452,6 +453,8 @@ bool unlock = FALSE; int ret; + i_assert(!cache->compressing); + if (MAIL_INDEX_IS_IN_MEMORY(cache->index) || cache->index->readonly) return 0; @@ -463,26 +466,27 @@ cache->filepath, cache->fd, FALSE); } - return mail_cache_compress_locked(cache, trans, &unlock); + } else { + switch (mail_cache_lock(cache, FALSE)) { + case -1: + return -1; + case 0: + /* couldn't lock, either it's broken or doesn't exist. + just start creating it. */ + break; + default: + /* locking succeeded. */ + unlock = TRUE; + } } - - switch (mail_cache_lock(cache, FALSE)) { - case -1: - return -1; - case 0: - /* couldn't lock, either it's broken or doesn't exist. - just start creating it. */ - return mail_cache_compress_locked(cache, trans, &unlock); - default: - /* locking succeeded. */ - unlock = TRUE; - ret = mail_cache_compress_locked(cache, trans, &unlock); - if (unlock) { - if (mail_cache_unlock(cache) < 0) - ret = -1; - } - return ret; + cache->compressing = TRUE; + ret = mail_cache_compress_locked(cache, trans, &unlock); + cache->compressing = FALSE; + if (unlock) { + if (mail_cache_unlock(cache) < 0) + ret = -1; } + return ret; } bool mail_cache_need_compress(struct mail_cache *cache)
--- a/src/lib-index/mail-cache-private.h Thu Sep 11 16:37:32 2008 +0300 +++ b/src/lib-index/mail-cache-private.h Thu Sep 11 16:52:47 2008 +0300 @@ -173,6 +173,7 @@ unsigned int locked:1; unsigned int hdr_modified:1; unsigned int field_header_write_pending:1; + unsigned int compressing:1; }; struct mail_cache_loop_track {
--- a/src/lib-index/mail-cache.c Thu Sep 11 16:37:32 2008 +0300 +++ b/src/lib-index/mail-cache.c Thu Sep 11 16:52:47 2008 +0300 @@ -667,7 +667,8 @@ { i_assert(view->trans_view == NULL); - if (view->cache->field_header_write_pending) + if (view->cache->field_header_write_pending && + !view->cache->compressing) (void)mail_cache_header_fields_update(view->cache); buffer_free(&view->cached_exists_buf);