Mercurial > dovecot > original-hg > dovecot-2.1
changeset 14857:32ce915e046a
lib-index: If map_with_read gets disabled, reset the cache buffers properly.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 19 Dec 2012 15:00:45 +0200 |
parents | bde8963a3774 |
children | 7f4835cff04a |
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 Tue Dec 18 22:13:48 2012 +0200 +++ b/src/lib-index/mail-cache-compress.c Wed Dec 19 15:00:45 2012 +0200 @@ -462,7 +462,13 @@ return 0; /* compression isn't very efficient with small read()s */ - cache->map_with_read = FALSE; + if (cache->map_with_read) { + cache->map_with_read = FALSE; + if (cache->read_buf != NULL) + buffer_set_used_size(cache->read_buf, 0); + cache->hdr = NULL; + cache->mmap_length = 0; + } if (cache->index->lock_method == FILE_LOCK_METHOD_DOTLOCK) { /* we're using dotlocking, cache file creation itself creates
--- a/src/lib-index/mail-cache.c Tue Dec 18 22:13:48 2012 +0200 +++ b/src/lib-index/mail-cache.c Wed Dec 19 15:00:45 2012 +0200 @@ -394,6 +394,7 @@ if (offset < cache->mmap_length && size <= cache->mmap_length - offset) { /* already mapped */ + i_assert(cache->mmap_base != NULL); *data_r = CONST_PTR_OFFSET(cache->mmap_base, offset); return 1; }