Index: test/Makefile.in =================================================================== --- test/Makefile.in (revision 651655) +++ test/Makefile.in (working copy) @@ -159,6 +159,8 @@ $(LINK_PROG) $(OBJECTS_tryread) $(ALL_LIBS) check: $(TESTALL_COMPONENTS) $(STDTEST_PORTABLE) $(STDTEST_NONPORTABLE) + @shlibpath_var@=../.libs:$$(@shlibpath_var@);\ + export @shlibpath_var@ teststatus=0; \ progfailed=""; \ for prog in $(STDTEST_PORTABLE) $(STDTEST_NONPORTABLE); do \ Index: network_io/unix/sendrecv.c =================================================================== --- network_io/unix/sendrecv.c (revision 651655) +++ network_io/unix/sendrecv.c (working copy) @@ -413,7 +413,7 @@ apr_off_t nbytes = 0; apr_off_t bytes_to_send = *len; apr_size_t header_bytes_written = 0; - int rv; + int rv = 0; /* Ignore flags for now. */ flags = 0; @@ -445,8 +445,12 @@ header_bytes_written = rv; rv = 0; } + /* XXX: Bogus, decrement hd->headers/numheaders by those + * sent, prepare for resend for !APR_INCOMPLETE_WRITE + */ } - else if (bytes_to_send) { + + if ((rv >= 0) && bytes_to_send) { /* We won't dare call sendfile() if we don't have * header or file bytes to send because nbytes == 0 * means send the remaining file to EOF. @@ -458,23 +462,25 @@ &nbytes, /* number of bytes to write/written */ NULL, /* Headers/footers */ flags); /* undefined, set to 0 */ + bytes_to_send -= nbytes; - bytes_to_send -= nbytes; if (rv == -1) { if (errno == EAGAIN) { if (sock->timeout > 0) { sock->options |= APR_INCOMPLETE_WRITE; + rv = 0; } /* BSD's sendfile can return -1/EAGAIN even if it * sent bytes. Sanitize the result so we get normal EAGAIN * semantics w.r.t. bytes sent. */ - if (nbytes) { + else if (nbytes) { /* normal exit for a big file & non-blocking io */ (*len) = nbytes + header_bytes_written; return APR_SUCCESS; } } + /* XXX else ??? */ } else { /* rv == 0 (or the kernel is broken) */ if (nbytes == 0) { @@ -500,14 +506,11 @@ nbytes = 0; } } - if ((rv == -1) && (errno == EAGAIN) - && (sock->timeout > 0)) { - apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0); - if (arv != APR_SUCCESS) { - *len = 0; - return arv; - } + + if ((rv == -1) && (errno == EAGAIN) && (sock->timeout > 0)) { + sock->options |= APR_INCOMPLETE_WRITE; } + } while (rv == -1 && (errno == EINTR || errno == EAGAIN)); (*len) = nbytes + header_bytes_written;