aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-08-12 16:59:35 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-08-12 16:59:35 +0100
commitaef19db4a81bcc40db2047c1c540f09f07fc9fd1 (patch)
treea22145cafd5a39acc3c93d5f4592a0c7288a0cce
parentcdef5507e20992b5fe08e3655620e6690d887dc7 (diff)
downloadrspamd-aef19db4a81bcc40db2047c1c540f09f07fc9fd1.tar.gz
rspamd-aef19db4a81bcc40db2047c1c540f09f07fc9fd1.zip
Remove weight definition from symbols cache.
-rw-r--r--src/libserver/symbols_cache.c96
-rw-r--r--src/libserver/symbols_cache.h61
2 files changed, 15 insertions, 142 deletions
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index 6e97dbd38..0cc285094 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -80,7 +80,6 @@ struct cache_item {
/* Priority */
gint priority;
gint id;
- gdouble metric_weight;
/* Dependencies */
GPtrArray *deps;
@@ -332,6 +331,11 @@ rspamd_symbols_cache_load_items (struct symbols_cache *cache, const gchar *name)
if (item) {
/* Copy saved info */
+ /*
+ * XXX: don't save or load weight, it should be obtained from the
+ * metric
+ */
+#if 0
elt = ucl_object_find_key (cur, "weight");
if (elt) {
@@ -340,7 +344,7 @@ rspamd_symbols_cache_load_items (struct symbols_cache *cache, const gchar *name)
item->weight = w;
}
}
-
+#endif
elt = ucl_object_find_key (cur, "time");
if (elt) {
item->avg_time = ucl_object_todouble (elt);
@@ -447,7 +451,6 @@ rspamd_symbols_cache_save_items (struct symbols_cache *cache, const gchar *name)
gint
rspamd_symbols_cache_add_symbol (struct symbols_cache *cache,
const gchar *name,
- double weight,
gint priority,
symbol_func_t func,
gpointer user_data,
@@ -490,9 +493,8 @@ rspamd_symbols_cache_add_symbol (struct symbols_cache *cache,
item->user_data = user_data;
item->priority = priority;
item->type = type;
- item->weight = weight;
- if (item->weight < 0 && item->priority == 0) {
+ if ((type & SYMBOL_TYPE_FINE) && item->priority == 0) {
/* Make priority for negative weighted symbols */
item->priority = 1;
}
@@ -518,69 +520,6 @@ rspamd_symbols_cache_add_symbol (struct symbols_cache *cache,
return item->id;
}
-gint
-rspamd_symbols_cache_add_symbol_normal (struct symbols_cache *cache,
- const gchar *name, double weight,
- symbol_func_t func, gpointer user_data)
-{
- return rspamd_symbols_cache_add_symbol (cache,
- name,
- weight,
- 0,
- func,
- user_data,
- SYMBOL_TYPE_NORMAL,
- -1);
-}
-
-gint
-rspamd_symbols_cache_add_symbol_virtual (struct symbols_cache *cache,
- const gchar *name,
- double weight,
- gint parent)
-{
- return rspamd_symbols_cache_add_symbol (cache,
- name,
- weight,
- 0,
- NULL,
- NULL,
- SYMBOL_TYPE_VIRTUAL,
- parent);
-}
-
-gint
-rspamd_symbols_cache_add_symbol_callback (struct symbols_cache *cache,
- double weight,
- symbol_func_t func,
- gpointer user_data)
-{
- return rspamd_symbols_cache_add_symbol (cache,
- NULL,
- weight,
- 0,
- func,
- user_data,
- SYMBOL_TYPE_CALLBACK,
- -1);
-}
-
-gint
-rspamd_symbols_cache_add_symbol_callback_prio (struct symbols_cache *cache,
- double weight,
- gint priority,
- symbol_func_t func,
- gpointer user_data)
-{
- return rspamd_symbols_cache_add_symbol (cache,
- NULL,
- weight,
- priority,
- func,
- user_data,
- SYMBOL_TYPE_CALLBACK,
- -1);
-}
void
rspamd_symbols_cache_destroy (struct symbols_cache *cache)
@@ -662,21 +601,6 @@ rspamd_symbols_cache_init (struct symbols_cache* cache,
return res;
}
-static gboolean
-check_debug_symbol (struct rspamd_config *cfg, const gchar *symbol)
-{
- GList *cur;
-
- cur = cfg->debug_symbols;
- while (cur) {
- if (strcmp (symbol, (const gchar *)cur->data) == 0) {
- return TRUE;
- }
- cur = g_list_next (cur);
- }
-
- return FALSE;
-}
static void
rspamd_symbols_cache_validate_cb (gpointer k, gpointer v, gpointer ud)
@@ -776,11 +700,7 @@ rspamd_symbols_cache_metric_validate_cb (gpointer k, gpointer v, gpointer ud)
item = g_hash_table_lookup (cache->items_by_symbol, sym);
if (item) {
- item->metric_weight = weight;
-
- if (fabs (item->weight) < fabs (weight) || weight < 0) {
- item->weight = weight;
- }
+ item->weight = weight;
}
}
diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h
index 7dd33ad8f..bc3386eba 100644
--- a/src/libserver/symbols_cache.h
+++ b/src/libserver/symbols_cache.h
@@ -37,12 +37,13 @@ struct symbols_cache;
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_GHOST,
- SYMBOL_TYPE_SKIPPED,
- SYMBOL_TYPE_COMPOSITE
+ SYMBOL_TYPE_NORMAL = (1 << 0),
+ SYMBOL_TYPE_VIRTUAL = (1 << 1),
+ SYMBOL_TYPE_CALLBACK = (1 << 2),
+ SYMBOL_TYPE_GHOST = (1 << 3),
+ SYMBOL_TYPE_SKIPPED = (1 << 4),
+ SYMBOL_TYPE_COMPOSITE = (1 << 5),
+ SYMBOL_TYPE_FINE = (1 << 6)
};
/**
@@ -64,53 +65,6 @@ gboolean rspamd_symbols_cache_init (struct symbols_cache* cache,
struct rspamd_config *cfg);
/**
- * Register function for symbols parsing
- * @param name name of symbol
- * @param func pointer to handler
- * @param user_data pointer to user_data
- */
-gint rspamd_symbols_cache_add_symbol_normal (struct symbols_cache *cache,
- const gchar *name,
- double weight,
- symbol_func_t func,
- gpointer user_data);
-
-
-/**
- * Register virtual symbol
- * @param name name of symbol
- * @param weight initial weight
- * @param parent associated callback parent
- */
-gint rspamd_symbols_cache_add_symbol_virtual (struct symbols_cache *cache,
- const gchar *name,
- double weight,
- gint parent);
-
-/**
- * Register callback function for symbols parsing
- * @param name name of symbol
- * @param func pointer to handler
- * @param user_data pointer to user_data
- */
-gint rspamd_symbols_cache_add_symbol_callback (struct symbols_cache *cache,
- double weight,
- symbol_func_t func,
- gpointer user_data);
-
-/**
- * Register function for symbols parsing with strict priority
- * @param name name of symbol
- * @param func pointer to handler
- * @param user_data pointer to user_data
- */
-gint rspamd_symbols_cache_add_symbol_callback_prio (struct symbols_cache *cache,
- double weight,
- gint priority,
- symbol_func_t func,
- gpointer user_data);
-
-/**
* Generic function to register a symbol
* @param cache
* @param name
@@ -123,7 +77,6 @@ gint rspamd_symbols_cache_add_symbol_callback_prio (struct symbols_cache *cache,
*/
gint rspamd_symbols_cache_add_symbol (struct symbols_cache *cache,
const gchar *name,
- double weight,
gint priority,
symbol_func_t func,
gpointer user_data,