apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r553682 - /apr/apr/trunk/file_io/unix/fullrw.c
Date Fri, 06 Jul 2007 01:01:19 GMT
Author: davi
Date: Thu Jul  5 18:01:18 2007
New Revision: 553682

URL: http://svn.apache.org/viewvc?view=rev&rev=553682
Log:
Rework apr_file_writev_full so it tries to writev() data before resorting to
a plain write.

Modified:
    apr/apr/trunk/file_io/unix/fullrw.c

Modified: apr/apr/trunk/file_io/unix/fullrw.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/unix/fullrw.c?view=diff&rev=553682&r1=553681&r2=553682
==============================================================================
--- apr/apr/trunk/file_io/unix/fullrw.c (original)
+++ apr/apr/trunk/file_io/unix/fullrw.c Thu Jul  5 18:01:18 2007
@@ -72,10 +72,36 @@
     apr_size_t amt = 0;
     apr_size_t total = 0;
 
-    for (i = 0; i < nvec && rv == APR_SUCCESS; i++) {
-        rv = apr_file_write_full(thefile, vec[i].iov_base, 
+    for (i = 0; i < nvec; i++) {
+        total += vec[i].iov_len;
+    }
+
+    rv = apr_file_writev(thefile, vec, nvec, &amt);
+
+    if (bytes_written != NULL)
+        *bytes_written = amt;
+
+    if (rv != APR_SUCCESS || (amt == total)) {
+        return rv;
+    }
+
+    for (i = 0; i < nvec && amt; i++) {
+        if (amt >= vec[i].iov_len) {
+            amt -= vec[i].iov_len;
+        }
+        else {
+            break;
+        }
+    }
+
+    if (amt) {
+        rv = apr_file_write_full(thefile, vec[i].iov_base + amt,
+                                 vec[i].iov_len - amt, NULL);
+    }
+
+    for (; i < nvec && rv == APR_SUCCESS; i++) {
+        rv = apr_file_write_full(thefile, vec[i].iov_base,
                                  vec[i].iov_len, &amt);
-        total += amt;
     }
 
     if (bytes_written != NULL)



Mime
View raw message