From 454467849070931e0fd7bd09d62b46fbd4923dc5 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 9 Mar 2012 17:16:09 +0100 Subject: [PATCH] BUG: checks: fix server maintenance exit sequence 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/checks.c b/src/checks.c index 7a9b56d8e..010fe6d2f 100644 --- a/src/checks.c +++ b/src/checks.c @@ -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)