From 184636e3e765eeb12f4887e1b82aef4ca6422264 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 6 Sep 2012 14:04:41 +0200 Subject: [PATCH] BUG: tcp: close socket fd upon connect error When the data layer fails to initialize (eg: out of memory for SSL), we must close the socket fd we just allocated. --- src/proto_tcp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/proto_tcp.c b/src/proto_tcp.c index b43731cb9..f81914782 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -459,8 +459,10 @@ int tcp_connect_server(struct connection *conn, int data) fd_insert(fd); conn_sock_want_send(conn); /* for connect status */ - if (conn_data_init(conn) < 0) + if (conn_data_init(conn) < 0) { + fd_delete(fd); return SN_ERR_RESOURCE; + } if (data) conn_data_want_send(conn); /* prepare to send data if any */