aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat/backends
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2016-07-20 12:52:11 +0100
committerAndrew Lewis <nerf@judo.za.org>2016-07-20 12:52:11 +0100
commit295549db2fe885430456abc385c8875b837bee91 (patch)
treebf97f43127794786860d0b0478e807f85724fd81 /src/libstat/backends
parente1e2c7f0b69adfdaa5e36aebb3f1b607e4f6f62a (diff)
downloadrspamd-295549db2fe885430456abc385c8875b837bee91.tar.gz
rspamd-295549db2fe885430456abc385c8875b837bee91.zip
[Fix] Fix creation of mmapped statfiles
Diffstat (limited to 'src/libstat/backends')
-rw-r--r--src/libstat/backends/mmaped_file.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/libstat/backends/mmaped_file.c b/src/libstat/backends/mmaped_file.c
index 2065edd5c..75a9a5e10 100644
--- a/src/libstat/backends/mmaped_file.c
+++ b/src/libstat/backends/mmaped_file.c
@@ -824,7 +824,34 @@ rspamd_mmaped_file_init (struct rspamd_stat_ctx *ctx,
if (mf != NULL) {
mf->pool = cfg->cfg_pool;
- }
+ } else {
+ /* Create file here */
+
+ filenameo = ucl_object_find_key (stf->opts, "filename");
+ if (filenameo == NULL || ucl_object_type (filenameo) != UCL_STRING) {
+ filenameo = ucl_object_find_key (stf->opts, "path");
+ if (filenameo == NULL || ucl_object_type (filenameo) != UCL_STRING) {
+ msg_err_config ("statfile %s has no filename defined", stf->symbol);
+ return NULL;
+ }
+ }
+
+ filename = ucl_object_tostring (filenameo);
+
+ sizeo = ucl_object_find_key (stf->opts, "size");
+ if (sizeo == NULL || ucl_object_type (sizeo) != UCL_INT) {
+ msg_err_config ("statfile %s has no size defined", stf->symbol);
+ return NULL;
+ }
+
+ size = ucl_object_toint (sizeo);
+
+ if (rspamd_mmaped_file_create (filename, size, stf, cfg->cfg_pool) != 0) {
+ msg_err_config ("cannot create new file");
+ }
+
+ mf = rspamd_mmaped_file_open (cfg->cfg_pool, filename, size, stf);
+ }
return (gpointer)mf;
}