]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Fix conditional learning
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 30 Apr 2016 14:44:45 +0000 (15:44 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 30 Apr 2016 14:44:45 +0000 (15:44 +0100)
src/libstat/classifiers/bayes.c
src/libstat/stat_process.c

index 4e30f191e1e8a82e1da9d635dbd88536da3d79a0..5ebba8d56b7a705b64c66ac7282f3143bf1e6f3b 100644 (file)
@@ -274,6 +274,7 @@ bayes_classify (struct rspamd_classifier * ctx,
        }
 
        pprob = rspamd_mempool_alloc (task->task_pool, sizeof (*pprob));
+       *pprob = final_prob;
        rspamd_mempool_set_variable (task->task_pool, "bayes_prob", pprob, NULL);
 
        if (cl.processed_tokens > 0 && fabs (final_prob - 0.5) > 0.05) {
index dc00184295d3db7d23668373709f2f272f66b09f..1c8fbf070a818eb5578187b92402de6125b9d423 100644 (file)
@@ -484,6 +484,7 @@ rspamd_stat_classifiers_learn (struct rspamd_stat_ctx *st_ctx,
                while (cur) {
                        cb_ref = GPOINTER_TO_INT (cur->data);
 
+                       lua_settop (L, 0);
                        lua_rawgeti (L, LUA_REGISTRYINDEX, cb_ref);
                        /* Push task and two booleans: is_spam and is_unlearn */
                        ptask = lua_newuserdata (L, sizeof (*ptask));
@@ -509,7 +510,7 @@ rspamd_stat_classifiers_learn (struct rspamd_stat_ctx *st_ctx,
                                                }
 
                                                lua_settop (L, 0);
-                                               continue; /* Go to the next classifier */
+                                               break;
                                        }
                                }
                        }
@@ -518,6 +519,10 @@ rspamd_stat_classifiers_learn (struct rspamd_stat_ctx *st_ctx,
                        cur = g_list_next (cur);
                }
 
+               if (conditionally_skipped) {
+                       break;
+               }
+
                if (cl->subrs->learn_spam_func (cl, task->tokens, task, spam,
                                task->flags & RSPAMD_TASK_FLAG_UNLEARN, err)) {
                        learned = TRUE;