diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-08-05 21:29:40 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-08-05 21:29:40 +0400 |
commit | 5d0e4d334fef7f0fe683040d32e2a53b503315f2 (patch) | |
tree | d2f00bbb940564a4e77a287f84c7876e8fd9c009 /src/controller.c | |
parent | 80b5b55a53622875d4973ea1d440dc7fa916f20b (diff) | |
download | rspamd-5d0e4d334fef7f0fe683040d32e2a53b503315f2.tar.gz rspamd-5d0e4d334fef7f0fe683040d32e2a53b503315f2.zip |
* Fixes to winnow learning
Diffstat (limited to 'src/controller.c')
-rw-r--r-- | src/controller.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/controller.c b/src/controller.c index 6ef9f7e08..15b14cf8d 100644 --- a/src/controller.c +++ b/src/controller.c @@ -704,6 +704,7 @@ controller_read_socket (f_str_t * in, void *arg) struct mime_text_part *part; GList *comp_list, *cur = NULL; GTree *tokens = NULL; + GError *err = NULL; f_str_t c; double sum; @@ -818,26 +819,33 @@ controller_read_socket (f_str_t * in, void *arg) return TRUE; } + + /* Init classifier */ + cls_ctx = session->learn_classifier->classifier->init_func (session->session_pool, session->learn_classifier); /* 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) { - msg_info ("learn failed for message <%s>, no statfile found: %s", task->message_id, session->learn_symbol); + session->learn_symbol, &st, TRUE); + + if (statfile == NULL || + ! session->learn_classifier->classifier->learn_func (cls_ctx, session->worker->srv->statfile_pool, + session->learn_symbol, tokens, session->in_class, &sum, + session->learn_multiplier, &err)) { + if (err) { + i = rspamd_snprintf (out_buf, sizeof (out_buf), "learn failed, learn classifier error: %s" CRLF, err->message); + msg_info ("learn failed for message <%s>, learn error: %s", task->message_id, err->message); + g_error_free (err); + } + else { + i = rspamd_snprintf (out_buf, sizeof (out_buf), "learn failed, unknown learn classifier error" CRLF); + msg_info ("learn failed for message <%s>, unknown learn error", task->message_id); + } free_task (task, FALSE); - i = rspamd_snprintf (out_buf, sizeof (out_buf), "learn failed, invalid symbol" CRLF); if (!rspamd_dispatcher_write (session->dispatcher, out_buf, i, FALSE, FALSE)) { return FALSE; } + session->state = STATE_REPLY; return TRUE; } - - /* Init classifier */ - cls_ctx = session->learn_classifier->classifier->init_func (session->session_pool, session->learn_classifier); - - /* XXX: remove this awful legacy */ - session->learn_classifier->classifier->learn_func (cls_ctx, session->worker->srv->statfile_pool, - statfile, tokens, session->in_class, &sum, - session->learn_multiplier); session->worker->srv->stat->messages_learned++; maybe_write_binlog (session->learn_classifier, st, statfile, tokens); |