From: Willy Tarreau Date: Sun, 14 Sep 2008 15:43:27 +0000 (+0200) Subject: [BUG] dynamic connection throttling could return a max of zero conns X-Git-Tag: v1.3.16-rc1~107 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=28a9e529f8ec5b78f7047c8b94c5684fb594ba5b;p=thirdparty%2Fhaproxy.git [BUG] dynamic connection throttling could return a max of zero conns srv_dynamic_maxconn() is clearly documented as returning at least 1 possible connection under throttling. But the computation was wrong, the minimum 1 was divided and got lost in case of very low maxconns. Apply the MAX(1, max) before returning the result in order to ensure that a newly appeared server will get some traffic. (cherry picked from commit 819970098f134453c0934047b3bd3440b0996b55) --- diff --git a/src/queue.c b/src/queue.c index dd5bb043ca..172e0560d0 100644 --- a/src/queue.c +++ b/src/queue.c @@ -52,8 +52,8 @@ unsigned int srv_dynamic_maxconn(const struct server *s) now.tv_sec < s->last_change + s->slowstart && now.tv_sec >= s->last_change) { unsigned int ratio; - ratio = MAX(1, 100 * (now.tv_sec - s->last_change) / s->slowstart); - max = max * ratio / 100; + ratio = 100 * (now.tv_sec - s->last_change) / s->slowstart; + max = MAX(1, max * ratio / 100); } return max; }