From 629938bacad71fd6754d96e6a524463fe438bac5 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 23 Feb 2015 16:00:07 +0000 Subject: [PATCH] Try to open statfile if it is not found. --- src/libstat/backends/mmaped_file.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/libstat/backends/mmaped_file.c b/src/libstat/backends/mmaped_file.c index 2e5709149..dc4c1c599 100644 --- a/src/libstat/backends/mmaped_file.c +++ b/src/libstat/backends/mmaped_file.c @@ -865,7 +865,7 @@ rspamd_mmaped_file_runtime (struct rspamd_statfile_config *stcf, gboolean learn, mf = rspamd_mmaped_file_is_open (ctx, stcf); - if (mf == NULL && learn) { + if (mf == NULL) { /* Create file here */ filenameo = ucl_object_find_key (stcf->opts, "filename"); @@ -877,18 +877,19 @@ rspamd_mmaped_file_runtime (struct rspamd_statfile_config *stcf, gboolean learn, } } + if (learn) { + filename = ucl_object_tostring (filenameo); - filename = ucl_object_tostring (filenameo); + sizeo = ucl_object_find_key (stcf->opts, "size"); + if (sizeo == NULL || ucl_object_type (sizeo) != UCL_INT) { + msg_err ("statfile %s has no size defined", stcf->symbol); + return NULL; + } - sizeo = ucl_object_find_key (stcf->opts, "size"); - if (sizeo == NULL || ucl_object_type (sizeo) != UCL_INT) { - msg_err ("statfile %s has no size defined", stcf->symbol); - return NULL; + size = ucl_object_toint (sizeo); + rspamd_mmaped_file_create (ctx, filename, size, stcf); } - size = ucl_object_toint (sizeo); - rspamd_mmaped_file_create (ctx, filename, size, stcf); - mf = rspamd_mmaped_file_open (ctx, filename, size, stcf); } -- 2.39.5