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);
+ gulong (*inc_learns)(struct rspamd_statfile_runtime *runtime, gpointer ctx);
gpointer ctx;
};
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,
+ gpointer ctx);
#endif /* BACKENDS_H_ */
return rev;
}
+
+gulong
+rspamd_mmaped_file_inc_learns (struct rspamd_statfile_runtime *runtime,
+ gpointer ctx)
+{
+ rspamd_mmaped_file_t *mf = (rspamd_mmaped_file_t *)runtime;
+ guint64 rev = 0;
+ time_t t;
+
+ if (mf != NULL) {
+ rspamd_mmaped_file_inc_revision (mf);
+ rspamd_mmaped_file_get_revision (mf, &rev, &t);
+ }
+
+ return rev;
+}
.init = rspamd_mmaped_file_init,
.runtime = rspamd_mmaped_file_runtime,
.process_token = rspamd_mmaped_file_process_token,
+ .learn_token = rspamd_mmaped_file_learn_token,
.total_learns = rspamd_mmaped_file_total_learns,
- .learn_token = rspamd_mmaped_file_learn_token
+ .inc_learns = rspamd_mmaped_file_inc_learns
}
};
struct rspamd_stat_ctx *st_ctx;
struct rspamd_tokenizer_runtime *tklist = NULL, *tok;
struct rspamd_classifier_runtime *cl_run;
+ struct rspamd_statfile_runtime *st_run;
struct classifier_ctx *cl_ctx;
struct preprocess_cb_data cbdata;
GList *cl_runtimes;
- GList *cur;
+ GList *cur, *curst;
gboolean ret = FALSE;
+ gulong nrev;
st_ctx = rspamd_stat_get_ctx ();
g_assert (st_ctx != NULL);
g_tree_foreach (cl_run->tok->tokens, rspamd_stat_learn_token,
&cbdata);
+ curst = g_list_first (cl_run->st_runtime);
+
+ while (curst) {
+ st_run = (struct rspamd_statfile_runtime *)curst->data;
+
+ nrev = st_run->backend->inc_learns (st_run->backend_runtime,
+ st_run->backend->ctx);
+
+ msg_debug ("learned %s, new revision: %ul",
+ st_run->st->symbol, nrev);
+
+ curst = g_list_next (curst);
+ }
}
else {
return FALSE;