summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-02-18 15:14:08 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-02-18 15:14:08 +0000
commitc744a20b8605f81251f14945f97f832c8306920a (patch)
tree06f7d3e017c7ab684a098f352e64e8e0d41af09c /src
parentddec997069bbdb56fa1438c07a211cd66b4a79c8 (diff)
downloadrspamd-c744a20b8605f81251f14945f97f832c8306920a.tar.gz
rspamd-c744a20b8605f81251f14945f97f832c8306920a.zip
Invalidate learned files to update their content.
Diffstat (limited to 'src')
-rw-r--r--src/libstat/backends/backends.h3
-rw-r--r--src/libstat/backends/mmaped_file.c11
-rw-r--r--src/libstat/stat_config.c1
-rw-r--r--src/libstat/stat_process.c3
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);
}
}