aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/upstream.c9
-rw-r--r--src/libutil/upstream.h3
2 files changed, 11 insertions, 1 deletions
diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c
index f4705b229..d2c1d2ee0 100644
--- a/src/libutil/upstream.c
+++ b/src/libutil/upstream.c
@@ -64,6 +64,7 @@ struct upstream_list {
GPtrArray *alive;
rspamd_mutex_t *lock;
guint64 hash_seed;
+ guint cur_elt;
};
static struct rdns_resolver *res = NULL;
@@ -354,6 +355,7 @@ rspamd_upstreams_create (void)
ls->ups = g_ptr_array_new ();
ls->alive = g_ptr_array_new ();
ls->lock = rspamd_mutex_new ();
+ ls->cur_elt = 0;
return ls;
}
@@ -678,5 +680,12 @@ rspamd_upstream_get (struct upstream_list *ups,
return rspamd_upstream_get_round_robin (ups, TRUE);
case RSPAMD_UPSTREAM_MASTER_SLAVE:
return rspamd_upstream_get_round_robin (ups, FALSE);
+ case RSPAMD_UPSTREAM_SEQUENTIAL:
+ if (ups->cur_elt >= ups->alive->len) {
+ ups->cur_elt = 0;
+ return NULL;
+ }
+
+ return g_ptr_array_index (ups->alive, ups->cur_elt ++);
}
}
diff --git a/src/libutil/upstream.h b/src/libutil/upstream.h
index cff6acfb1..8c399ab03 100644
--- a/src/libutil/upstream.h
+++ b/src/libutil/upstream.h
@@ -10,7 +10,8 @@ enum rspamd_upstream_rotation {
RSPAMD_UPSTREAM_RANDOM,
RSPAMD_UPSTREAM_HASHED,
RSPAMD_UPSTREAM_ROUND_ROBIN,
- RSPAMD_UPSTREAM_MASTER_SLAVE
+ RSPAMD_UPSTREAM_MASTER_SLAVE,
+ RSPAMD_UPSTREAM_SEQUENTIAL
};