]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Invalidate learned files to update their content.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 18 Feb 2015 15:14:08 +0000 (15:14 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 18 Feb 2015 15:14:08 +0000 (15:14 +0000)
src/libstat/backends/backends.h
src/libstat/backends/mmaped_file.c
src/libstat/stat_config.c
src/libstat/stat_process.c

index f8a2af72c074a63735adc7a162c837cc66e10bcd..e775faf6ed756fc4801f6c1887971a7138d3daa8 100644 (file)
@@ -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,
index 02ea17c288d993215ac455d09ba7ffa6d28320e0..2e57091496a46b6b4eb52bfc9b3c9da52e3356ed 100644 (file)
@@ -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);
+       }
+}
index 17b5c54f5862b48ef87d7493a46afa74c399a80b..8a05147216d5f05e7fcef7e275ec85bae222bb44 100644 (file)
@@ -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,
index 1ce439c51168995025d1bd7ae77c668b459c6dbc..511a9f8003889c49d449d977a342e82d6e43d9eb 100644 (file)
@@ -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);
                                        }
                                }