Fix weight calculation for spamd_address. Bug 2694
authorHeiko Schlichting <heiko@fu-berlin.de>
Fri, 19 Feb 2021 11:11:51 +0000 (11:11 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Fri, 19 Feb 2021 16:37:02 +0000 (16:37 +0000)
(cherry picked from commit 6296a393aeab9fecc38916dfcbf1c94d54691650)

doc/doc-txt/ChangeLog
src/src/spam.c

index f687f73f52847bd4f6c56f234fc63956cb40a103..f8bfcf10c44a0ba6e4aae3a19700687272a3b3fd 100644 (file)
@@ -153,7 +153,9 @@ JH/42 Bug 2692: 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
index 340f8b92f68af6dbf6bf3d215bd7a06200c2fce5..2fffa1447171180e157289c91ed63644a23312dd 100644 (file)
@@ -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;
   }