]> source.dussan.org Git - rspamd.git/commitdiff
Fix statfiles class determination euristic.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 18 Jul 2011 13:55:27 +0000 (17:55 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 18 Jul 2011 13:55:27 +0000 (17:55 +0400)
Fix call of classifier pre-callback.

src/cfg_utils.c
src/lua/lua_classifier.c

index a34084cceae87c02769ae99882a6764a850e9394..da1fe34a18e09fd3fc70b5b9cdcf3c877e4eb4e4 100644 (file)
@@ -1051,7 +1051,7 @@ gboolean
 check_classifier_statfiles (struct classifier_config *cf)
 {
        struct statfile                *st;
-       gboolean                        has_other = FALSE, cur_class;
+       gboolean                        has_other = FALSE, res = FALSE, cur_class;
        GList                          *cur;
 
        /* First check classes directly */
@@ -1093,14 +1093,14 @@ check_classifier_statfiles (struct classifier_config *cf)
                }
                else {
                        if (cur_class != st->is_spam) {
-                               return TRUE;
+                               res = TRUE;
                        }
                }
 
                cur = g_list_next (cur);
        }
 
-       return FALSE;
+       return res;
 }
 
 /*
index 901d6cff5f2849ef4911df467a976e6b997c890c..4e868b7f707ff4d515e58ee835c74ed0087e69a8 100644 (file)
@@ -81,8 +81,7 @@ call_classifier_pre_callback (struct classifier_config *ccf, struct worker_task
 {
        struct classifier_config      **pccf;
        struct worker_task            **ptask;
-       struct statfile                *st;
-       gint                            i, len;
+       struct statfile               **pst;
        GList                          *res = NULL;
 
        pccf = lua_newuserdata (L, sizeof (struct classifier_config *));
@@ -100,15 +99,16 @@ call_classifier_pre_callback (struct classifier_config *ccf, struct worker_task
                msg_warn ("error running pre classifier callback %s", lua_tostring (L, -1));
        }
        else {
-               if (lua_istable (L, 1)) {
-                       len = lua_objlen (L, 1);
-                       for (i = 1; i <= len; i ++) {
-                               lua_rawgeti (L, 1, i);
-                               st = lua_check_statfile (L);
-                               if (st) {
-                                       res = g_list_prepend (res, st);
+               if (lua_istable (L, -1)) {
+                       lua_pushnil (L);
+                       while(lua_next (L, -2)) {
+                               pst = luaL_checkudata (L, -1, "rspamd{statfile}");
+                               if (pst) {
+                                       res = g_list_prepend (res, *pst);
                                }
+                               lua_pop (L, 1);
                        }
+                       lua_pop (L, 1);
                }
        }