From 3bd693057420af0cd04132fdfb7c59e56aa90421 Mon Sep 17 00:00:00 2001
From: Godbach <nylzhaowei@gmail.com>
Date: Wed, 7 Aug 2013 09:48:23 +0800
Subject: [PATCH 6/9] BUG/MINOR: use the same check condition for server as
 other algorithms

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>
(cherry picked from commit 8f9fd2f0a0893761afeb6800c7b62a51d782af0e)
---
 src/lb_map.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lb_map.c b/src/lb_map.c
index 49805ad..9858249 100644
--- a/src/lb_map.c
+++ b/src/lb_map.c
@@ -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;
-- 
1.8.1.5