diff options
author | Jeff Trawick <trawick@apache.org> | 2009-01-31 22:12:11 +0000 |
---|---|---|
committer | Jeff Trawick <trawick@apache.org> | 2009-01-31 22:12:11 +0000 |
commit | de76de0dfeb60879c52effad40659dc9aabe7095 (patch) | |
tree | b4858d609765d55e080168fdcb307f1718e5a0cf /network_io | |
parent | a3143b97048c636fba87ea6f218f9cd946bc7c7c (diff) | |
download | apr-de76de0dfeb60879c52effad40659dc9aabe7095.tar.gz |
apr_socket_sendfile() on Solaris: Fix handling of files truncated
after the sender determines the length. (This fixes a busy loop in
httpd when a file being served is truncated.)
Some other implementations of apr_socket_sendfile() were already
patched along the way to handle this; some apparently remain broken.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@739640 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'network_io')
-rw-r--r-- | network_io/unix/sendrecv.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/network_io/unix/sendrecv.c b/network_io/unix/sendrecv.c index ce6d01276..c133a26d9 100644 --- a/network_io/unix/sendrecv.c +++ b/network_io/unix/sendrecv.c @@ -1083,6 +1083,14 @@ apr_status_t apr_socket_sendfile(apr_socket_t *sock, apr_file_t *file, /* Update how much we sent */ *len = nbytes; + + if (nbytes == 0) { + /* Most likely the file got smaller after the stat. + * Return an error so the caller can do the Right Thing. + */ + return APR_EOF; + } + if ((sock->timeout > 0) && (*len < requested_len)) { sock->options |= APR_INCOMPLETE_WRITE; } |