diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-05-28 20:31:10 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-05-28 20:31:10 +0400 |
commit | ae3eb4dfd787052bebc732c3e37b56f0800e1aa2 (patch) | |
tree | 9ffbf987783e0802ed1c6b311e69b42beba0e142 /src/filter.c | |
parent | 0c72b8d2de2081e8b8605c86bba3f743387f981f (diff) | |
download | rspamd-ae3eb4dfd787052bebc732c3e37b56f0800e1aa2.tar.gz rspamd-ae3eb4dfd787052bebc732c3e37b56f0800e1aa2.zip |
* New symbols sorter:
- add ability to have dynamic rules inside items cache
- make 3 types of rules: negative, dynamic and static
- make logic of cache more simple by using glib lists instead of arrays
- do checks of symbols in more logically correct way (negative->dynamic->static)
Diffstat (limited to 'src/filter.c')
-rw-r--r-- | src/filter.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/filter.c b/src/filter.c index e2d6d80b8..0a18bd793 100644 --- a/src/filter.c +++ b/src/filter.c @@ -50,7 +50,7 @@ insert_result (struct worker_task *task, const char *metric_name, const char *sy struct metric_result *metric_res; struct symbol *s; struct cache_item *item; - int i; + GList *cur; metric = g_hash_table_lookup (task->worker->srv->cfg->metrics, metric_name); if (metric == NULL) { @@ -99,12 +99,25 @@ insert_result (struct worker_task *task, const char *metric_name, const char *sy /* Process cache item */ if (metric->cache) { - for (i = 0; i < metric->cache->used_items; i++) { - item = &metric->cache->items[i]; + cur = metric->cache->static_items; + while (cur) + { + item = cur->data; - if (flag > 0 && strcmp (item->s->symbol, symbol) == 0) { + if (strcmp (item->s->symbol, symbol) == 0) { item->s->frequency++; } + cur = g_list_next (cur); + } + cur = metric->cache->negative_items; + while (cur) + { + item = cur->data; + + if (strcmp (item->s->symbol, symbol) == 0) { + item->s->frequency++; + } + cur = g_list_next (cur); } } } @@ -272,7 +285,7 @@ static int continue_process_filters (struct worker_task *task) { GList *cur = task->save.entry; - struct cache_item *item = task->save.item; + gpointer item = task->save.item; struct metric *metric = cur->data; @@ -306,7 +319,7 @@ process_filters (struct worker_task *task) { GList *cur; struct metric *metric; - struct cache_item *item = NULL; + gpointer item = NULL; if (task->save.saved) { task->save.saved = 0; |