From: Aki Tuomi Date: Mon, 21 Nov 2016 11:53:50 +0000 (+0200) Subject: lib-index: Limit mmap errors in index cache to 1/s X-Git-Tag: 2.3.0.rc1~2553 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9594e86dc601b72c1636f2b901dcfbf4ffaf47f;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Limit mmap errors in index cache to 1/s --- diff --git a/src/lib-index/mail-cache-private.h b/src/lib-index/mail-cache-private.h index cfa74af646..72500d05a5 100644 --- a/src/lib-index/mail-cache-private.h +++ b/src/lib-index/mail-cache-private.h @@ -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; diff --git a/src/lib-index/mail-cache.c b/src/lib-index/mail-cache.c index f244f99dc0..356d8deeef 100644 --- a/src/lib-index/mail-cache.c +++ b/src/lib-index/mail-cache.c @@ -10,6 +10,7 @@ #include "read-full.h" #include "write-full.h" #include "mail-cache-private.h" +#include "ioloop.h" #include @@ -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 :