#include "cfg_file.h"
#include "lua/lua_common.h"
#include "unix-std.h"
+#include "contrib/t1ha/t1ha.h"
#include <math.h>
#define msg_err_cache(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \
GList *delayed_deps;
GList *delayed_conditions;
rspamd_mempool_t *static_pool;
+ guint64 cksum;
gdouble total_weight;
guint used_items;
gdouble total_freq;
*/
item->cd = rspamd_mempool_alloc0 (cache->static_pool,
sizeof (struct counter_data));
-
- if (name != NULL) {
- item->symbol = rspamd_mempool_strdup (cache->static_pool, name);
- }
-
item->func = func;
item->user_data = user_data;
item->priority = priority;
item->id = cache->used_items;
item->parent = parent;
cache->used_items ++;
- msg_debug_cache ("used items: %d, added symbol: %s", cache->used_items, name);
+
+ if (name != NULL) {
+ item->symbol = rspamd_mempool_strdup (cache->static_pool, name);
+ msg_debug_cache ("used items: %d, added symbol: %s, %d",
+ cache->used_items, name, item->id);
+ cache->cksum = t1ha (item->symbol, strlen (item->symbol),
+ cache->cksum);
+ }
+ else {
+ msg_debug_cache ("used items: %d, added unnamed symbol: %d",
+ cache->used_items, item->id);
+ cache->cksum = t1ha (&item->id, sizeof (item->id),
+ cache->cksum);
+ }
+
rspamd_set_counter (item, 0);
g_ptr_array_add (cache->items_by_id, item);
item->deps = g_ptr_array_new ();
cache->total_freq = 1;
cache->total_weight = 1.0;
cache->cfg = cfg;
+ cache->cksum = 0xdeadbabe;
return cache;
}