aboutsummaryrefslogtreecommitdiff
path: root/lib/transfer.c
diff options
context:
space:
mode:
authorHoward Chu <hyc@highlandsun.com>2010-05-07 15:05:34 +0200
committerDaniel Stenberg <daniel@haxx.se>2010-05-07 15:05:34 +0200
commitd64bd82bdcb169d0647a80f00068cedd761f8163 (patch)
tree222920db94e7d4ae7df6df1f9a9afd0b78159492 /lib/transfer.c
parentcb6647ce1cfba836203e91057752441302b9c46a (diff)
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/transfer.c')
-rw-r--r--lib/transfer.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/transfer.c b/lib/transfer.c
index 92a59d038..c9234a79d 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -376,12 +376,11 @@ 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;
size_t bytestoread = buffersize;
- int readrc;
if(k->size != -1 && !k->header) {
/* make sure we don't read "too much" if we can help it since we
@@ -394,15 +393,12 @@ static CURLcode readwrite_data(struct SessionHandle *data,
if(bytestoread) {
/* receive data from the network! */
- readrc = Curl_read(conn, conn->sockfd, k->buf, bytestoread, &nread);
+ result = Curl_read(conn, conn->sockfd, k->buf, bytestoread, &nread);
- /* subzero, this would've blocked */
- if(0 > readrc)
+ /* read would've blocked */
+ if(CURLE_AGAIN == result)
break; /* get out of loop */
- /* get the CURLcode from the int */
- result = (CURLcode)readrc;
-
if(result>0)
return result;
}