]> source.dussan.org Git - rspamd.git/commitdiff
Add the concept of ghost symbols.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 17 Feb 2015 13:20:32 +0000 (13:20 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 17 Feb 2015 13:20:32 +0000 (13:20 +0000)
src/libserver/symbols_cache.c
src/libserver/symbols_cache.h

index 5f6a2cd728a13a55dc07c458699f287867b2029c..0ecd6e6e855fd25429fc11eb69eea4fe662a1701 100644 (file)
@@ -316,7 +316,7 @@ register_symbol_common (struct symbols_cache **cache,
        GList **target, *cur;
        struct metric *m;
        struct rspamd_symbol_def *s;
-       gboolean skipped;
+       gboolean skipped, ghost = (weight == 0.0);
 
        if (*cache == NULL) {
                pcache = g_new0 (struct symbols_cache, 1);
@@ -365,7 +365,7 @@ register_symbol_common (struct symbols_cache **cache,
        }
 
        /* Check whether this item is skipped */
-       skipped = TRUE;
+       skipped = !ghost;
        if (!item->is_callback && pcache->cfg &&
                        g_hash_table_lookup (pcache->cfg->metrics_symbols, name) == NULL) {
                cur = g_list_first (pcache->cfg->metrics_list);
@@ -401,14 +401,21 @@ register_symbol_common (struct symbols_cache **cache,
        }
 
        item->is_skipped = skipped;
+       item->is_ghost = ghost;
+
        if (skipped) {
                msg_warn ("symbol %s is not registered in any metric, so skip its check",
                                name);
        }
 
+       if (ghost) {
+               msg_debug ("symbol %s is registered as ghost symbol, it won't be inserted "
+                               "to any metric", name);
+       }
+
        /* If we have undefined priority determine list according to weight */
        if (priority == 0) {
-               if (item->s->weight > 0) {
+               if (item->s->weight >= 0) {
                        target = &(*cache)->static_items;
                }
                else {
index d2694fd047c880272b32519517200f92fa357396..3baf749ab5b11466a3e2a7b5f4e7767cab02c601 100644 (file)
@@ -50,6 +50,7 @@ struct cache_item {
        /* Flags of virtual symbols */
        gboolean is_virtual;
        gboolean is_callback;
+       gboolean is_ghost;
 
        /* Priority */
        gint priority;