From: Christopher Faulet Date: Mon, 17 Feb 2025 14:16:15 +0000 (+0100) Subject: BUG/MINOR: cli: Wait for the last ACK when FDs are xferred from the old worker X-Git-Tag: v3.2-dev6~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=49b7bcf583261efedabad5ba15c4026f2e713c61;p=thirdparty%2Fhaproxy.git BUG/MINOR: cli: Wait for the last ACK when FDs are xferred from the old worker On reload, the new worker requests bound FDs to the old one. The old worker sends them in message of at most 252 FDs. Each message is acknowledged by the new worker. All messages sent or received by the old worker are handled manually via sendmsg/recv syscalls. So the old worker must be sure consume all the ACK replies. However, the last one was never consumed. So it was considered as a command by the CLI applet. This issue was hidden since recently. But it was the root cause of the issue #2862. Note this last ack is also the first one when there are less than 252 FDs to transfer. This patch must be backported to all stable versions. --- diff --git a/src/cli.c b/src/cli.c index 1b6c0cbc6..e7a33f57d 100644 --- a/src/cli.c +++ b/src/cli.c @@ -2444,6 +2444,16 @@ static int _getsocks(char **args, char *payload, struct appctx *appctx, void *pr ha_warning("Failed to transfer sockets\n"); goto out; } + + /* Wait for an ack */ + do { + ret = recv(fd, &tot_fd_nb, sizeof(tot_fd_nb), 0); + } while (ret == -1 && errno == EINTR); + + if (ret <= 0) { + ha_warning("Unexpected error while transferring sockets\n"); + goto out; + } } out: