1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

sendrecv: make them two pairs of send/recv to properly deal with FTPS

FTP(S) use two connections that can be set to different recv and
send functions independently, so by introducing recv+send pairs
in the same manner we already have sockets/connections we can
work with FTPS fine.

This commit fixes the FTPS regression introduced in change d64bd82.
This commit is contained in:
Howard Chu 2010-05-11 22:48:38 +02:00 committed by Daniel Stenberg
parent 016ce4b1da
commit bc8fc9803f
10 changed files with 26 additions and 22 deletions

View File

@ -633,8 +633,8 @@ gtls_connect_step3(struct connectdata *conn,
infof(data, "\t MAC: %s\n", ptr); infof(data, "\t MAC: %s\n", ptr);
conn->ssl[sockindex].state = ssl_connection_complete; conn->ssl[sockindex].state = ssl_connection_complete;
conn->recv = gtls_recv; conn->recv[sockindex] = gtls_recv;
conn->send = gtls_send; conn->send[sockindex] = gtls_send;
{ {
/* we always unconditionally get the session id here, as even if we /* we always unconditionally get the session id here, as even if we

View File

@ -1339,8 +1339,8 @@ CURLcode Curl_nss_connect(struct connectdata *conn, int sockindex)
} }
connssl->state = ssl_connection_complete; connssl->state = ssl_connection_complete;
conn->recv = nss_recv; conn->recv[sockindex] = nss_recv;
conn->send = nss_send; conn->send[sockindex] = nss_send;
display_conn_info(conn, connssl->handle); display_conn_info(conn, connssl->handle);

View File

@ -302,8 +302,8 @@ Curl_polarssl_connect(struct connectdata *conn,
} }
conn->ssl[sockindex].state = ssl_connection_complete; conn->ssl[sockindex].state = ssl_connection_complete;
conn->recv = polarssl_recv; conn->recv[sockindex] = polarssl_recv;
conn->send = polarssl_send; conn->send[sockindex] = polarssl_send;
/* Save the current session data for possible re-use */ /* Save the current session data for possible re-use */
{ {

View File

@ -268,8 +268,8 @@ CURLcode Curl_qsossl_connect(struct connectdata * conn, int sockindex)
} }
if (rc == CURLE_OK) { if (rc == CURLE_OK) {
connssl->state = ssl_connection_complete; connssl->state = ssl_connection_complete;
conn->recv = qsossl_recv; conn->recv[sockindex] = qsossl_recv;
conn->send = qsossl_send; conn->send[sockindex] = qsossl_send;
} }
return rc; return rc;

View File

@ -466,8 +466,10 @@ Curl_sec_login(struct connectdata *conn)
conn->mech = *m; conn->mech = *m;
conn->sec_complete = 1; conn->sec_complete = 1;
if (conn->data_prot != prot_clear) { if (conn->data_prot != prot_clear) {
conn->recv = sec_read; conn->recv[FIRSTSOCKET] = sec_read;
conn->send = _sec_send; conn->send[FIRSTSOCKET] = _sec_send;
conn->recv[SECONDARYSOCKET] = sec_read;
conn->send[SECONDARYSOCKET] = _sec_send;
} }
conn->command_prot = prot_safe; conn->command_prot = prot_safe;
/* Set the requested protection level */ /* Set the requested protection level */

View File

@ -251,7 +251,7 @@ CURLcode Curl_write(struct connectdata *conn,
CURLcode curlcode = CURLE_OK; CURLcode curlcode = CURLE_OK;
int num = (sockfd == conn->sock[SECONDARYSOCKET]); int num = (sockfd == conn->sock[SECONDARYSOCKET]);
bytes_written = conn->send(conn, num, mem, len, &curlcode); bytes_written = conn->send[num](conn, num, mem, len, &curlcode);
*written = bytes_written; *written = bytes_written;
if(-1 != bytes_written) if(-1 != bytes_written)
@ -576,7 +576,7 @@ CURLcode Curl_read(struct connectdata *conn, /* connection data */
buffertofill = buf; buffertofill = buf;
} }
nread = conn->recv(conn, num, buffertofill, bytesfromsocket, &curlcode); nread = conn->recv[num](conn, num, buffertofill, bytesfromsocket, &curlcode);
if(nread == -1) if(nread == -1)
return curlcode; return curlcode;

View File

@ -2493,11 +2493,11 @@ static CURLcode ssh_connect(struct connectdata *conn, bool *done)
return result; return result;
if(conn->protocol & PROT_SCP) { if(conn->protocol & PROT_SCP) {
conn->recv = scp_recv; conn->recv[FIRSTSOCKET] = scp_recv;
conn->send = scp_send; conn->send[FIRSTSOCKET] = scp_send;
} else { } else {
conn->recv = sftp_recv; conn->recv[FIRSTSOCKET] = sftp_recv;
conn->send = sftp_send; conn->send[FIRSTSOCKET] = sftp_send;
} }
ssh = &conn->proto.sshc; ssh = &conn->proto.sshc;

View File

@ -2440,8 +2440,8 @@ ossl_connect_common(struct connectdata *conn,
if(ssl_connect_done==connssl->connecting_state) { if(ssl_connect_done==connssl->connecting_state) {
connssl->state = ssl_connection_complete; connssl->state = ssl_connection_complete;
conn->recv = ossl_recv; conn->recv[sockindex] = ossl_recv;
conn->send = ossl_send; conn->send[sockindex] = ossl_send;
*done = TRUE; *done = TRUE;
} }
else else

View File

@ -4754,8 +4754,10 @@ static CURLcode create_conn(struct SessionHandle *data,
return result; return result;
} }
conn->recv = Curl_recv_plain; conn->recv[FIRSTSOCKET] = Curl_recv_plain;
conn->send = Curl_send_plain; conn->send[FIRSTSOCKET] = Curl_send_plain;
conn->recv[SECONDARYSOCKET] = Curl_recv_plain;
conn->send[SECONDARYSOCKET] = Curl_send_plain;
/*********************************************************************** /***********************************************************************
* file: is a special case in that it doesn't need a network connection * file: is a special case in that it doesn't need a network connection

View File

@ -760,8 +760,8 @@ struct connectdata {
curl_socket_t sock[2]; /* two sockets, the second is used for the data curl_socket_t sock[2]; /* two sockets, the second is used for the data
transfer when doing FTP */ transfer when doing FTP */
Curl_recv *recv; Curl_recv *recv[2];
Curl_send *send; Curl_send *send[2];
struct ssl_connect_data ssl[2]; /* this is for ssl-stuff */ struct ssl_connect_data ssl[2]; /* this is for ssl-stuff */
struct ssl_config_data ssl_config; struct ssl_config_data ssl_config;