mirror of
https://github.com/curl/curl.git
synced 2026-08-25 17:33:32 +03:00
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.
This commit is contained in:
parent
cb6647ce1c
commit
d64bd82bdc
26 changed files with 297 additions and 433 deletions
19
lib/telnet.c
19
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue