apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pque...@apache.org
Subject svn commit: r111571 - /apr/apr/trunk/CHANGES /apr/apr/trunk/file_io/unix/readwrite.c
Date Sat, 11 Dec 2004 03:53:08 GMT
Author: pquerna
Date: Fri Dec 10 19:53:06 2004
New Revision: 111571

URL: http://svn.apache.org/viewcvs?view=rev&rev=111571
Log:
* file_io/unix/readwrite.c: Revert to the original code for apr_file writev() in the !HAVE_WRITEV
case, and a large comment 
                            explaining why we cannot use a better method without breaking
writev()'s semantics.

Modified:
   apr/apr/trunk/CHANGES
   apr/apr/trunk/file_io/unix/readwrite.c

Modified: apr/apr/trunk/CHANGES
Url: http://svn.apache.org/viewcvs/apr/apr/trunk/CHANGES?view=diff&rev=111571&p1=apr/apr/trunk/CHANGES&r1=111570&p2=apr/apr/trunk/CHANGES&r2=111571
==============================================================================
--- apr/apr/trunk/CHANGES	(original)
+++ apr/apr/trunk/CHANGES	Fri Dec 10 19:53:06 2004
@@ -10,10 +10,6 @@
   *) Add apr_file_writev_full to ensure an entire iovec is writen to a file.
      [Paul Querna]
 
-  *) apr_file_writev will now at least try to write all iovecs on platforms
-     that do not support writev. 
-     [Paul Querna]
-
   *) Remove the runtime test for Sendfile versions on FreeBSD. PR 25718.
      [Mike Silbersack <silby silby.com>, Paul Querna]
 

Modified: apr/apr/trunk/file_io/unix/readwrite.c
Url: http://svn.apache.org/viewcvs/apr/apr/trunk/file_io/unix/readwrite.c?view=diff&rev=111571&p1=apr/apr/trunk/file_io/unix/readwrite.c&r1=111570&p2=apr/apr/trunk/file_io/unix/readwrite.c&r2=111571
==============================================================================
--- apr/apr/trunk/file_io/unix/readwrite.c	(original)
+++ apr/apr/trunk/file_io/unix/readwrite.c	Fri Dec 10 19:53:06 2004
@@ -241,21 +241,22 @@
         return APR_SUCCESS;
     }
 #else
-    int i;
-    int tbytes;
-    apr_status_t rv = APR_SUCCESS;
+    /**
+     * The problem with trying to output the entire iovec is that we cannot
+     * maintain the behavoir that a real writev would have.  If we iterate
+     * over the iovec one at a time, we loose the atomic properties of 
+     * writev().  The other option is to combine the entire iovec into one
+     * buffer that we could then send in one call to write().  This is not 
+     * reasonable since we do not know how much data an iocev could contain.
+     *
+     * The only reasonable option, that maintains the semantics of a real 
+     * writev(), is to only write the first iovec.  Callers of file_writev()
+     * must deal with partial writes as they normally would. If you want to 
+     * ensure an entire iovec is written, use apr_file_writev_full().
+     */
 
-    *nbytes = 0;
-
-    for (i = 0; i < nvec; i++) {
-         tbytes = vec[i].iov_len;
-         rv = apr_file_write(thefile, vec[i].iov_base, &tbytes);
-         *nbytes += tbytes;
-         if (rv != APR_SUCCESS || tbytes < vec[i].iov_len) {
-             break;
-         }
-    }
-    return rv;
+    *nbytes = vec[0].iov_len;
+    return apr_file_write(thefile, vec[0].iov_base, nbytes);
 #endif
 }
 

Mime
View raw message