]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Add mail_cache.last_stat_size historical/master-2.2
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 10 Feb 2020 16:16:14 +0000 (18:16 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 1 Jun 2020 12:26:41 +0000 (15:26 +0300)
src/lib-index/mail-cache-private.h
src/lib-index/mail-cache.c

index cb1c6efc304447d76fcd51fcddddd1a258e46ef6..b75b9af70a7d3847fd2f037400901a71db6eed30 100644 (file)
@@ -96,6 +96,7 @@ struct mail_cache {
 
        time_t last_mmap_error_time;
 
+       uoff_t last_stat_size;
        size_t mmap_length;
        /* a) mmaping the whole file */
        void *mmap_base;
index 0a861e47cf05d00da189a40521102e4607e36c50..c7ce3abff84cc59bb048bdebed427d1cef2faa16 100644 (file)
@@ -117,6 +117,7 @@ static void mail_cache_init_file_cache(struct mail_cache *cache)
                mail_cache_set_syscall_error(cache, "fstat()");
        }
 
+       cache->last_stat_size = st.st_size;
        cache->st_ino = st.st_ino;
        cache->st_dev = st.st_dev;
 }
@@ -438,6 +439,7 @@ int mail_cache_map(struct mail_cache *cache, size_t offset, size_t size,
                        i_error("fstat(%s) failed: %m", cache->filepath);
                        return -1;
                }
+               cache->last_stat_size = st.st_size;
                if (offset >= (uoff_t)st.st_size) {
                        *data_r = NULL;
                        return 0;
@@ -799,6 +801,7 @@ int mail_cache_append(struct mail_cache *cache, const void *data, size_t size,
                                mail_cache_set_syscall_error(cache, "fstat()");
                        return -1;
                }
+               cache->last_stat_size = st.st_size;
                if ((uoff_t)st.st_size > cache->index->optimization_set.cache.max_size) {
                        mail_cache_set_corrupted(cache, "Cache file too large");
                        return -1;