Author: jim
Date: Thu May 15 09:26:01 2008
New Revision: 656722
URL: http://svn.apache.org/viewvc?rev=656722&view=rev
Log:
Merge r656659 from trunk:
Darwin sendfile() cleanup.
First, remove extra code. Secondly, don't update len and
offset within this loop; we just want to check for errors
and finally:
When using a socket marked for non-blocking I/O, sendfile() may send fewer bytes than
requested. In
this case, the number of bytes successfully sent is returned in the via the len parameters
and the
error EAGAIN is returned.
so when this happens, return with a success anytime we've
sent data.
Reviewed by: jim
Modified:
apr/apr/branches/1.3.x/network_io/unix/sendrecv.c
Modified: apr/apr/branches/1.3.x/network_io/unix/sendrecv.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/network_io/unix/sendrecv.c?rev=656722&r1=656721&r2=656722&view=diff
==============================================================================
--- apr/apr/branches/1.3.x/network_io/unix/sendrecv.c (original)
+++ apr/apr/branches/1.3.x/network_io/unix/sendrecv.c Thu May 15 09:26:01 2008
@@ -472,9 +472,6 @@
NULL, /* Headers/footers */
flags); /* undefined, set to 0 */
- bytes_sent += nbytes;
- bytes_to_send -= nbytes;
- (*offset) += nbytes;
if (rv == -1) {
if (errno == EAGAIN) {
if (sock->timeout > 0) {
@@ -484,7 +481,8 @@
* sent bytes. Sanitize the result so we get normal EAGAIN
* semantics w.r.t. bytes sent.
*/
- else if (nbytes) {
+ if (nbytes) {
+ bytes_sent += nbytes;
/* normal exit for a big file & non-blocking io */
(*len) = bytes_sent;
return APR_SUCCESS;
@@ -492,6 +490,7 @@
}
}
else { /* rv == 0 (or the kernel is broken) */
+ bytes_sent += nbytes;
if (nbytes == 0) {
/* Most likely the file got smaller after the stat.
* Return an error so the caller can do the Right Thing.
@@ -500,10 +499,6 @@
return APR_EOF;
}
}
-
- if ((rv == -1) && (errno == EAGAIN) && (sock->timeout > 0))
{
- sock->options |= APR_INCOMPLETE_WRITE;
- }
} while (rv == -1 && (errno == EINTR || errno == EAGAIN));
/* Now write the footers */
|