]> source.dussan.org Git - rspamd.git/commitdiff
Set error if cannot learn anything.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 22 Jul 2015 16:12:26 +0000 (17:12 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 22 Jul 2015 16:17:51 +0000 (17:17 +0100)
src/libstat/stat_process.c

index 6fbc824138b1bcf9f193873a8cd967ea55b2b6e3..4e76421373c0a29421dd8400d1bdf11fda362d80 100644 (file)
@@ -345,7 +345,7 @@ rspamd_stat_classify (struct rspamd_task *task, lua_State *L, GError **err)
        struct classifier_ctx *cl_ctx;
        GList *cl_runtimes;
        GList *cur;
-       gboolean ret = RSPAMD_STAT_PROCESS_ERROR, compat = TRUE;
+       gboolean ret = RSPAMD_STAT_PROCESS_OK, compat = TRUE;
        const ucl_object_t *obj;
 
        st_ctx = rspamd_stat_get_ctx ();
@@ -513,7 +513,7 @@ rspamd_stat_learn (struct rspamd_task *task, gboolean spam, lua_State *L,
        gulong nrev;
        rspamd_learn_t learn_res = RSPAMD_LEARN_OK;
        guint i;
-       gboolean compat = TRUE;
+       gboolean compat = TRUE, learned = FALSE;
 
        st_ctx = rspamd_stat_get_ctx ();
        g_assert (st_ctx != NULL);
@@ -588,6 +588,7 @@ rspamd_stat_learn (struct rspamd_task *task, gboolean spam, lua_State *L,
                                        msg_debug ("learned %s classifier %s", spam ? "spam" : "ham",
                                                        cl_run->clcf->name);
                                        ret = RSPAMD_STAT_PROCESS_OK;
+                                       learned = TRUE;
 
                                        cbdata.classifier_runtimes = cur;
                                        cbdata.task = task;
@@ -631,6 +632,11 @@ rspamd_stat_learn (struct rspamd_task *task, gboolean spam, lua_State *L,
                cur = g_list_next (cur);
        }
 
+       if (!learned) {
+               g_set_error (err, rspamd_stat_quark (), 500, "message cannot be learned"
+                               " for any classifier defined");
+       }
+
        return ret;
 }