]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Rework structure.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 26 May 2015 17:17:35 +0000 (18:17 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 26 May 2015 17:17:35 +0000 (18:17 +0100)
src/libserver/symbols_cache.c
src/libserver/symbols_cache.h

index d673ee017f80f37224db6732e5c527117304a6ce..8d37a9ead709b7638a8d385b19c012356e6d8e32 100644 (file)
@@ -50,71 +50,42 @@ struct rspamd_symbols_cache_header {
 };
 
 struct symbols_cache {
-       /* Normal cache items */
-       GList *static_items;
-
-       /* Items that have negative weights */
-       GList *negative_items;
-
        /* Hash table for fast access */
        GHashTable *items_by_symbol;
-
        rspamd_mempool_t *static_pool;
-
        guint cur_items;
        guint used_items;
        guint uses;
-       gpointer map;
        struct rspamd_config *cfg;
 };
 
-struct saved_cache_item {
-       gchar symbol[MAX_SYMBOL];
-       double weight;
-       guint32 frequency;
-       double avg_time;
-};
-
-struct dynamic_map_item {
-       struct in_addr addr;
-       guint32 mask;
-       gboolean negative;
-};
-
 struct counter_data {
        gdouble value;
        gint number;
 };
 
 struct cache_item {
-       /* Static item's data */
-       struct saved_cache_item *s;
-       struct counter_data *cd;
+       /* This block is likely shared */
+       gdouble avg_time;
        gdouble weight;
        guint32 frequency;
-       gdouble avg_time;
-
-       rspamd_mempool_mutex_t *mtx;
-
-       /* For dynamic rules */
-       struct dynamic_map_item *networks;
-       guint32 networks_number;
-       gboolean is_dynamic;
 
-       gboolean is_skipped;
+       /* Static item's data */
+       struct counter_data *cd;
+       enum rspamd_symbol_type type;
 
        /* Callback data */
        symbol_func_t func;
        gpointer user_data;
 
-       /* Flags of virtual symbols */
-       gboolean is_virtual;
-       gboolean is_callback;
-       gboolean is_ghost;
-
+       /* Parent symbol id for virtual symbols */
+       gint parent;
        /* Priority */
        gint priority;
+       gint id;
        gdouble metric_weight;
+
+       rspamd_mempool_mutex_t *mtx;
 };
 
 gint
index 2a7bc86242ee6ac8c1c5d74520d951cbe568d82b..41237df83682f5f681e6e79ba9628c5a0cee49b5 100644 (file)
@@ -38,7 +38,8 @@ typedef void (*symbol_func_t)(struct rspamd_task *task, gpointer user_data);
 enum rspamd_symbol_type {
        SYMBOL_TYPE_NORMAL,
        SYMBOL_TYPE_VIRTUAL,
-       SYMBOL_TYPE_CALLBACK
+       SYMBOL_TYPE_CALLBACK,
+       SYMBOL_TYPE_GHOST
 };
 
 /**