summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cfg_utils.c2
-rw-r--r--src/cfg_xml.c7
-rw-r--r--src/lua/lua_classifier.c19
3 files changed, 19 insertions, 9 deletions
diff --git a/src/cfg_utils.c b/src/cfg_utils.c
index 440fb65e6..1576cb9fb 100644
--- a/src/cfg_utils.c
+++ b/src/cfg_utils.c
@@ -827,7 +827,7 @@ check_classifier_conf (struct config_file *cfg, struct classifier_config *c)
memory_pool_add_destructor (cfg->cfg_pool, (pool_destruct_func) g_hash_table_destroy, c->opts);
}
if (c->labels == NULL) {
- c->labels = g_hash_table_new (g_str_hash, g_str_equal);
+ c->labels = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify)g_list_free);
memory_pool_add_destructor (cfg->cfg_pool, (pool_destruct_func) g_hash_table_destroy, c->labels);
}
diff --git a/src/cfg_xml.c b/src/cfg_xml.c
index bcec06c1d..60bfbf96f 100644
--- a/src/cfg_xml.c
+++ b/src/cfg_xml.c
@@ -1907,6 +1907,7 @@ rspamd_xml_end_element (GMarkupParseContext *context, const gchar *element_name,
gpointer tptr;
struct wrk_cbdata wcd;
struct xml_subparser *subparser;
+ GList *labels;
if (g_ascii_strcasecmp (element_name, "if") == 0) {
tptr = g_queue_pop_head (ud->if_stack);
@@ -1962,11 +1963,11 @@ rspamd_xml_end_element (GMarkupParseContext *context, const gchar *element_name,
ud->cfg->statfiles = g_list_prepend (ud->cfg->statfiles, st);
g_hash_table_insert (ud->cfg->classifiers_symbols, st->symbol, ccf);
if (st->label) {
- if (g_hash_table_lookup (ccf->labels, st->label)) {
- msg_warn ("duplicate statfile label %s with symbol %s, ignoring", st->label, st->symbol);
+ if ((labels = g_hash_table_lookup (ccf->labels, st->label))) {
+ labels = g_list_append (labels, st);
}
else {
- g_hash_table_insert (ccf->labels, st->label, st);
+ g_hash_table_insert (ccf->labels, st->label, g_list_prepend (NULL, st));
}
}
ud->section_pointer = ccf;
diff --git a/src/lua/lua_classifier.c b/src/lua/lua_classifier.c
index c6eb2cf18..be18cda0d 100644
--- a/src/lua/lua_classifier.c
+++ b/src/lua/lua_classifier.c
@@ -278,14 +278,23 @@ lua_classifier_get_statfile_by_label (lua_State *L)
struct classifier_config *ccf = lua_check_classifier (L);
struct statfile *st, **pst;
const gchar *label;
+ GList *cur;
+ gint i;
label = luaL_checkstring (L, 2);
if (ccf && label) {
- st = g_hash_table_lookup (ccf->labels, label);
- if (st) {
- pst = lua_newuserdata (L, sizeof (struct statfile *));
- lua_setclass (L, "rspamd{statfile}", -1);
- *pst = st;
+ cur = g_hash_table_lookup (ccf->labels, label);
+ if (cur) {
+ lua_newtable (L);
+ i = 1;
+ while (cur) {
+ st = cur->data;
+ pst = lua_newuserdata (L, sizeof (struct statfile *));
+ lua_setclass (L, "rspamd{statfile}", -1);
+ *pst = st;
+ lua_rawseti (L, -2, i++);
+ cur = g_list_next (cur);
+ }
return 1;
}
}