]> source.dussan.org Git - rspamd.git/commitdiff
Ignore order of symbols when calculating checksum.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 20 Nov 2013 00:44:02 +0000 (00:44 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 20 Nov 2013 00:44:02 +0000 (00:44 +0000)
src/symbols_cache.c

index b273ea1c950def9f8c32286857f94c32daab3a0c..c60554f8f3e877814195d8d741919a3a536f2197 100644 (file)
@@ -31,7 +31,7 @@
 #include "cfg_file.h"
 
 #define WEIGHT_MULT 2.0
-#define FREQUENCY_MULT 100.0
+#define FREQUENCY_MULT 10.0
 #define TIME_MULT -1.0
 
 /* After which number of messages try to resort cache */
@@ -81,12 +81,14 @@ static GChecksum               *
 get_mem_cksum (struct symbols_cache *cache)
 {
        GChecksum                      *result;
-       GList                          *cur;
+       GList                          *cur, *l;
        struct cache_item              *item;
 
        result = g_checksum_new (G_CHECKSUM_SHA1);
 
-       cur = g_list_first (cache->negative_items);
+       l = g_list_copy (cache->negative_items);
+       l = g_list_sort (l, cache_cmp);
+       cur = g_list_first (l);
        while (cur) {
                item = cur->data;
                if (item->s->symbol[0] != '\0') {
@@ -94,7 +96,12 @@ get_mem_cksum (struct symbols_cache *cache)
                }
                cur = g_list_next (cur);
        }
-       cur = g_list_first (cache->static_items);
+       g_list_free (l);
+
+
+       l = g_list_copy (cache->static_items);
+       l = g_list_sort (l, cache_cmp);
+       cur = g_list_first (l);
        while (cur) {
                item = cur->data;
                if (item->s->symbol[0] != '\0') {
@@ -103,6 +110,7 @@ get_mem_cksum (struct symbols_cache *cache)
                total_frequency += item->s->frequency;
                cur = g_list_next (cur);
        }
+       g_list_free (l);
 
        return result;
 }