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.dau...@criteo.com>
---
 src/proto_tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index df4e5a4d2..a9d5229c9 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -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;
-- 
2.25.0


Reply via email to