aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/cfg_utils.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-08-13 15:28:07 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-08-13 15:28:07 +0100
commit6f70b5767167f3414ee7c84346e84f32ebfeaf38 (patch)
tree1448f57c9730837667f5da5f037832b970e17993 /src/libserver/cfg_utils.c
parent7a1cfea11cf27eea852be68b2373b233e650f689 (diff)
downloadrspamd-6f70b5767167f3414ee7c84346e84f32ebfeaf38.tar.gz
rspamd-6f70b5767167f3414ee7c84346e84f32ebfeaf38.zip
More fixes for the new symbols structure.
Diffstat (limited to 'src/libserver/cfg_utils.c')
-rw-r--r--src/libserver/cfg_utils.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index fcf5b4fd9..5d8e261b9 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -574,6 +574,24 @@ rspamd_config_new_metric (struct rspamd_config *cfg, struct metric *c,
return c;
}
+struct rspamd_symbols_group *
+rspamd_config_new_group (struct rspamd_config *cfg, struct metric *metric,
+ const gchar *name)
+{
+ struct rspamd_symbols_group *gr;
+
+ gr = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (*gr));
+ gr->symbols = g_hash_table_new (rspamd_strcase_hash,
+ rspamd_strcase_equal);
+ rspamd_mempool_add_destructor (cfg->cfg_pool,
+ (rspamd_mempool_destruct_t)g_hash_table_unref, gr->symbols);
+ gr->name = rspamd_mempool_strdup (cfg->cfg_pool, name);
+
+ g_hash_table_insert (metric->groups, gr->name, gr);
+
+ return gr;
+}
+
struct rspamd_worker_conf *
rspamd_config_new_worker (struct rspamd_config *cfg,
struct rspamd_worker_conf *c)
@@ -971,6 +989,7 @@ rspamd_config_add_metric_symbol (struct rspamd_config *cfg,
score_ptr = rspamd_mempool_alloc (cfg->cfg_pool, sizeof (gdouble));
*score_ptr = score;
+ sym_def->score = score;
sym_def->weight_ptr = score_ptr;
sym_def->name = rspamd_mempool_strdup (cfg->cfg_pool, symbol);
sym_def->one_shot = one_shot;
@@ -1007,12 +1026,7 @@ rspamd_config_add_metric_symbol (struct rspamd_config *cfg,
sym_group = g_hash_table_lookup (metric->groups, group);
if (sym_group == NULL) {
/* Create new group */
- sym_group =
- rspamd_mempool_alloc0 (cfg->cfg_pool,
- sizeof (struct rspamd_symbols_group));
- sym_group->name = rspamd_mempool_strdup (cfg->cfg_pool, group);
- sym_group->symbols = NULL;
- g_hash_table_insert (metric->groups, sym_group->name, sym_group);
+ sym_group = rspamd_config_new_group (cfg, metric, group);
}
sym_def->gr = sym_group;