You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2009/02/01 13:49:53 UTC

svn commit: r739755 - in /apr/apr/branches/1.3.x: CHANGES network_io/unix/sendrecv.c

Author: trawick
Date: Sun Feb  1 12:49:53 2009
New Revision: 739755

URL: http://svn.apache.org/viewvc?rev=739755&view=rev
Log:
backport r739640 from trunk

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.

Modified:
    apr/apr/branches/1.3.x/CHANGES
    apr/apr/branches/1.3.x/network_io/unix/sendrecv.c

Modified: apr/apr/branches/1.3.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/CHANGES?rev=739755&r1=739754&r2=739755&view=diff
==============================================================================
--- apr/apr/branches/1.3.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.3.x/CHANGES [utf-8] Sun Feb  1 12:49:53 2009
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.3.4
 
+  *) 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.)  [Jeff Trawick]
+
   *) Fix documentation for apr_temp_dir_get().
      PR 46303  [Carlo Marcelo Arenas Belon <carenas sajinet.com.pe>]
 

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=739755&r1=739754&r2=739755&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 Sun Feb  1 12:49:53 2009
@@ -1083,6 +1083,14 @@
 
     /* 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;
     }