]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mworker: sets used or closed worker FDs to -1
authorWilliam Lallemand <wlallemand@haproxy.org>
Mon, 31 Jan 2022 10:01:24 +0000 (11:01 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Mon, 31 Jan 2022 10:10:34 +0000 (11:10 +0100)
mworker_cli_sockpair_new() is used to create the socketpair CLI listener of
the worker. Its FD is referenced in the mworker_proc structure, however,
once it's assigned to the listener the reference should be removed so we
don't use it accidentally.

The same must be done in case of errors if the FDs were already closed.

src/cli.c

index 16ddf052675945fbef38272c3c3f85841cb9aae7..fad064b92d626f17cc6ec62e1d4762e020fcbc4d 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -2982,11 +2982,19 @@ int mworker_cli_sockpair_new(struct mworker_proc *mworker_proc, int proc)
                global.maxsock++; /* for the listening socket */
        }
 
+       /* the sockpair was asssigned successfully to the listener for the
+        * worker,  we can remove it from the mworker_proc, so it's not used
+        * elsewhere accidentally
+        */
+       mworker_proc->ipc_fd[1] = -1;
+
        return 0;
 
 error:
        close(mworker_proc->ipc_fd[0]);
        close(mworker_proc->ipc_fd[1]);
+       mworker_proc->ipc_fd[0] = -1;
+       mworker_proc->ipc_fd[1] = -1;
        free(err);
 
        return -1;