aboutsummaryrefslogtreecommitdiff
path: root/lib/telnet.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/telnet.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/telnet.c')
-rw-r--r--lib/telnet.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/telnet.c b/lib/telnet.c
index e7f05eb91..b94415db5 100644
--- a/lib/telnet.c
+++ b/lib/telnet.c
@@ -1209,7 +1209,6 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
struct pollfd pfd[2];
int poll_cnt;
#endif
- int ret;
ssize_t nread;
struct timeval now;
bool keepon = TRUE;
@@ -1383,14 +1382,13 @@ 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)
+ code = Curl_read(conn, sockfd, buf, BUFSIZE - 1, &nread);
+ /* read would've blocked. Loop again */
+ if(code == CURLE_AGAIN)
break;
/* returned not-zero, this an error */
- else if(ret) {
+ else if(code) {
keepon = FALSE;
- code = (CURLcode)ret;
break;
}
/* returned zero but actually received 0 or less here,
@@ -1472,14 +1470,13 @@ static CURLcode telnet_do(struct connectdata *conn, bool *done)
default: /* read! */
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)
+ code = Curl_read(conn, sockfd, buf, BUFSIZE - 1, &nread);
+ /* read would've blocked. Loop again */
+ if(code == CURLE_AGAIN)
break;
/* returned not-zero, this an error */
- else if(ret) {
+ else if(code) {
keepon = FALSE;
- code = (CURLcode)ret;
break;
}
/* returned zero but actually received 0 or less here,