]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: server/cli: Fix locking in function processing "set server" command
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 18 Jun 2021 06:47:14 +0000 (08:47 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 18 Jun 2021 07:16:32 +0000 (09:16 +0200)
The commit c7b391aed ("BUG/MEDIUM: server/cli: Fix ABBA deadlock when fqdn
is set from the CLI") introduced 2 bugs. The first one is a typo on the
server's lock label (s/SERVER_UNLOCK/SERVER_LOCK/). The second one is about
the server's lock itself. It must be acquired to execute the "agent-send"
subcommand.

The patch above is marked to be backported as far as 1.8. Thus, this one
must also backported as far 1.8.

BUG/MINOR: server/cli: Don't forget to lock server on agent-send subcommand

src/server.c

index f4802400852867c124bd4d3a2778a678252ee3e2..ef80d2b0ffa7485049f344b1c2a55a6f05a7a7ef 100644 (file)
@@ -3994,12 +3994,14 @@ static int cli_parse_set_server(char **args, char *payload, struct appctx *appct
                        cli_msg(appctx, LOG_WARNING, warning);
        }
        else if (strcmp(args[3], "agent-send") == 0) {
+               HA_SPIN_LOCK(SERVER_LOCK, &sv->lock);
                if (!(sv->agent.state & CHK_ST_ENABLED))
                        cli_err(appctx, "agent checks are not enabled on this server.\n");
                else {
                        if (!set_srv_agent_send(sv, args[4]))
                                cli_err(appctx, "cannot allocate memory for new string.\n");
                }
+               HA_SPIN_UNLOCK(SERVER_LOCK, &sv->lock);
        }
        else if (strcmp(args[3], "check-addr") == 0) {
                char *addr = NULL;
@@ -4072,7 +4074,7 @@ static int cli_parse_set_server(char **args, char *payload, struct appctx *appct
                        sv->flags &= ~SRV_F_NO_RESOLUTION;
                }
                warning = srv_update_fqdn(sv, args[4], "stats socket command", 1);
-               HA_SPIN_UNLOCK(SERVER_UNLOCK, &sv->lock);
+               HA_SPIN_UNLOCK(SERVER_LOCK, &sv->lock);
                HA_SPIN_UNLOCK(DNS_LOCK, &sv->resolvers->lock);
                if (warning)
                        cli_msg(appctx, LOG_WARNING, warning);