summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-15 16:11:55 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-15 16:11:55 +0100
commitf9e618dee39905944b35232ad262c93472a70a06 (patch)
treecf08d2a2988cb202b11a218b89c459360f2a5eb9 /src
parentcdac77e4c351e1d3c4b04d8018ae3a9884057570 (diff)
downloadrspamd-f9e618dee39905944b35232ad262c93472a70a06.tar.gz
rspamd-f9e618dee39905944b35232ad262c93472a70a06.zip
[Minor] Add some auxiliary functions for upstreams
Diffstat (limited to 'src')
-rw-r--r--src/libutil/upstream.c17
-rw-r--r--src/libutil/upstream.h16
2 files changed, 31 insertions, 2 deletions
diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c
index 7e64b866c..907024579 100644
--- a/src/libutil/upstream.c
+++ b/src/libutil/upstream.c
@@ -473,6 +473,14 @@ rspamd_upstream_ok (struct upstream *up)
RSPAMD_UPSTREAM_UNLOCK (up->lock);
}
+void
+rspamd_upstream_set_weight (struct upstream *up, guint weight)
+{
+ RSPAMD_UPSTREAM_LOCK (up->lock);
+ up->weight = weight;
+ RSPAMD_UPSTREAM_UNLOCK (up->lock);
+}
+
#define SEED_CONSTANT 0xa574de7df64e9b9dULL
struct upstream_list*
@@ -611,6 +619,13 @@ rspamd_upstreams_set_flags (struct upstream_list *ups,
ups->flags = flags;
}
+void
+rspamd_upstreams_set_rotation (struct upstream_list *ups,
+ enum rspamd_upstream_rotation rot)
+{
+ ups->rot_alg = rot;
+}
+
gboolean
rspamd_upstream_add_addr (struct upstream *up, rspamd_inet_addr_t *addr)
{
@@ -973,6 +988,6 @@ rspamd_upstreams_foreach (struct upstream_list *ups,
for (i = 0; i < ups->ups->len; i ++) {
up = g_ptr_array_index (ups->ups, i);
- cb (up, ud);
+ cb (up, i, ud);
}
}
diff --git a/src/libutil/upstream.h b/src/libutil/upstream.h
index 07b9302e8..ddc480afe 100644
--- a/src/libutil/upstream.h
+++ b/src/libutil/upstream.h
@@ -63,6 +63,12 @@ void rspamd_upstream_fail (struct upstream *up);
void rspamd_upstream_ok (struct upstream *up);
/**
+ * Set weight for an upstream
+ * @param up
+ */
+void rspamd_upstream_set_weight (struct upstream *up, guint weight);
+
+/**
* Create new list of upstreams
* @return
*/
@@ -77,6 +83,14 @@ void rspamd_upstreams_set_flags (struct upstream_list *ups,
enum rspamd_upstream_flag flags);
/**
+ * Sets rotation policy for upstreams list
+ * @param ups
+ * @param rot
+ */
+void rspamd_upstreams_set_rotation (struct upstream_list *ups,
+ enum rspamd_upstream_rotation rot);
+
+/**
* Destroy list of upstreams
* @param ups
*/
@@ -131,7 +145,7 @@ 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,
+typedef void (*rspamd_upstream_traverse_func) (struct upstream *up, guint idx,
void *ud);
/**