aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-01-20 22:44:06 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-01-20 22:44:06 +0000
commitfac115a3a452dc1aebdb4a64d425af4e7318a671 (patch)
treec36fa51d6c98f939fae8cfd9867963e50e55d05f /src
parent0762a7107fbd1f5b6f1fd39681590acba4993506 (diff)
downloadrspamd-fac115a3a452dc1aebdb4a64d425af4e7318a671.tar.gz
rspamd-fac115a3a452dc1aebdb4a64d425af4e7318a671.zip
Restore statfile resize logic.
Diffstat (limited to 'src')
-rw-r--r--src/libstat/backends/mmaped_file.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libstat/backends/mmaped_file.c b/src/libstat/backends/mmaped_file.c
index 2769bba8a..43baaa67c 100644
--- a/src/libstat/backends/mmaped_file.c
+++ b/src/libstat/backends/mmaped_file.c
@@ -338,6 +338,18 @@ rspamd_mmaped_file_open (rspamd_mmaped_file_ctx * pool,
}
rspamd_mempool_lock_mutex (pool->lock);
+ if (!forced &&
+ labs (size - st.st_size) > (long)sizeof (struct stat_file) * 2
+ && size > sizeof (struct stat_file)) {
+ rspamd_mempool_unlock_mutex (pool->lock);
+ msg_warn ("need to reindex statfile old size: %Hz, new size: %Hz",
+ (size_t)st.st_size, size);
+ return rspamd_mmaped_file_reindex (pool, filename, st.st_size, size);
+ }
+ else if (size < sizeof (struct stat_file)) {
+ msg_err ("requested to shrink statfile to %Hz but it is too small",
+ size);
+ }
new_file = g_slice_alloc0 (sizeof (rspamd_mmaped_file_t));
if ((new_file->fd = open (filename, O_RDWR)) == -1) {