diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-09-22 21:03:07 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-09-22 21:03:07 +0100 |
commit | fcbf12d1ac04074bb148104d3485148645982328 (patch) | |
tree | a5520039d6744f890f5537ee8955f9f93bebcbd8 /src/libmime | |
parent | 460c4fad7efffafe99f7ac74ddd3e6950c4c744e (diff) | |
download | rspamd-fcbf12d1ac04074bb148104d3485148645982328.tar.gz rspamd-fcbf12d1ac04074bb148104d3485148645982328.zip |
Add default metric results prior to message processing.
Diffstat (limited to 'src/libmime')
-rw-r--r-- | src/libmime/filter.c | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/src/libmime/filter.c b/src/libmime/filter.c index 61f7c0cbc..bdddffb59 100644 --- a/src/libmime/filter.c +++ b/src/libmime/filter.c @@ -62,6 +62,35 @@ filter_error_quark (void) return g_quark_from_static_string ("g-filter-error-quark"); } +static struct metric_result * +create_metric_result (struct rspamd_task *task, const gchar *name) +{ + struct metric_result *metric_res; + struct metric *metric; + + metric = g_hash_table_lookup (task->cfg->metrics, name); + if (metric == NULL) { + return NULL; + } + + metric_res = + rspamd_mempool_alloc (task->task_pool, + sizeof (struct metric_result)); + metric_res->symbols = g_hash_table_new (rspamd_str_hash, + rspamd_str_equal); + metric_res->checked = FALSE; + rspamd_mempool_add_destructor (task->task_pool, + (rspamd_mempool_destruct_t) g_hash_table_unref, + metric_res->symbols); + metric_res->metric = metric; + metric_res->grow_factor = 0; + metric_res->score = 0; + g_hash_table_insert (task->results, (gpointer) metric->name, + metric_res); + + return metric_res; +} + static void insert_metric_result (struct rspamd_task *task, struct metric *metric, @@ -79,20 +108,7 @@ insert_metric_result (struct rspamd_task *task, if (metric_res == NULL) { /* Create new metric chain */ - metric_res = - rspamd_mempool_alloc (task->task_pool, - sizeof (struct metric_result)); - metric_res->symbols = g_hash_table_new (rspamd_str_hash, - rspamd_str_equal); - metric_res->checked = FALSE; - rspamd_mempool_add_destructor (task->task_pool, - (rspamd_mempool_destruct_t) g_hash_table_unref, - metric_res->symbols); - metric_res->metric = metric; - metric_res->grow_factor = 0; - metric_res->score = 0; - g_hash_table_insert (task->results, (gpointer) metric->name, - metric_res); + metric_res = create_metric_result (task, metric->name); } weight = g_hash_table_lookup (metric->symbols, symbol); @@ -335,6 +351,8 @@ process_filters (struct rspamd_task *task) struct metric *metric; gpointer item = NULL; + /* Insert default metric to be sure that it exists all the time */ + create_metric_result (task, DEFAULT_METRIC); if (task->settings) { const ucl_object_t *wl; |