From: Timo Sirainen Date: Wed, 19 Dec 2012 13:00:45 +0000 (+0200) Subject: lib-index: If map_with_read gets disabled, reset the cache buffers properly. X-Git-Tag: 2.1.13~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de9b2ee7878a73346ba0eee34798abb22ffcfcb6;p=thirdparty%2Fdovecot%2Fcore.git lib-index: If map_with_read gets disabled, reset the cache buffers properly. --- diff --git a/src/lib-index/mail-cache-compress.c b/src/lib-index/mail-cache-compress.c index e3bdf7cdac..5ed89dafe0 100644 --- a/src/lib-index/mail-cache-compress.c +++ b/src/lib-index/mail-cache-compress.c @@ -462,7 +462,13 @@ int mail_cache_compress(struct mail_cache *cache, 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 diff --git a/src/lib-index/mail-cache.c b/src/lib-index/mail-cache.c index ccb0237395..da40232c49 100644 --- a/src/lib-index/mail-cache.c +++ b/src/lib-index/mail-cache.c @@ -394,6 +394,7 @@ int mail_cache_map(struct mail_cache *cache, size_t offset, size_t size, 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; }