diff --git a/lib/easy.c b/lib/easy.c index 53f417f..796ff90 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -1120,9 +1120,6 @@ CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen, size_t *n) *n = 0; ret1 = Curl_read(c, sfd, buffer, buflen, &n1); - if(ret1 == -1) - return CURLE_AGAIN; - if(ret1 != CURLE_OK) return (CURLcode)ret1; diff --git a/lib/http.c b/lib/http.c index fc01ee8..c6a6418 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1468,8 +1468,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn, default: DEBUGASSERT(ptr+BUFSIZE-nread <= data->state.buffer+BUFSIZE+1); res = Curl_read(conn, tunnelsocket, ptr, BUFSIZE-nread, &gotbytes); - if(res< 0) - /* EWOULDBLOCK */ + if(res==CURLE_AGAIN) continue; /* go loop yourself */ else if(res) keepon = FALSE; diff --git a/lib/pingpong.c b/lib/pingpong.c index c6b6f2f..6172833 100644 --- a/lib/pingpong.c +++ b/lib/pingpong.c @@ -340,8 +340,7 @@ CURLcode Curl_pp_readresp(curl_socket_t sockfd, #if defined(HAVE_KRB4) || defined(HAVE_GSSAPI) conn->data_prot = prot; #endif - if(res < 0) - /* EWOULDBLOCK */ + if(res == CURLE_AGAIN) return CURLE_OK; /* return */ #ifdef CURL_DOES_CONVERSIONS diff --git a/lib/sendf.c b/lib/sendf.c index 4843214..1693a46 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -238,7 +238,7 @@ CURLcode Curl_sendf(curl_socket_t sockfd, struct connectdata *conn, * Curl_write() is an internal write function that sends data to the * server. Works with plain sockets, SCP, SSL or kerberos. * - * If the write would block (EWOULDBLOCK), we return CURLE_OK and + * If the write would block (CURLE_AGAIN), we return CURLE_OK and * (*written == 0). Otherwise we return regular CURLcode value. */ CURLcode Curl_write(struct connectdata *conn, @@ -258,7 +258,7 @@ CURLcode Curl_write(struct connectdata *conn, /* we completely ignore the curlcode value when -1 is not returned */ return CURLE_OK; - /* handle EWOULDBLOCK or a send failure */ + /* handle CURLE_AGAIN or a send failure */ switch(curlcode) { case CURLE_AGAIN: *written = 0; @@ -437,7 +437,7 @@ CURLcode Curl_client_write(struct connectdata *conn, return CURLE_OK; } -int Curl_read_plain(curl_socket_t sockfd, +CURLcode Curl_read_plain(curl_socket_t sockfd, char *buf, size_t bytesfromsocket, ssize_t *n) @@ -451,7 +451,7 @@ int Curl_read_plain(curl_socket_t sockfd, #else if((EWOULDBLOCK == err) || (EAGAIN == err) || (EINTR == err)) #endif - return -1; + return CURLE_AGAIN; else return CURLE_RECV_ERROR; } @@ -465,10 +465,9 @@ int Curl_read_plain(curl_socket_t sockfd, * Internal read-from-socket function. This is meant to deal with plain * sockets, SSL sockets and kerberos sockets. * - * If the read would block (EWOULDBLOCK) we return -1. Otherwise we return - * a regular CURLcode value. + * Returns a regular CURLcode value. */ -int Curl_read(struct connectdata *conn, /* connection data */ +CURLcode Curl_read(struct connectdata *conn, /* connection data */ curl_socket_t sockfd, /* read from this socket */ char *buf, /* store read data here */ size_t sizerequested, /* max amount to read */ diff --git a/lib/sendf.h b/lib/sendf.h index 5732a0b..ed3b3a5 100644 --- a/lib/sendf.h +++ b/lib/sendf.h @@ -55,13 +55,13 @@ CURLcode Curl_client_write(struct connectdata *conn, int type, char *ptr, size_t len); /* internal read-function, does plain socket only */ -int Curl_read_plain(curl_socket_t sockfd, +CURLcode Curl_read_plain(curl_socket_t sockfd, char *buf, size_t bytesfromsocket, ssize_t *n); /* internal read-function, does plain socket, SSL and krb4 */ -int Curl_read(struct connectdata *conn, curl_socket_t sockfd, +CURLcode Curl_read(struct connectdata *conn, curl_socket_t sockfd, char *buf, size_t buffersize, ssize_t *n); /* internal write-function, does plain socket, SSL, SCP, SFTP and krb4 */ diff --git a/lib/telnet.c b/lib/telnet.c index e7f05eb..3bbbc3d 100644 --- a/lib/telnet.c +++ b/lib/telnet.c @@ -1384,8 +1384,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) if(events.lNetworkEvents & FD_READ) { /* read data from network */ ret = Curl_read(conn, sockfd, buf, BUFSIZE - 1, &nread); - /* returned sub-zero, this would've blocked. Loop again */ - if(ret < 0) + /* read would've blocked. Loop again */ + if(ret == CURLE_AGAIN) break; /* returned not-zero, this an error */ else if(ret) { @@ -1473,8 +1473,8 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done) if(pfd[0].revents & POLLIN) { /* read data from network */ ret = Curl_read(conn, sockfd, buf, BUFSIZE - 1, &nread); - /* returned sub-zero, this would've blocked. Loop again */ - if(ret < 0) + /* read would've blocked. Loop again */ + if(ret == CURLE_AGAIN) break; /* returned not-zero, this an error */ else if(ret) { diff --git a/lib/transfer.c b/lib/transfer.c index 92a59d0..2635582 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -376,7 +376,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, *done = FALSE; /* This is where we loop until we have read everything there is to - read or we get a EWOULDBLOCK */ + read or we get a CURLE_AGAIN */ do { size_t buffersize = data->set.buffer_size? data->set.buffer_size : BUFSIZE; @@ -396,8 +396,8 @@ static CURLcode readwrite_data(struct SessionHandle *data, /* receive data from the network! */ readrc = Curl_read(conn, conn->sockfd, k->buf, bytestoread, &nread); - /* subzero, this would've blocked */ - if(0 > readrc) + /* read would've blocked */ + if(CURLE_AGAIN == readrc) break; /* get out of loop */ /* get the CURLcode from the int */