]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: If map_with_read gets disabled, reset the cache buffers properly.
authorTimo Sirainen <tss@iki.fi>
Wed, 19 Dec 2012 13:00:45 +0000 (15:00 +0200)
committerTimo Sirainen <tss@iki.fi>
Wed, 19 Dec 2012 13:00:45 +0000 (15:00 +0200)
src/lib-index/mail-cache-compress.c
src/lib-index/mail-cache.c

index e3bdf7cdac3c4a3f0a262f0e63ac27f83204eff6..5ed89dafe01d994d5893e1d88e7fd118c69976b2 100644 (file)
@@ -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
index ccb0237395d05367fbae28a2db6b7419352a9ce4..da40232c49834a44b5ab8a4d9957b838653e1fdb 100644 (file)
@@ -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;
        }