apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r656659 - /apr/apr/trunk/network_io/unix/sendrecv.c
Date Thu, 15 May 2008 13:38:39 GMT
Author: jim
Date: Thu May 15 06:38:39 2008
New Revision: 656659

URL: http://svn.apache.org/viewvc?rev=656659&view=rev
Log:
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.

Modified:
    apr/apr/trunk/network_io/unix/sendrecv.c

Modified: apr/apr/trunk/network_io/unix/sendrecv.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/network_io/unix/sendrecv.c?rev=656659&r1=656658&r2=656659&view=diff
==============================================================================
--- apr/apr/trunk/network_io/unix/sendrecv.c (original)
+++ apr/apr/trunk/network_io/unix/sendrecv.c Thu May 15 06:38:39 2008
@@ -472,9 +472,6 @@
                       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 @@
                  * 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 @@
             }
         }
         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 @@
                 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 */



Mime
View raw message