]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG: checks: fix server maintenance exit sequence
authorWilly Tarreau <w@1wt.eu>
Fri, 9 Mar 2012 16:16:09 +0000 (17:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 Mar 2012 16:19:43 +0000 (17:19 +0100)
Recent commit 62c3be broke maintenance mode by fixing srv_is_usable().
Enabling a disabled server would not re-introduce it into the farm.
The reason is that in set_server_up(), the SRV_MAINTAIN flag is still
present when recounting the servers. The flag was removed late only to
adjust a log message. Keep a copy of the old flag instead and update
SRV_MAINTAIN earlier.

This fix must also be backported to 1.4 (but no release got the regression).

src/checks.c

index 7a9b56d8eec4018a2c3bdae08f1e4f8ad9ec1fa9..010fe6d2fa0506922f21cecab52b7f33169efaff 100644 (file)
@@ -444,6 +444,7 @@ void set_server_up(struct server *s) {
        struct server *srv;
        struct chunk msg;
        int xferred;
+       unsigned int old_state = s->state;
 
        if (s->state & SRV_MAINTAIN) {
                s->health = s->rise;
@@ -461,6 +462,7 @@ void set_server_up(struct server *s) {
 
                s->last_change = now.tv_sec;
                s->state |= SRV_RUNNING;
+               s->state &= ~SRV_MAINTAIN;
 
                if (s->slowstart > 0) {
                        s->state |= SRV_WARMINGUP;
@@ -483,7 +485,7 @@ void set_server_up(struct server *s) {
 
                chunk_init(&msg, trash, sizeof(trash));
 
-               if (s->state & SRV_MAINTAIN) {
+               if (old_state & SRV_MAINTAIN) {
                        chunk_printf(&msg,
                                "%sServer %s/%s is UP (leaving maintenance)", s->state & SRV_BACKUP ? "Backup " : "",
                                s->proxy->id, s->id);
@@ -505,8 +507,6 @@ void set_server_up(struct server *s) {
                                if (! (srv->state & SRV_MAINTAIN))
                                        /* Only notify tracking servers if they're not in maintenance. */
                                        set_server_up(srv);
-
-               s->state &= ~SRV_MAINTAIN;
        }
 
        if (s->health >= s->rise)