NBYTES (g_hash_table_size (task->cfg->composite_symbols) * 2));
/* Process hash table */
- g_hash_table_foreach (task->cfg->composite_symbols,
- composites_foreach_callback,
- cd);
+ rspamd_symcache_composites_foreach (task,
+ task->cfg->cache,
+ composites_foreach_callback,
+ cd);
/* Remove symbols that are in composites */
g_hash_table_foreach (cd->symbols_to_remove, composites_remove_symbols, cd);
#include "unix-std.h"
#include "contrib/t1ha/t1ha.h"
#include "libserver/worker_util.h"
+#include "khash.h"
#include <math.h>
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
ref_entry_t ref;
};
-struct rspamd_symcache {
- /* Hash table for fast access */
- GHashTable *items_by_symbol;
- GPtrArray *items_by_id;
- struct symcache_order *items_by_order;
- GPtrArray *filters;
- GPtrArray *prefilters;
- GPtrArray *postfilters;
- GPtrArray *composites;
- GPtrArray *idempotent;
- GPtrArray *virtual;
- GPtrArray *squeezed;
- GList *delayed_deps;
- GList *delayed_conditions;
- rspamd_mempool_t *static_pool;
- guint64 cksum;
- gdouble total_weight;
- guint used_items;
- guint stats_symbols_count;
- guint64 total_hits;
- guint id;
- struct rspamd_config *cfg;
- gdouble reload_time;
- gint peak_cb;
-};
-
-struct item_stat {
- struct rspamd_counter_data time_counter;
- gdouble avg_time;
- gdouble weight;
- guint hits;
- guint64 total_hits;
- struct rspamd_counter_data frequency_counter;
- gdouble avg_frequency;
- gdouble stddev_frequency;
-};
-
-struct rspamd_symcache_dynamic_item {
- guint16 start_msec; /* Relative to task time */
- unsigned started:1;
- unsigned finished:1;
- /* unsigned pad:14; */
- guint32 async_events;
-};
-
struct rspamd_symcache_item {
/* This block is likely shared */
struct item_stat *st;
GPtrArray *rdeps;
};
+struct item_stat {
+ struct rspamd_counter_data time_counter;
+ gdouble avg_time;
+ gdouble weight;
+ guint hits;
+ guint64 total_hits;
+ struct rspamd_counter_data frequency_counter;
+ gdouble avg_frequency;
+ gdouble stddev_frequency;
+};
+
+struct rspamd_symcache {
+ /* Hash table for fast access */
+ GHashTable *items_by_symbol;
+ GPtrArray *items_by_id;
+ struct symcache_order *items_by_order;
+ GPtrArray *filters;
+ GPtrArray *prefilters;
+ GPtrArray *postfilters;
+ GPtrArray *composites;
+ GPtrArray *idempotent;
+ GPtrArray *virtual;
+ GPtrArray *squeezed;
+ GList *delayed_deps;
+ GList *delayed_conditions;
+ rspamd_mempool_t *static_pool;
+ guint64 cksum;
+ gdouble total_weight;
+ guint used_items;
+ guint stats_symbols_count;
+ guint64 total_hits;
+ guint id;
+ struct rspamd_config *cfg;
+ gdouble reload_time;
+ gint peak_cb;
+};
+
+struct rspamd_symcache_dynamic_item {
+ guint16 start_msec; /* Relative to task time */
+ unsigned started:1;
+ unsigned finished:1;
+ /* unsigned pad:14; */
+ guint32 async_events;
+};
+
+
+
struct cache_dependency {
struct rspamd_symcache_item *item;
gchar *sym;
}
return 0;
+}
+
+void
+rspamd_symcache_composites_foreach (struct rspamd_task *task,
+ struct rspamd_symcache *cache,
+ GHFunc func,
+ gpointer fd)
+{
+ guint i;
+ struct rspamd_symcache_item *item;
+ struct rspamd_symcache_dynamic_item *dyn_item;
+
+ PTR_ARRAY_FOREACH (cache->composites, i, item) {
+ dyn_item = rspamd_symcache_get_dynamic (task->checkpoint, item);
+
+ if (!CHECK_START_BIT (task->checkpoint, dyn_item)) {
+ SET_START_BIT (task->checkpoint, dyn_item);
+ func (item->symbol, item->specific.normal.user_data, fd);
+ SET_FINISH_BIT (task->checkpoint, dyn_item);
+ }
+ }
}
\ No newline at end of file