]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mworker: Do not attempt to close(2) fd -1
authorTim Duesterhus <tim@bastelstu.be>
Sun, 25 Nov 2018 19:03:39 +0000 (20:03 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 26 Nov 2018 07:35:41 +0000 (08:35 +0100)
Valgrind reports:

==3389== Warning: invalid file descriptor -1 in syscall close()

Check for >= 0 before closing.

This bug was introduced in commit ce83b4a5dd48c000dec68f9d551945d21e9ac7ac
and is specific to 1.9. No backport needed.

src/haproxy.c

index 54ab7c865a2ee4ad58393ae4d3a0c40ca83d6659..b4e12f14a910b484ea37b21e77803e972beddbd6 100644 (file)
@@ -3099,7 +3099,8 @@ int main(int argc, char **argv)
                                 * workers, we don't need to close the worker
                                 * side of other workers since it's done with
                                 * the bind_proc */
-                               close(child->ipc_fd[0]);
+                               if (child->ipc_fd[0] >= 0)
+                                       close(child->ipc_fd[0]);
                                if (child->relative_pid == relative_pid &&
                                    child->reloads == 0) {
                                        /* keep this struct if this is our pid */