diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-02-18 21:00:56 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-02-18 21:00:56 +0000 |
commit | dbc9ff655dfb459eb8af328a82a5b8c848cda480 (patch) | |
tree | 2d0b2dd5696ce974841e5bbff7e6d2da4c2bb260 /src | |
parent | 7a3c590d65b4b9a4092018002e53614e61c63b50 (diff) | |
download | rspamd-dbc9ff655dfb459eb8af328a82a5b8c848cda480.tar.gz rspamd-dbc9ff655dfb459eb8af328a82a5b8c848cda480.zip |
[Fix] Fix round-robin rotation
Diffstat (limited to 'src')
-rw-r--r-- | src/libutil/upstream.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libutil/upstream.c b/src/libutil/upstream.c index 6acf420ea..612354043 100644 --- a/src/libutil/upstream.c +++ b/src/libutil/upstream.c @@ -1378,13 +1378,20 @@ rspamd_upstream_get_round_robin (struct upstream_list *ups, } } - if (up->checked * (up->errors + 1) < min_checked) { + /* + * This code is used when all upstreams have zero weight + * The logic is to select least currently used upstream and penalise + * upstream with errors. The error penalty should no be too high + * to avoid sudden traffic drop in this case. + */ + if (up->checked + up->errors * 2 < min_checked) { min_checked_sel = up; min_checked = up->checked; } } if (max_weight == 0) { + /* All upstreams have zero weight */ if (min_checked > G_MAXUINT / 2) { /* Reset all checked counters to avoid overflow */ for (i = 0; i < ups->alive->len; i ++) { |