diff options
author | Howard Chu <hyc@highlandsun.com> | 2010-05-07 15:05:34 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2010-05-07 15:05:34 +0200 |
commit | d64bd82bdcb169d0647a80f00068cedd761f8163 (patch) | |
tree | 222920db94e7d4ae7df6df1f9a9afd0b78159492 /lib/polarssl.c | |
parent | cb6647ce1cfba836203e91057752441302b9c46a (diff) | |
download | curl-d64bd82bdcb169d0647a80f00068cedd761f8163.tar.gz |
sendrecv: split the I/O handling into private handler
Howard Chu brought the bulk work of this patch that properly
moves out the sending and recving of data to the parts of the
code that are properly responsible for the various ways of doing
so.
Daniel Stenberg assisted with polishing a few bits and fixed some
minor flaws in the original patch.
Another upside of this patch is that we now abuse CURLcodes less
with the "magic" -1 return codes and instead use CURLE_AGAIN more
consistently.
Diffstat (limited to 'lib/polarssl.c')
-rw-r--r-- | lib/polarssl.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/lib/polarssl.c b/lib/polarssl.c index 95baa1320..0027e31e0 100644 --- a/lib/polarssl.c +++ b/lib/polarssl.c @@ -76,6 +76,9 @@ static void polarssl_debug(void *context, int level, char *line) #else #endif +static Curl_recv polarssl_recv; +static Curl_send polarssl_send; + /* * This function loads all the client/CA certificates and CRLs. Setup the TLS * layer and do all necessary magic. @@ -299,6 +302,8 @@ Curl_polarssl_connect(struct connectdata *conn, } conn->ssl[sockindex].state = ssl_connection_complete; + conn->recv = polarssl_recv; + conn->send = polarssl_send; /* Save the current session data for possible re-use */ { @@ -319,12 +324,11 @@ Curl_polarssl_connect(struct connectdata *conn, return CURLE_OK; } -/* for documentation see Curl_ssl_send() in sslgen.h */ -ssize_t Curl_polarssl_send(struct connectdata *conn, - int sockindex, - const void *mem, - size_t len, - int *curlcode) +static ssize_t polarssl_send(struct connectdata *conn, + int sockindex, + const void *mem, + size_t len, + CURLcode *curlcode) { int ret = -1; @@ -332,7 +336,8 @@ ssize_t Curl_polarssl_send(struct connectdata *conn, (unsigned char *)mem, len); if(ret < 0) { - *curlcode = (ret == POLARSSL_ERR_NET_TRY_AGAIN) ? -1 : CURLE_SEND_ERROR; + *curlcode = (ret == POLARSSL_ERR_NET_TRY_AGAIN) ? + CURLE_AGAIN : CURLE_SEND_ERROR; ret = -1; } @@ -355,12 +360,11 @@ void Curl_polarssl_close(struct connectdata *conn, int sockindex) ssl_free(&conn->ssl[sockindex].ssl); } -/* for documentation see Curl_ssl_recv() in sslgen.h */ -ssize_t Curl_polarssl_recv(struct connectdata *conn, - int num, - char *buf, - size_t buffersize, - int *curlcode) +static ssize_t polarssl_recv(struct connectdata *conn, + int num, + char *buf, + size_t buffersize, + CURLcode *curlcode) { int ret = -1; ssize_t len = -1; @@ -369,7 +373,8 @@ ssize_t Curl_polarssl_recv(struct connectdata *conn, ret = ssl_read(&conn->ssl[num].ssl, (unsigned char *)buf, buffersize); if(ret <= 0) { - *curlcode = (ret == POLARSSL_ERR_NET_TRY_AGAIN) ? -1 : CURLE_RECV_ERROR; + *curlcode = (ret == POLARSSL_ERR_NET_TRY_AGAIN) ? + CURLE_AGAIN : CURLE_RECV_ERROR; return -1; } |