diff options
-rw-r--r-- | src/libstat/backends/backends.h | 3 | ||||
-rw-r--r-- | src/libstat/backends/mmaped_file.c | 11 | ||||
-rw-r--r-- | src/libstat/stat_config.c | 1 | ||||
-rw-r--r-- | src/libstat/stat_process.c | 3 |
4 files changed, 18 insertions, 0 deletions
diff --git a/src/libstat/backends/backends.h b/src/libstat/backends/backends.h index f8a2af72c..e775faf6e 100644 --- a/src/libstat/backends/backends.h +++ b/src/libstat/backends/backends.h @@ -48,6 +48,7 @@ struct rspamd_stat_backend { gboolean (*learn_token)(struct token_node_s *tok, struct rspamd_token_result *res, gpointer ctx); gulong (*total_learns)(struct rspamd_statfile_runtime *runtime, gpointer ctx); + void (*finalize_learn)(struct rspamd_statfile_runtime *runtime, gpointer ctx); gulong (*inc_learns)(struct rspamd_statfile_runtime *runtime, gpointer ctx); gulong (*dec_learns)(struct rspamd_statfile_runtime *runtime, gpointer ctx); ucl_object_t* (*get_stat)(struct rspamd_statfile_runtime *runtime, gpointer ctx); @@ -63,6 +64,8 @@ gboolean rspamd_mmaped_file_process_token (struct token_node_s *tok, gboolean rspamd_mmaped_file_learn_token (struct token_node_s *tok, struct rspamd_token_result *res, gpointer ctx); +void rspamd_mmaped_file_finalize_learn (struct rspamd_statfile_runtime *runtime, + gpointer ctx); gulong rspamd_mmaped_file_total_learns (struct rspamd_statfile_runtime *runtime, gpointer ctx); gulong rspamd_mmaped_file_inc_learns (struct rspamd_statfile_runtime *runtime, diff --git a/src/libstat/backends/mmaped_file.c b/src/libstat/backends/mmaped_file.c index 02ea17c28..2e5709149 100644 --- a/src/libstat/backends/mmaped_file.c +++ b/src/libstat/backends/mmaped_file.c @@ -1037,3 +1037,14 @@ rspamd_mmaped_file_get_stat (struct rspamd_statfile_runtime *runtime, return res; } + +void +rspamd_mmaped_file_finalize_learn (struct rspamd_statfile_runtime *runtime, + gpointer ctx) +{ + rspamd_mmaped_file_t *mf = (rspamd_mmaped_file_t *)runtime; + + if (mf != NULL) { + msync (mf->map, mf->len, MS_INVALIDATE | MS_ASYNC); + } +} diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c index 17b5c54f5..8a0514721 100644 --- a/src/libstat/stat_config.c +++ b/src/libstat/stat_config.c @@ -51,6 +51,7 @@ static struct rspamd_stat_backend stat_backends[] = { .runtime = rspamd_mmaped_file_runtime, .process_token = rspamd_mmaped_file_process_token, .learn_token = rspamd_mmaped_file_learn_token, + .finalize_learn = rspamd_mmaped_file_finalize_learn, .total_learns = rspamd_mmaped_file_total_learns, .inc_learns = rspamd_mmaped_file_inc_learns, .dec_learns = rspamd_mmaped_file_dec_learns, diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index 1ce439c51..511a9f800 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -560,6 +560,9 @@ rspamd_stat_learn (struct rspamd_task *task, gboolean spam, lua_State *L, st_run->st->symbol, nrev); } + st_run->backend->finalize_learn (st_run->backend_runtime, + st_run->backend->ctx); + curst = g_list_next (curst); } } |