]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mworker: Set FD_CLOEXEC flag on log fd
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 19 Dec 2017 09:35:53 +0000 (10:35 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 19 Dec 2017 13:03:30 +0000 (14:03 +0100)
A log socket (UDP or UNIX) is opened by the master during its startup, when the
first log message is sent. So, to prevent FD leaks, we must ensure we correctly
close it during a reload. By setting FD_CLOEXEC bit on it, we are sure it will
be automatically closed it during a reload.

This patch must be backported in 1.8.

src/log.c

index 0b8467f33611226c9c09bdaeaf6cf5021271042f..de775af45b4502c4278b8a85c94a837ff646c045 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1176,6 +1176,7 @@ void __send_log(struct proxy *p, int level, char *message, size_t size, char *sd
                        setsockopt(*plogfd, SOL_SOCKET, SO_RCVBUF, &zero, sizeof(zero));
                        /* does nothing under Linux, maybe needed for others */
                        shutdown(*plogfd, SHUT_RD);
+                       fcntl(*plogfd, F_SETFD, fcntl(*plogfd, F_GETFD, FD_CLOEXEC) | FD_CLOEXEC);
                }
 
                switch (logsrv->format) {