aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/symbols_cache.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-29 14:53:12 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-29 14:53:12 +0000
commitb7dd1410aee70091302217f1455ad88dea16945c (patch)
treedd9f9a3b10aa59040930066140a48ab5bc6328d3 /src/libserver/symbols_cache.c
parent24c8b7263292318b70f858c6f33d7e452462581d (diff)
downloadrspamd-b7dd1410aee70091302217f1455ad88dea16945c.tar.gz
rspamd-b7dd1410aee70091302217f1455ad88dea16945c.zip
[Fix] Fix sorting order for symbols cache
Diffstat (limited to 'src/libserver/symbols_cache.c')
-rw-r--r--src/libserver/symbols_cache.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index 0e270f499..927842ac2 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -200,8 +200,11 @@ cache_logic_cmp (const void *p1, const void *p2, gpointer ud)
if (i1->deps->len != 0 || i2->deps->len != 0) {
/* TODO: handle complex dependencies */
- w1 = -(i1->deps->len);
- w2 = -(i2->deps->len);
+ w1 = 1.0 / (i1->deps->len);
+ w2 = 1.0 / (i2->deps->len);
+ msg_debug_cache ("deps length: %s -> %.2f, %s -> %.2f",
+ i1->symbol, w1 * 1000.0,
+ i2->symbol, w2 * 1000.0);
}
else if (i1->priority == i2->priority) {
f1 = (double)i1->frequency / (double)cache->total_freq;
@@ -212,14 +215,16 @@ cache_logic_cmp (const void *p1, const void *p2, gpointer ud)
t2 = i2->avg_time;
w1 = SCORE_FUN (weight1, f1, t1);
w2 = SCORE_FUN (weight2, f2, t2);
- msg_debug_cache ("%s -> %.2f, %s -> %.2f", i1->symbol, w1 * 1000.0,
+ msg_debug_cache ("%s -> %.2f, %s -> %.2f",
+ i1->symbol, w1 * 1000.0,
i2->symbol, w2 * 1000.0);
}
else {
/* Strict sorting */
w1 = abs (i1->priority);
w2 = abs (i2->priority);
- msg_debug_cache ("priority: %s -> %.2f, %s -> %.2f", i1->symbol, w1 * 1000.0,
+ msg_debug_cache ("priority: %s -> %.2f, %s -> %.2f",
+ i1->symbol, w1 * 1000.0,
i2->symbol, w2 * 1000.0);
}