]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: use the same check condition for server as other algorithms
authorGodbach <nylzhaowei@gmail.com>
Wed, 7 Aug 2013 01:48:23 +0000 (09:48 +0800)
committerWilly Tarreau <w@1wt.eu>
Tue, 13 Aug 2013 14:15:08 +0000 (16:15 +0200)
Such load balance algorithms as roundrobin, leastconn and first will check the
server after being selected with the following condition:
if (!s->maxconn || (!s->nbpend && s->served < srv_dynamic_maxconn(s)))

But static-rr uses the different one in map_get_server_rr()  as below:
if (!srv->maxconn || srv->cur_sess < srv_dynamic_maxconn(srv))
After viewing this difference, it is a better choice for static-rr to use the
same check condition as other algorithms.

This change will only affect static-rr. Though all hash algorithms with type
map-based will use the same server map as static-rr, they call another function
map_get_server_hash() to get server.

Signed-off-by: Godbach <nylzhaowei@gmail.com>
src/lb_map.c

index 49805ad37380a7c232b7d9fd77f40e511a0d3257..9858249cd7d6e57b7520b51b0b7bacc26c99ef24 100644 (file)
@@ -229,7 +229,7 @@ struct server *map_get_server_rr(struct proxy *px, struct server *srvtoavoid)
        avoididx = 0; /* shut a gcc warning */
        do {
                srv = px->lbprm.map.srv[newidx++];
-               if (!srv->maxconn || srv->cur_sess < srv_dynamic_maxconn(srv)) {
+               if (!srv->maxconn || (!srv->nbpend && srv->served < srv_dynamic_maxconn(srv))) {
                        /* make sure it is not the server we are try to exclude... */
                        if (srv != srvtoavoid) {
                                px->lbprm.map.rr_idx = newidx;