]> source.dussan.org Git - rspamd.git/commitdiff
Add `one_shot` attr to metric symbols.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 8 Oct 2014 23:54:39 +0000 (00:54 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 8 Oct 2014 23:54:39 +0000 (00:54 +0100)
src/libserver/cfg_file.h
src/libserver/cfg_rcl.c

index c08fe0c80079e7c87e6057fa65a7aa500d18e71b..9366b7718e3af8e4d2f77fc2a9b29dc80a264199 100644 (file)
@@ -119,6 +119,7 @@ struct rspamd_symbol_def {
        gchar *name;
        gchar *description;
        gdouble *weight_ptr;
+       gboolean one_shot;
 };
 
 /**
index 95510388350dc5404091c5899b337f9ec38bc0e5..750b7008736b88098a525d7791bcfdc6b8e32d93 100644 (file)
@@ -255,6 +255,7 @@ rspamd_rcl_insert_symbol (struct rspamd_config *cfg, struct metric *metric,
        struct rspamd_symbols_group *sym_group;
        struct rspamd_symbol_def *sym_def;
        GList *metric_list, *group_list;
+       gboolean one_shot = FALSE;
 
        /*
         * We allow two type of definitions:
@@ -264,6 +265,7 @@ rspamd_rcl_insert_symbol (struct rspamd_config *cfg, struct metric *metric,
         *      weight = ...;
         *      description = ...;
         *      group = ...;
+        *      one_shot = true/false;
         * }
         */
        if (is_legacy) {
@@ -298,6 +300,10 @@ rspamd_rcl_insert_symbol (struct rspamd_config *cfg, struct metric *metric,
                if (val != NULL) {
                        ucl_object_tostring_safe (val, &group);
                }
+               val = ucl_object_find_key (obj, "one_shot");
+               if (val != NULL) {
+                       one_shot = ucl_object_toboolean (val);
+               }
        }
        else {
                g_set_error (err,
@@ -316,8 +322,9 @@ rspamd_rcl_insert_symbol (struct rspamd_config *cfg, struct metric *metric,
        sym_def->weight_ptr = score_ptr;
        sym_def->name = rspamd_mempool_strdup (cfg->cfg_pool, sym_name);
        sym_def->description = (gchar *)description;
+       sym_def->one_shot = one_shot;
 
-       g_hash_table_insert (metric->symbols, sym_def->name, score_ptr);
+       g_hash_table_insert (metric->symbols, sym_def->name, sym_def);
 
        if ((metric_list =
                g_hash_table_lookup (cfg->metrics_symbols, sym_def->name)) == NULL) {