* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
#endif
#endif
+static void close_secondarysocket(struct connectdata *conn)
+{
+ if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET]) {
+ Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]);
+ conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
+ }
+ conn->bits.tcpconnect[SECONDARYSOCKET] = FALSE;
+ conn->tunnel_state[SECONDARYSOCKET] = TUNNEL_INIT;
+}
/*
* NOTE: back in the old days, we added code in the FTP code that made NOBODY
CURLSOCKTYPE_ACCEPT);
if(error) {
- Curl_closesocket(conn, s); /* close the socket and bail out */
- conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
+ close_secondarysocket(conn);
return CURLE_ABORTED_BY_CALLBACK;
}
}
/* store which command was sent */
ftpc->count1 = fcmd;
+ close_secondarysocket(conn);
+
/* we set the secondary socket variable to this for now, it is only so that
the cleanup function will close it in case we fail before the true
secondary stuff is made */
- if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET])
- Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]);
conn->sock[SECONDARYSOCKET] = portsock;
/* this tcpconnect assignment below is a hackish work-around to make the
/* Note that we keep "use" set to TRUE since that (next) connection is
still requested to use SSL */
}
- if(CURL_SOCKET_BAD != conn->sock[SECONDARYSOCKET]) {
- Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]);
- conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
- conn->bits.tcpconnect[SECONDARYSOCKET] = FALSE;
- }
+ close_secondarysocket(conn);
}
if(!result && (ftp->transfer == FTPTRANSFER_BODY) && ftpc->ctl_valid &&
CURLcode result = ftp_do_more(conn, &completed);
if(result) {
- if(conn->sock[SECONDARYSOCKET] != CURL_SOCKET_BAD) {
- /* close the second socket if it was created already */
- Curl_closesocket(conn, conn->sock[SECONDARYSOCKET]);
- conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
- }
+ close_secondarysocket(conn);
return result;
}
}