]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[CLEANUP] frontend: only apply TCP-specific settings to TCP/TCP6 sockets
authorWilly Tarreau <w@1wt.eu>
Fri, 24 Dec 2010 13:49:37 +0000 (14:49 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 24 Dec 2010 13:49:37 +0000 (14:49 +0100)
It's useless to apply keep-alive or lingering to non-TCP sockets.

src/frontend.c

index cf6606a075f379860347477afcf2b10f2d96ebfb..4fc4460f0c37fc5bd03a2b958db60d821d87ef61 100644 (file)
@@ -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->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->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_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));