Browse Source

[Fix] Fix round-robin selection when upstreams have no weight

tags/1.3.0
Vsevolod Stakhov 8 years ago
parent
commit
e3aed2666a
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      src/libutil/upstream.c

+ 9
- 0
src/libutil/upstream.c View 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--;

Loading…
Cancel
Save