aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBjörn Stenberg <bjst@bjorn>2013-11-08 00:09:20 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-11-10 22:49:56 +0000
commite7d77fb3ef14bac8690f343327b302f866ac53f2 (patch)
treef6447320eb2516c46c53405718601cad61efa965 /lib
parentc8e63f247aa14a6721b0d04f444d258e690b0dc8 (diff)
connect: Close temporary sockets in conn_free()
The temporary sockets used for Happy Eyeballs were not closed properly, if curl exited prematurely, which this patch fixes.
Diffstat (limited to 'lib')
-rw-r--r--lib/connect.c5
-rw-r--r--lib/ftp.c1
-rw-r--r--lib/url.c6
3 files changed, 10 insertions, 2 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 2fd9883b9..67f73343c 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -758,10 +758,13 @@ CURLcode Curl_is_connected(struct connectdata *conn,
/* use this socket from now on */
conn->sock[sockindex] = conn->tempsock[i];
conn->ip_addr = conn->tempaddr[i];
+ conn->tempsock[i] = CURL_SOCKET_BAD;
/* close the other socket, if open */
- if(conn->tempsock[other] != CURL_SOCKET_BAD)
+ if(conn->tempsock[other] != CURL_SOCKET_BAD) {
Curl_closesocket(conn, conn->tempsock[other]);
+ conn->tempsock[other] = CURL_SOCKET_BAD;
+ }
/* see if we need to do any proxy magic first once we connected */
code = Curl_connected_proxy(conn, sockindex);
diff --git a/lib/ftp.c b/lib/ftp.c
index 8879ff1d9..abd70e070 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -1866,7 +1866,6 @@ static CURLcode proxy_magic(struct connectdata *conn,
if(conn->tunnel_state[SECONDARYSOCKET] != TUNNEL_COMPLETE) {
/* the CONNECT procedure is not complete, the tunnel is not yet up */
state(conn, FTP_STOP); /* this phase is completed */
- conn->bits.tcpconnect[SECONDARYSOCKET] = FALSE;
return result;
}
else
diff --git a/lib/url.c b/lib/url.c
index 35b8a6c6e..36bd46455 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -2503,6 +2503,10 @@ static void conn_free(struct connectdata *conn)
Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]);
if(CURL_SOCKET_BAD != conn->sock[FIRSTSOCKET])
Curl_closesocket(conn, conn->sock[FIRSTSOCKET]);
+ if(CURL_SOCKET_BAD != conn->tempsock[0])
+ Curl_closesocket(conn, conn->tempsock[0]);
+ if(CURL_SOCKET_BAD != conn->tempsock[1])
+ Curl_closesocket(conn, conn->tempsock[1]);
#if defined(USE_NTLM) && defined(NTLM_WB_ENABLED)
Curl_ntlm_wb_cleanup(conn);
@@ -3522,6 +3526,8 @@ static struct connectdata *allocate_conn(struct SessionHandle *data)
conn->sock[FIRSTSOCKET] = CURL_SOCKET_BAD; /* no file descriptor */
conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD; /* no file descriptor */
+ conn->tempsock[0] = CURL_SOCKET_BAD; /* no file descriptor */
+ conn->tempsock[1] = CURL_SOCKET_BAD; /* no file descriptor */
conn->connection_id = -1; /* no ID */
conn->port = -1; /* unknown at this point */