]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Limit mmap errors in index cache to 1/s
authorAki Tuomi <aki.tuomi@dovecot.fi>
Mon, 21 Nov 2016 11:53:50 +0000 (13:53 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 21 Nov 2016 20:45:02 +0000 (22:45 +0200)
src/lib-index/mail-cache-private.h
src/lib-index/mail-cache.c

index 22576cbf54ee961d879b08f3320281ef8477f65c..2c80295a482b391503e58133b3c33f1161c206a7 100644 (file)
@@ -114,6 +114,8 @@ struct mail_cache {
        ino_t st_ino;
        dev_t st_dev;
 
+       time_t last_mmap_error_time;
+
        size_t mmap_length;
        /* a) mmaping the whole file */
        void *mmap_base;
index f244f99dc0a71a5034c66522a859710c56ed6e9d..356d8deeefa2708c137f23aed7e9df3cd23de44a 100644 (file)
@@ -10,6 +10,7 @@
 #include "read-full.h"
 #include "write-full.h"
 #include "mail-cache-private.h"
+#include "ioloop.h"
 
 #include <unistd.h>
 
@@ -480,8 +481,11 @@ int mail_cache_map(struct mail_cache *cache, size_t offset, size_t size,
        if (cache->mmap_base == MAP_FAILED) {
                cache->mmap_base = NULL;
                cache->mmap_length = 0;
-               mail_cache_set_syscall_error(cache, t_strdup_printf(
-                       "mmap(size=%"PRIuSIZE_T")", cache->mmap_length));
+               if (ioloop_time != cache->last_mmap_error_time) {
+                       cache->last_mmap_error_time = ioloop_time;
+                       mail_cache_set_syscall_error(cache, t_strdup_printf(
+                               "mmap(size=%"PRIuSIZE_T")", cache->mmap_length));
+               }
                return -1;
        }
        *data_r = offset > cache->mmap_length ? NULL :