]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] set the log socket receive window to zero bytes
authorWilly Tarreau <w@1wt.eu>
Mon, 17 Sep 2007 08:56:13 +0000 (10:56 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 15 Oct 2007 07:32:07 +0000 (09:32 +0200)
The syslog UDP socket may receive data, which is not cool because those
data accumulate in the system buffers up to the receive socket buffer size.
To prevent this, we set the receive window to zero and try to shutdown(SHUT_RD)
the socket.

src/log.c

index 1677c2ecc64590dc5249ffb96c15058b3036d72d..542dd0dc4c967135e8d79a514dbccc73c10547df 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -163,6 +163,9 @@ void send_log(struct proxy *p, int level, const char *message, ...)
        if (logfd < 0) {
                if ((logfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
                        return;
+               /* we don't want to receive anything on this socket */
+               setsockopt(logfd, SOL_SOCKET, SO_RCVBUF, &zero, sizeof(zero));
+               shutdown(logfd, SHUT_RD); /* does nothing under Linux, maybe needed for others */
        }
     
        if (level < 0 || progname == NULL || message == NULL)