From 90e320fb14cc946f4eb5671618e7db9f5d002453 Mon Sep 17 00:00:00 2001 From: Heiko Schlichting Date: Fri, 19 Feb 2021 11:14:36 +0000 Subject: [PATCH] Fix weight calculation for socks_proxy. Bug 2694 (cherry picked from commit 83811e3c1b8189c0a725ec53df699730e7767263) --- doc/doc-txt/ChangeLog | 4 ++-- src/src/transports/smtp_socks.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index f8bfcf10c..a458b4721 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -154,8 +154,8 @@ JH/42 Bug 2692: Harden against a peer which reneges on a 452 "too many 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. + Previously the weighting was incorrectly applied. Similar fix for socks + proxies. Found and fixed by Heiko Schlichting. Exim version 4.94 diff --git a/src/src/transports/smtp_socks.c b/src/src/transports/smtp_socks.c index 41dc78147..cd8ed3e6d 100644 --- a/src/src/transports/smtp_socks.c +++ b/src/src/transports/smtp_socks.c @@ -190,7 +190,7 @@ for (rnd = random() % weights, i = 0; i < nproxies; i++) { sd = &proxies[i]; if (!sd->is_failed && sd->priority == pri) - if ((rnd -= sd->weight) <= 0) + if ((rnd -= sd->weight) < 0) return i; } -- 2.30.2