summaryrefslogtreecommitdiffstats
path: root/src/controller.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-11-12 20:38:20 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-11-12 20:38:20 +0300
commit092a40dcf813accb11a0b6bb600dccea0b35fb1d (patch)
treebc15b37adda2a21575799204dbc528874d2e82c2 /src/controller.c
parent1ad9f1f651ef3f0ee26d69007dd27e60f99f1f12 (diff)
downloadrspamd-092a40dcf813accb11a0b6bb600dccea0b35fb1d.tar.gz
rspamd-092a40dcf813accb11a0b6bb600dccea0b35fb1d.zip
* Write revision and revision time to statfile
* Make some improvements to API (trying to make it more clear)
Diffstat (limited to 'src/controller.c')
-rw-r--r--src/controller.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/controller.c b/src/controller.c
index 3b0179734..0b79813b3 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -385,6 +385,8 @@ controller_read_socket (f_str_t * in, void *arg)
{
struct controller_session *session = (struct controller_session *)arg;
struct classifier_ctx *cls_ctx;
+ stat_file_t *statfile;
+ struct statfile *st;
int len, i, r;
char *s, **params, *cmd, out_buf[128];
struct worker_task *task;
@@ -474,11 +476,27 @@ controller_read_socket (f_str_t * in, void *arg)
}
cur = g_list_next (cur);
}
+
+ /* Get or create statfile */
+ statfile = get_statfile_by_symbol (session->worker->srv->statfile_pool, session->learn_classifier,
+ session->learn_symbol, &st, TRUE);
+ if (statfile == NULL) {
+ free_task (task, FALSE);
+ i = snprintf (out_buf, sizeof (out_buf), "learn failed" CRLF);
+ if (!rspamd_dispatcher_write (session->dispatcher, out_buf, i, FALSE, FALSE)) {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /* Init classifier */
cls_ctx = session->learn_classifier->classifier->init_func (session->session_pool, session->learn_classifier);
- session->learn_classifier->classifier->learn_func (cls_ctx, session->worker->srv->statfile_pool, session->learn_symbol, tokens, session->in_class);
+
+ /* XXX: remove this awful legacy */
+ session->learn_classifier->classifier->learn_func (cls_ctx, session->worker->srv->statfile_pool, statfile, tokens, session->in_class);
session->worker->srv->stat->messages_learned++;
- maybe_write_binlog (session->learn_classifier, session->learn_symbol, tokens);
+ maybe_write_binlog (session->learn_classifier, st, statfile, tokens);
free_task (task, FALSE);
i = snprintf (out_buf, sizeof (out_buf), "learn ok" CRLF);