]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix symbols registration and execution
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 12 Jul 2016 16:22:18 +0000 (17:22 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 12 Jul 2016 16:22:18 +0000 (17:22 +0100)
src/libserver/symbols_cache.c
src/lua/lua_config.c

index 4bed6ad3aa7c4c3b239b5017d641b1eb9589fd10..f74982ff62692761af39af9c05104150f4d8e530 100644 (file)
@@ -1125,7 +1125,7 @@ rspamd_symbols_cache_check_symbol (struct rspamd_task *task,
        gboolean check = TRUE;
        const gdouble slow_diff_limit = 1e5;
 
-       if (item->type & (SYMBOL_TYPE_NORMAL|SYMBOL_TYPE_CALLBACK)) {
+       if (item->func) {
 
                g_assert (item->func != NULL);
                /* Check has been started */
index d16c645a681f485180db8e558e4e3a8b2701111c..ee6ab3ef757b6ee44009fc042bce7ce417a888fc 100644 (file)
@@ -783,13 +783,24 @@ rspamd_register_symbol_fromlua (lua_State *L,
                }
        }
 
-       ret = rspamd_symbols_cache_add_symbol (cfg->cache,
-                       name,
-                       priority,
-                       lua_metric_symbol_callback,
-                       cd,
-                       type,
-                       parent);
+       if (ref != -1) {
+               ret = rspamd_symbols_cache_add_symbol (cfg->cache,
+                               name,
+                               priority,
+                               lua_metric_symbol_callback,
+                               cd,
+                               type,
+                               parent);
+       }
+       else {
+               ret = rspamd_symbols_cache_add_symbol (cfg->cache,
+                               name,
+                               priority,
+                               NULL,
+                               cd,
+                               type,
+                               parent);
+       }
        rspamd_mempool_add_destructor (cfg->cfg_pool,
                        (rspamd_mempool_destruct_t)lua_destroy_cfg_symbol,
                        cd);
@@ -924,10 +935,10 @@ lua_parse_symbol_type (const gchar *str)
                        ret = SYMBOL_TYPE_NORMAL;
                }
                else if (strcmp (str, "prefilter") == 0) {
-                       ret = SYMBOL_TYPE_PREFILTER;
+                       ret = SYMBOL_TYPE_PREFILTER|SYMBOL_TYPE_GHOST;
                }
                else if (strcmp (str, "postfilter") == 0) {
-                       ret = SYMBOL_TYPE_POSTFILTER;
+                       ret = SYMBOL_TYPE_POSTFILTER|SYMBOL_TYPE_GHOST;
                }
                else {
                        msg_warn ("bad type: %s", str);