aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-04-24 15:57:20 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-04-24 15:57:20 +0100
commit7448425afed57c354987d1a340cb58e45d24d9d5 (patch)
tree4390a98fab74b7013ff5c8a9986eacc6291fe329
parent3281d1d77a53a6d905ef1aee0e0baf1096643283 (diff)
downloadrspamd-7448425afed57c354987d1a340cb58e45d24d9d5.tar.gz
rspamd-7448425afed57c354987d1a340cb58e45d24d9d5.zip
[Fix] Add resolving version of radix map helper
-rw-r--r--src/libserver/cfg_utils.c4
-rw-r--r--src/libutil/map_helpers.c28
-rw-r--r--src/libutil/map_helpers.h8
3 files changed, 38 insertions, 2 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 69dc3577e..1a2f473e7 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -1798,7 +1798,7 @@ rspamd_config_radix_from_ucl (struct rspamd_config *cfg,
else {
/* Just a list */
*target = rspamd_map_helper_new_radix (NULL);
- rspamd_map_helper_insert_radix (*target, str, "");
+ rspamd_map_helper_insert_radix_resolve (*target, str, "");
}
break;
case UCL_OBJECT:
@@ -1822,7 +1822,7 @@ rspamd_config_radix_from_ucl (struct rspamd_config *cfg,
*target = rspamd_map_helper_new_radix (NULL);
}
- rspamd_map_helper_insert_radix (*target, str, "");
+ rspamd_map_helper_insert_radix_resolve (*target, str, "");
}
ucl_object_iterate_free (it);
diff --git a/src/libutil/map_helpers.c b/src/libutil/map_helpers.c
index dbbe70e84..7bb442a97 100644
--- a/src/libutil/map_helpers.c
+++ b/src/libutil/map_helpers.c
@@ -444,6 +444,34 @@ rspamd_map_helper_insert_radix (gpointer st, gconstpointer key, gconstpointer va
}
void
+rspamd_map_helper_insert_radix_resolve (gpointer st, gconstpointer key, gconstpointer value)
+{
+ struct rspamd_radix_map_helper *r = (struct rspamd_radix_map_helper *)st;
+ struct rspamd_map_helper_value *val;
+ gsize vlen;
+ khiter_t k;
+ gconstpointer nk;
+ gint res;
+
+ vlen = strlen (value);
+ val = rspamd_mempool_alloc0 (r->pool, sizeof (*val) +
+ vlen + 1);
+ memcpy (val->value, value, vlen);
+
+ k = kh_get (rspamd_map_hash, r->htb, key);
+
+ if (k == kh_end (r->htb)) {
+ nk = rspamd_mempool_strdup (r->pool, key);
+ k = kh_put (rspamd_map_hash, r->htb, nk, &res);
+ }
+
+ nk = kh_key (r->htb, k);
+ val->key = nk;
+ kh_value (r->htb, k) = val;
+ rspamd_radix_add_iplist (key, ",", r->trie, val, TRUE);
+}
+
+void
rspamd_map_helper_insert_hash (gpointer st, gconstpointer key, gconstpointer value)
{
struct rspamd_hash_map_helper *ht = st;
diff --git a/src/libutil/map_helpers.h b/src/libutil/map_helpers.h
index b6bf81cdc..bd933fbf2 100644
--- a/src/libutil/map_helpers.h
+++ b/src/libutil/map_helpers.h
@@ -157,6 +157,14 @@ struct rspamd_radix_map_helper *rspamd_map_helper_new_radix (struct rspamd_map *
*/
void rspamd_map_helper_insert_radix (gpointer st, gconstpointer key, gconstpointer value);
/**
+ * Inserts new value into radix map performing synchronous resolving
+ * @param st
+ * @param key
+ * @param value
+ */
+void rspamd_map_helper_insert_radix_resolve (gpointer st, gconstpointer key,
+ gconstpointer value);
+/**
* Destroys radix map helper
* @param r
*/