]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] dynamic connection throttling could return a max of zero conns
authorWilly Tarreau <w@1wt.eu>
Sun, 14 Sep 2008 15:43:27 +0000 (17:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 7 Dec 2008 22:30:38 +0000 (23:30 +0100)
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)

src/queue.c

index dd5bb043ca23e6b3b5f7f00ea2b1c27224822059..172e0560d05f79da35a284772a0a1f0342132604 100644 (file)
@@ -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;
 }