]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: tcp: avoid closing fd when socket failed in tcp_bind_listener
authorWilliam Dauchy <w.dauchy@criteo.com>
Wed, 12 Feb 2020 09:09:14 +0000 (10:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 12 Feb 2020 14:24:21 +0000 (15:24 +0100)
we were trying to close file descriptor even when `socket` call was
failing.
this should fix github issue #499

this should be backported to all versions >= v1.8

Fixes: 153659f1ae69a1 ("MINOR: tcp: When binding socket, attempt to
reuse one from the old proc.")
Signed-off-by: William Dauchy <w.dauchy@criteo.com>
src/proto_tcp.c

index 197cb432b90b53040ea599d70c4615de3bd004bd..45d6a7c1995855f8ca678ae2fca76c25d5430e5a 100644 (file)
@@ -749,8 +749,8 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
                        if (getsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, &default_tcp_maxseg,
                            &ready_len) == -1)
                                ha_warning("Failed to get the default value of TCP_MAXSEG\n");
+                       close(fd);
                }
-               close(fd);
        }
        if (default_tcp6_maxseg == -1) {
                default_tcp6_maxseg = -2;