Ugh, I actually broke apr_socket_sendfile on OS X when I cleaned up my
code for submission. Here is a patch for my patch.
Fixes are:
1. nbytes is initialized properly so if we only send the header we
don't lie and say we sent header bytes + file length.
- apr_off_t nbytes = *len;
+ apr_off_t nbytes = 0;
2. Vestigial code removed.
- else {
- header_bytes_written = 0;
- }
3. Bytes sent in the header are now counted.
- (*len) = nbytes;
+ (*len) = nbytes + header_bytes_written;
Patch attached, hopefully in text/plain.
Geoff
Index: sendrecv.c
===================================================================
--- sendrecv.c (revision 651459)
+++ sendrecv.c (working copy)
@@ -410,7 +410,7 @@
apr_hdtr_t * hdtr, apr_off_t * offset,
apr_size_t * len, apr_int32_t flags)
{
- apr_off_t nbytes = *len;
+ apr_off_t nbytes = 0;
apr_off_t bytes_to_send = *len;
apr_size_t header_bytes_written = 0;
int rv;
@@ -445,9 +445,6 @@
header_bytes_written = rv;
rv = 0;
}
- else {
- header_bytes_written = 0;
- }
}
else if (bytes_to_send) {
/* We won't dare call sendfile() if we don't have
@@ -513,7 +510,7 @@
}
} while (rv == -1 && (errno == EINTR || errno == EAGAIN));
- (*len) = nbytes;
+ (*len) = nbytes + header_bytes_written;
if (rv == -1) {
return errno;
}
On Apr 24, 2008, at 12:44 PM, Geoff Greer wrote:
Instead of my last suggestion to disable sendfile on 10.5, I've fixed
apr_socket_sendfile. The patch is attached. You can apply it by
checking
out trunk:
cd apr/network_io/unix
patch -p0 < sendrecv.c.patch
Now the sendfile test case passes on OS X. This is my first real
patch, so
suggestions are welcome.
Geoff<sendrecv.c.patch>