00e058e7e0beca9a43c479078870d10dce79330b
[packages.git] / net / haproxy / patches / 0006-BUG-MINOR-use-the-same-check-condition-for-server-as.patch
1 From 3bd693057420af0cd04132fdfb7c59e56aa90421 Mon Sep 17 00:00:00 2001
2 From: Godbach <nylzhaowei@gmail.com>
3 Date: Wed, 7 Aug 2013 09:48:23 +0800
4 Subject: [PATCH 6/9] BUG/MINOR: use the same check condition for server as
5  other algorithms
6
7 Such load balance algorithms as roundrobin, leastconn and first will check the
8 server after being selected with the following condition:
9         if (!s->maxconn || (!s->nbpend && s->served < srv_dynamic_maxconn(s)))
10
11 But static-rr uses the different one in map_get_server_rr()  as below:
12         if (!srv->maxconn || srv->cur_sess < srv_dynamic_maxconn(srv))
13 After viewing this difference, it is a better choice for static-rr to use the
14 same check condition as other algorithms.
15
16 This change will only affect static-rr. Though all hash algorithms with type
17 map-based will use the same server map as static-rr, they call another function
18 map_get_server_hash() to get server.
19
20 Signed-off-by: Godbach <nylzhaowei@gmail.com>
21 (cherry picked from commit 8f9fd2f0a0893761afeb6800c7b62a51d782af0e)
22 ---
23  src/lb_map.c | 2 +-
24  1 file changed, 1 insertion(+), 1 deletion(-)
25
26 diff --git a/src/lb_map.c b/src/lb_map.c
27 index 49805ad..9858249 100644
28 --- a/src/lb_map.c
29 +++ b/src/lb_map.c
30 @@ -229,7 +229,7 @@ struct server *map_get_server_rr(struct proxy *px, struct server *srvtoavoid)
31         avoididx = 0; /* shut a gcc warning */
32         do {
33                 srv = px->lbprm.map.srv[newidx++];
34 -               if (!srv->maxconn || srv->cur_sess < srv_dynamic_maxconn(srv)) {
35 +               if (!srv->maxconn || (!srv->nbpend && srv->served < srv_dynamic_maxconn(srv))) {
36                         /* make sure it is not the server we are try to exclude... */
37                         if (srv != srvtoavoid) {
38                                 px->lbprm.map.rr_idx = newidx;
39 -- 
40 1.8.1.5
41