From: Heiko Schlichting Date: Fri, 19 Feb 2021 11:11:51 +0000 (+0000) Subject: Fix weight calculation for spamd_address. Bug 2694 X-Git-Tag: exim-4.95-RC0~125 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/6296a393aeab9fecc38916dfcbf1c94d54691650 Fix weight calculation for spamd_address. Bug 2694 --- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 5b900a558..59fb46ad2 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -203,7 +203,9 @@ JH/42 Bug 2693: Harden against a peer which reneges on a 452 "too many previous coding assumed this would not happen, and under PIPELINING would result in both lost and duplicate recipients for a message. - +JH/43 Bug 2694: Fix weighted distribution of work to multiple spamd servers. + Previously the weighting was incorrectly applied. Found and fixed by + Heiko Schlichting. Exim version 4.94 diff --git a/src/src/spam.c b/src/src/spam.c index 3318bff49..b0e24b368 100644 --- a/src/src/spam.c +++ b/src/src/spam.c @@ -174,7 +174,7 @@ for (long rnd = random() % weights, i = 0; i < num_servers; i++) { sd = spamds[i]; if (!sd->is_failed && sd->priority == pri) - if ((rnd -= sd->weight) <= 0) + if ((rnd -= sd->weight) < 0) return i; }