summaryrefslogtreecommitdiffstats
path: root/src/libserver/symbols_cache.c
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 /src/libserver/symbols_cache.c
parentcdef5507e20992b5fe08e3655620e6690d887dc7 (diff)
downloadrspamd-aef19db4a81bcc40db2047c1c540f09f07fc9fd1.tar.gz
rspamd-aef19db4a81bcc40db2047c1c540f09f07fc9fd1.zip
Remove weight definition from symbols cache.
Diffstat (limited to 'src/libserver/symbols_cache.c')
-rw-r--r--src/libserver/symbols_cache.c96
1 files changed, 8 insertions, 88 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;
}
}