From: Vsevolod Stakhov Date: Thu, 23 Jun 2016 11:59:54 +0000 (+0100) Subject: [Fix] Fix round-robin selection when upstreams have no weight X-Git-Tag: 1.3.0~272 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3aed2666a167ed0a9d63d972531027aaa2167e5;p=thirdparty%2Frspamd.git [Fix] Fix round-robin selection when upstreams have no weight --- diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c index fe07e89d21..2aa27d9294 100644 --- a/src/libutil/upstream.c +++ b/src/libutil/upstream.c @@ -743,6 +743,15 @@ rspamd_upstream_get_round_robin (struct upstream_list *ups, gboolean use_cur) } } + if (max_weight == 0) { + /* + * We actually don't have any weight information, so we could use + * random selection here + */ + selected = g_ptr_array_index (ups->alive, + ottery_rand_range (ups->alive->len - 1)); + } + if (use_cur && selected) { if (selected->cur_weight > 0) { selected->cur_weight--;