1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04: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:
Daniel Stenberg 2002-12-05 14:26:30 +00:00
parent 081e5a82ff
commit f6cdb820af

View File

@ -164,6 +164,12 @@ CURLcode Curl_readwrite(struct connectdata *conn,
if((k->keepon & KEEP_READ) && if((k->keepon & KEEP_READ) &&
(FD_ISSET(conn->sockfd, readfdp))) { (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! */ /* read! */
result = Curl_read(conn, conn->sockfd, k->buf, result = Curl_read(conn, conn->sockfd, k->buf,
data->set.buffer_size? data->set.buffer_size?
@ -189,6 +195,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
else if (0 >= nread) { else if (0 >= nread) {
k->keepon &= ~KEEP_READ; k->keepon &= ~KEEP_READ;
FD_ZERO(&k->rkeepfd); FD_ZERO(&k->rkeepfd);
readdone = TRUE;
break; break;
} }
@ -590,7 +597,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
else if(checkprefix("Last-Modified:", k->p) && else if(checkprefix("Last-Modified:", k->p) &&
(data->set.timecondition || data->set.get_filetime) ) { (data->set.timecondition || data->set.get_filetime) ) {
time_t secs=time(NULL); time_t secs=time(NULL);
k->timeofdoc = curl_getdate(k->p+strlen("Last-Modified:"), k->timeofdoc = curl_getdate(k->p+strlen("Last-Modified:"),
&secs); &secs);
if(data->set.get_filetime) if(data->set.get_filetime)
data->info.filetime = k->timeofdoc; data->info.filetime = k->timeofdoc;
@ -824,6 +831,9 @@ CURLcode Curl_readwrite(struct connectdata *conn,
} }
} /* if (! header and data to read ) */ } /* if (! header and data to read ) */
} while(!readdone);
} /* if( read from socket ) */ } /* if( read from socket ) */
/* If we still have writing to do, we check if we have a writable /* 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; int i, si;
ssize_t bytes_written; ssize_t bytes_written;
bool writedone=FALSE;
if ((k->bytecount == 0) && (k->writebytecount == 0)) if ((k->bytecount == 0) && (k->writebytecount == 0))
Curl_pgrsTime(data, TIMER_STARTTRANSFER); Curl_pgrsTime(data, TIMER_STARTTRANSFER);
didwhat |= KEEP_WRITE; 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 /* only read more data if there's no upload data already
present in the upload buffer */ present in the upload buffer */
if(0 == conn->upload_present) { if(0 == conn->upload_present) {
@ -892,6 +909,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* done */ /* done */
k->keepon &= ~KEEP_WRITE; /* we're done writing */ k->keepon &= ~KEEP_WRITE; /* we're done writing */
FD_ZERO(&k->wkeepfd); FD_ZERO(&k->wkeepfd);
writedone = TRUE;
break; break;
} }
@ -943,6 +961,8 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* advance the pointer where to find the buffer when the next send /* advance the pointer where to find the buffer when the next send
is to happen */ is to happen */
conn->upload_fromhere += bytes_written; conn->upload_fromhere += bytes_written;
writedone = TRUE; /* we are done, stop the loop */
} }
else { else {
/* we've uploaded that buffer now */ /* we've uploaded that buffer now */
@ -953,6 +973,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
/* switch off writing, we're done! */ /* switch off writing, we're done! */
k->keepon &= ~KEEP_WRITE; /* we're done writing */ k->keepon &= ~KEEP_WRITE; /* we're done writing */
FD_ZERO(&k->wkeepfd); FD_ZERO(&k->wkeepfd);
writedone = TRUE;
} }
} }
@ -964,6 +985,8 @@ CURLcode Curl_readwrite(struct connectdata *conn,
k->writebytecount += bytes_written; k->writebytecount += bytes_written;
Curl_pgrsSetUploadCounter(data, (double)k->writebytecount); Curl_pgrsSetUploadCounter(data, (double)k->writebytecount);
} while(!writedone); /* loop until we're done writing! */
} }
} while(0); /* just to break out from! */ } while(0); /* just to break out from! */