summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjim <jim@13f79535-47bb-0310-9956-ffa450edef68>2008-05-15 13:38:39 +0000
committerjim <jim@13f79535-47bb-0310-9956-ffa450edef68>2008-05-15 13:38:39 +0000
commit47506f40353098426f101d5a1562e3ebcd3838ca (patch)
tree9c37375bdab33d2f04019f1ecda30442c63a0c9a
parent930294b94772e9e3ffb8cfc50c6b3212166fb3de (diff)
downloadlibapr-47506f40353098426f101d5a1562e3ebcd3838ca.tar.gz
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. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@656659 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--network_io/unix/sendrecv.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/network_io/unix/sendrecv.c b/network_io/unix/sendrecv.c
index e3ac058c1..ce6d01276 100644
--- a/network_io/unix/sendrecv.c
+++ b/network_io/unix/sendrecv.c
@@ -472,9 +472,6 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
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 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
* 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 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
}
}
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 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file,
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 */