diff options
| author | Willy Tarreau <w@1wt.eu> | 2008-09-14 17:43:27 +0200 |
|---|---|---|
| committer | Willy Tarreau <w@1wt.eu> | 2008-09-14 18:19:33 +0200 |
| commit | 2859d8fb9fc42e42ce31f6e1d10dba9ea010edf6 (patch) | |
| tree | bc1b8be2e0e700b37c2493a0e001f771ae27fab0 | |
| parent | f62c4afe63948d032f2a187e96c46176f587d393 (diff) | |
| download | haproxy-2859d8fb9fc42e42ce31f6e1d10dba9ea010edf6.tar.gz | |
[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)
| -rw-r--r-- | src/queue.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/queue.c b/src/queue.c index 33f9867b8..c8b27b4fa 100644 --- a/src/queue.c +++ b/src/queue.c @@ -55,8 +55,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; } |
