]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Allow iterating over upstreams
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 15 Mar 2016 13:45:53 +0000 (13:45 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 15 Mar 2016 13:45:53 +0000 (13:45 +0000)
src/libutil/upstream.c
src/libutil/upstream.h

index 3d01215725f3dff41910cf6a20bb7aabb563af24..a49a8a222eee2e2999d3f1718f86dfd73336026d 100644 (file)
@@ -889,3 +889,18 @@ rspamd_upstream_get_data (struct upstream *up)
 {
        return up->data;
 }
+
+
+void
+rspamd_upstreams_foreach (struct upstream_list *ups,
+               rspamd_upstream_traverse_func cb, void *ud)
+{
+       struct upstream *up;
+       guint i;
+
+       for (i = 0; i < ups->ups->len; i ++) {
+               up = g_ptr_array_index (ups->ups, i);
+
+               cb (up, ud);
+       }
+}
index 79d88802db752df9cf21153c1abe73fc944e9d50..c3cbf685ad6a0e27447305e7fda8889b2743bbc6 100644 (file)
@@ -130,6 +130,19 @@ gboolean rspamd_upstreams_parse_line (struct upstream_list *ups,
 gboolean rspamd_upstreams_from_ucl (struct upstream_list *ups,
                const ucl_object_t *in, guint16 def_port, void *data);
 
+
+typedef void (*rspamd_upstream_traverse_func) (struct upstream *up,
+               void *ud);
+
+/**
+ * Traverse upstreams list calling the function specified
+ * @param ups
+ * @param cb
+ * @param ud
+ */
+void rspamd_upstreams_foreach (struct upstream_list *ups,
+               rspamd_upstream_traverse_func cb, void *ud);
+
 /**
  * Returns the current IP address of the upstream
  * @param up