From 9c3bc229ec3369789ecf31944b44f8e6bed18a03 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 24 Dec 2010 14:49:37 +0100 Subject: [PATCH] [CLEANUP] frontend: only apply TCP-specific settings to TCP/TCP6 sockets It's useless to apply keep-alive or lingering to non-TCP sockets. --- src/frontend.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/frontend.c b/src/frontend.c index cf6606a07..4fc4460f0 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -88,15 +88,19 @@ int frontend_accept(struct session *s) s->srv_error = default_srv_error; /* Adjust some socket options */ - if ((s->listener->addr.ss_family != AF_UNIX) && - setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, (char *) &one, sizeof(one)) == -1) - goto out_return; + if (s->listener->addr.ss_family == AF_INET || s->listener->addr.ss_family == AF_INET6) { + if (setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, + (char *) &one, sizeof(one)) == -1) + goto out_return; - if (s->fe->options & PR_O_TCP_CLI_KA) - setsockopt(cfd, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, sizeof(one)); + if (s->fe->options & PR_O_TCP_CLI_KA) + setsockopt(cfd, SOL_SOCKET, SO_KEEPALIVE, + (char *) &one, sizeof(one)); - if (s->fe->options & PR_O_TCP_NOLING) - setsockopt(cfd, SOL_SOCKET, SO_LINGER, (struct linger *) &nolinger, sizeof(struct linger)); + if (s->fe->options & PR_O_TCP_NOLING) + setsockopt(cfd, SOL_SOCKET, SO_LINGER, + (struct linger *) &nolinger, sizeof(struct linger)); + } if (global.tune.client_sndbuf) setsockopt(cfd, SOL_SOCKET, SO_SNDBUF, &global.tune.client_sndbuf, sizeof(global.tune.client_sndbuf));