mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
read and write as much as possible until end of data or EWOULDBLOCK before
returning back to the select() loop. Consider this a test so far.
This commit is contained in:
parent
081e5a82ff
commit
f6cdb820af
@ -164,6 +164,12 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
if((k->keepon & KEEP_READ) &&
|
||||
(FD_ISSET(conn->sockfd, readfdp))) {
|
||||
|
||||
bool readdone = FALSE;
|
||||
|
||||
/* This is where we loop until we have read everything there is to
|
||||
read or we get a EWOULDBLOCK */
|
||||
do {
|
||||
|
||||
/* read! */
|
||||
result = Curl_read(conn, conn->sockfd, k->buf,
|
||||
data->set.buffer_size?
|
||||
@ -189,6 +195,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
else if (0 >= nread) {
|
||||
k->keepon &= ~KEEP_READ;
|
||||
FD_ZERO(&k->rkeepfd);
|
||||
readdone = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -590,7 +597,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
else if(checkprefix("Last-Modified:", k->p) &&
|
||||
(data->set.timecondition || data->set.get_filetime) ) {
|
||||
time_t secs=time(NULL);
|
||||
k->timeofdoc = curl_getdate(k->p+strlen("Last-Modified:"),
|
||||
k->timeofdoc = curl_getdate(k->p+strlen("Last-Modified:"),
|
||||
&secs);
|
||||
if(data->set.get_filetime)
|
||||
data->info.filetime = k->timeofdoc;
|
||||
@ -824,6 +831,9 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
}
|
||||
|
||||
} /* if (! header and data to read ) */
|
||||
|
||||
} while(!readdone);
|
||||
|
||||
} /* if( read from socket ) */
|
||||
|
||||
/* If we still have writing to do, we check if we have a writable
|
||||
@ -836,12 +846,19 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
|
||||
int i, si;
|
||||
ssize_t bytes_written;
|
||||
bool writedone=FALSE;
|
||||
|
||||
if ((k->bytecount == 0) && (k->writebytecount == 0))
|
||||
Curl_pgrsTime(data, TIMER_STARTTRANSFER);
|
||||
|
||||
didwhat |= KEEP_WRITE;
|
||||
|
||||
/*
|
||||
* We loop here to do the READ and SEND loop until we run out of
|
||||
* data to send or until we get EWOULDBLOCK back
|
||||
*/
|
||||
do {
|
||||
|
||||
/* only read more data if there's no upload data already
|
||||
present in the upload buffer */
|
||||
if(0 == conn->upload_present) {
|
||||
@ -892,6 +909,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
/* done */
|
||||
k->keepon &= ~KEEP_WRITE; /* we're done writing */
|
||||
FD_ZERO(&k->wkeepfd);
|
||||
writedone = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -943,6 +961,8 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
/* advance the pointer where to find the buffer when the next send
|
||||
is to happen */
|
||||
conn->upload_fromhere += bytes_written;
|
||||
|
||||
writedone = TRUE; /* we are done, stop the loop */
|
||||
}
|
||||
else {
|
||||
/* we've uploaded that buffer now */
|
||||
@ -953,6 +973,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
/* switch off writing, we're done! */
|
||||
k->keepon &= ~KEEP_WRITE; /* we're done writing */
|
||||
FD_ZERO(&k->wkeepfd);
|
||||
writedone = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -964,6 +985,8 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
||||
k->writebytecount += bytes_written;
|
||||
Curl_pgrsSetUploadCounter(data, (double)k->writebytecount);
|
||||
|
||||
} while(!writedone); /* loop until we're done writing! */
|
||||
|
||||
}
|
||||
|
||||
} while(0); /* just to break out from! */
|
||||
|
Loading…
Reference in New Issue
Block a user