diff --git a/src/haproxy.c b/src/haproxy.c index 93b078010..b20974199 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3610,6 +3610,9 @@ int main(int argc, char **argv) child->timestamp = date.tv_sec; child->pid = ret; child->version = strdup(haproxy_version); + /* at this step the fd is bound for the worker, set it to -1 so + * it could be close in case of errors in mworker_cleanup_proc() */ + child->ipc_fd[1] = -1; break; } } diff --git a/src/mworker.c b/src/mworker.c index c4275a0fb..6bace6b46 100644 --- a/src/mworker.c +++ b/src/mworker.c @@ -541,14 +541,11 @@ void mworker_cleanup_proc() list_for_each_entry_safe(child, it, &proc_list, list) { if (child->pid == -1) { - /* Close the socketpair master side. We don't need to - * close the worker side, because it's stored in the - * GLOBAL cli listener which was supposed to be in the - * worker and which will be closed in - * mworker_cleanlisteners() - */ + /* Close the socketpairs. */ if (child->ipc_fd[0] > -1) close(child->ipc_fd[0]); + if (child->ipc_fd[1] > -1) + close(child->ipc_fd[1]); if (child->srv) { /* only exists if we created a master CLI listener */ srv_drop(child->srv);