From: Aurelien DARRAGON Date: Tue, 18 Apr 2023 10:02:48 +0000 (+0200) Subject: MINOR: server: propagate lb changes through srv_lb_propagate() X-Git-Tag: v2.8-dev8~52 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=85b91375bf49aa7930fbfbff6910db0f8fd5c03f;p=haproxy-3.0.git MINOR: server: propagate lb changes through srv_lb_propagate() Now that we have a generic srv_lb_propagate(s) function, let's use it each time we explicitly wan't to set the status down as well. Indeed, it is tricky to try to handle "down" case explicitly, instead we use srv_lb_propagate() which will call the proper function that will handle the new server state. This will allow some code cleanup and will prevent any logic error. This commit depends on: - "MINOR: server: propagate server state change to lb through single function" --- diff --git a/src/server.c b/src/server.c index 036c5a1..f62a7e3 100644 --- a/src/server.c +++ b/src/server.c @@ -5319,8 +5319,7 @@ static void srv_update_status(struct server *s) s->next_admin = s->cur_admin; if ((s->cur_state != SRV_ST_STOPPED) && (s->next_state == SRV_ST_STOPPED)) { - if (s->proxy->lbprm.set_server_status_down) - s->proxy->lbprm.set_server_status_down(s); + srv_lb_propagate(s); if (s->onmarkeddown & HANA_ONMARKEDDOWN_SHUTDOWNSESSIONS) srv_shutdown_streams(s, SF_ERR_DOWN); @@ -5354,8 +5353,7 @@ static void srv_update_status(struct server *s) } } else if ((s->cur_state != SRV_ST_STOPPING) && (s->next_state == SRV_ST_STOPPING)) { - if (s->proxy->lbprm.set_server_status_down) - s->proxy->lbprm.set_server_status_down(s); + srv_lb_propagate(s); /* we might have streams queued on this server and waiting for * a connection. Those which are redispatchable will be queued @@ -5466,8 +5464,7 @@ static void srv_update_status(struct server *s) check->health = 0; /* failure */ s->next_state = SRV_ST_STOPPED; - if (s->proxy->lbprm.set_server_status_down) - s->proxy->lbprm.set_server_status_down(s); + srv_lb_propagate(s); if (s->onmarkeddown & HANA_ONMARKEDDOWN_SHUTDOWNSESSIONS) srv_shutdown_streams(s, SF_ERR_DOWN); @@ -5660,8 +5657,7 @@ static void srv_update_status(struct server *s) if (!(s->cur_admin & SRV_ADMF_DRAIN) && (s->next_admin & SRV_ADMF_DRAIN)) { /* drain state is applied only if not yet in maint */ - if (px->lbprm.set_server_status_down) - px->lbprm.set_server_status_down(s); + srv_lb_propagate(s); /* we might have streams queued on this server and waiting for * a connection. Those which are redispatchable will be queued