From 530b9dde00565e8a9cf4654fa408f7dc69cdb590 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 17 Sep 2007 10:56:13 +0200 Subject: [PATCH] [MINOR] set the log socket receive window to zero bytes 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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/log.c b/src/log.c index 1677c2ecc..542dd0dc4 100644 --- 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)