]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix round-robin selection when upstreams have no weight
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 23 Jun 2016 11:59:54 +0000 (12:59 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 23 Jun 2016 11:59:54 +0000 (12:59 +0100)
src/libutil/upstream.c

index fe07e89d217a3169ccc94c10bc884ec605de3e4d..2aa27d9294c30acf8f285318084679a6e7c83acb 100644 (file)
@@ -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--;