]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: server: make use of srv_is_usable() instead of checking eweight
authorWilly Tarreau <w@1wt.eu>
Thu, 22 May 2014 14:20:59 +0000 (16:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 23 May 2014 12:29:11 +0000 (14:29 +0200)
srv_is_usable() is broader than srv_is_usable() as it not only considers
the weight but the server's state as well. Future changes will allow a
server to be in drain mode with a non-zero weight, so we should migrate
to use that function instead.

src/lb_map.c
src/queue.c
src/server.c

index df7af7f337176c3bb93a24052752ba7e1bc3ff5f..be61b77e8c9492204e25350f189143a4051eaf06 100644 (file)
@@ -99,9 +99,8 @@ void recalc_server_map(struct proxy *px)
                int max = 0;
                best = NULL;
                for (cur = px->srv; cur; cur = cur->next) {
-                       if (cur->eweight &&
-                           (cur->flags & SRV_F_BACKUP) == flag &&
-                           (cur->state == SRV_ST_STARTING || cur->state == SRV_ST_RUNNING)) {
+                       if ((cur->flags & SRV_F_BACKUP) == flag &&
+                           srv_is_usable(cur)) {
                                int v;
 
                                /* If we are forced to return only one server, we don't want to
index 8b4d9ed3a728a3aed3f788a081ba68413172de6e..74fa659212ec85561fdd354b97159d4c7b55a03c 100644 (file)
@@ -204,7 +204,7 @@ int pendconn_grab_from_px(struct server *s)
 {
        int xferred;
 
-       if (!s->eweight)
+       if (!srv_is_usable(s))
                return 0;
 
        for (xferred = 0; !s->maxconn || xferred < srv_dynamic_maxconn(s); xferred++) {
index 98ac2cd106f560b1c38ea7b93e2e120c10ad5855..857c8aaf66fc6e364152ef93c3bf8d01af9a1198 100644 (file)
@@ -637,7 +637,7 @@ void server_recalc_eweight(struct server *sv)
        /* now propagate the status change to any LB algorithms */
        if (px->lbprm.update_server_eweight)
                px->lbprm.update_server_eweight(sv);
-       else if (sv->eweight) {
+       else if (srv_is_usable(sv)) {
                if (px->lbprm.set_server_status_up)
                        px->lbprm.set_server_status_up(sv);
        }