apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pque...@apache.org
Subject svn commit: r109832 - /apr/apr/trunk/CHANGES /apr/apr/trunk/file_io/unix/readwrite.c /apr/apr/trunk/test/Makefile.in /apr/apr/trunk/test/data /apr/apr/trunk/test/testfile.c
Date Sat, 04 Dec 2004 23:40:37 GMT
Author: pquerna
Date: Sat Dec  4 15:40:37 2004
New Revision: 109832

URL: http://svn.apache.org/viewcvs?view=rev&rev=109832
Log:
* test/testfile.c: Add a test for apr_file_writev().
* file_io/unix/readwrite.c: Try to write all iovecs out on platforms without writev.

Modified:
   apr/apr/trunk/CHANGES
   apr/apr/trunk/file_io/unix/readwrite.c
   apr/apr/trunk/test/Makefile.in
   apr/apr/trunk/test/data/   (props changed)
   apr/apr/trunk/test/testfile.c

Modified: apr/apr/trunk/CHANGES
Url: http://svn.apache.org/viewcvs/apr/apr/trunk/CHANGES?view=diff&rev=109832&p1=apr/apr/trunk/CHANGES&r1=109831&p2=apr/apr/trunk/CHANGES&r2=109832
==============================================================================
--- apr/apr/trunk/CHANGES	(original)
+++ apr/apr/trunk/CHANGES	Sat Dec  4 15:40:37 2004
@@ -1,5 +1,9 @@
 Changes for APR 1.1.0
 
+  *) 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=109832&p1=apr/apr/trunk/file_io/unix/readwrite.c&r1=109831&p2=apr/apr/trunk/file_io/unix/readwrite.c&r2=109832
==============================================================================
--- apr/apr/trunk/file_io/unix/readwrite.c	(original)
+++ apr/apr/trunk/file_io/unix/readwrite.c	Sat Dec  4 15:40:37 2004
@@ -241,8 +241,17 @@
         return APR_SUCCESS;
     }
 #else
-    *nbytes = vec[0].iov_len;
-    return apr_file_write(thefile, vec[0].iov_base, nbytes);
+    int i, tbytes;
+    apr_status_t rv = APR_SUCCESS;
+
+    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)
+             break;
+    }
+    return rv;
 #endif
 }
 

Modified: apr/apr/trunk/test/Makefile.in
Url: http://svn.apache.org/viewcvs/apr/apr/trunk/test/Makefile.in?view=diff&rev=109832&p1=apr/apr/trunk/test/Makefile.in&r1=109831&p2=apr/apr/trunk/test/Makefile.in&r2=109832
==============================================================================
--- apr/apr/trunk/test/Makefile.in	(original)
+++ apr/apr/trunk/test/Makefile.in	Sat Dec  4 15:40:37 2004
@@ -31,7 +31,7 @@
 CLEAN_TARGETS = testfile.tmp mod_test.slo proc_child@EXEEXT@ occhild@EXEEXT@ \
 	readchild@EXEEXT@ tryread@EXEEXT@ sockchild@EXEEXT@ \
 	globalmutexchild@EXEEXT@ lfstests/large.bin \
-	data/testputs.txt data/testbigfprintf.dat
+	data/testputs.txt data/testbigfprintf.dat data/testwritev.txt
 CLEAN_SUBDIRS = internal
 
 INCDIR=../include

Modified: apr/apr/trunk/test/testfile.c
Url: http://svn.apache.org/viewcvs/apr/apr/trunk/test/testfile.c?view=diff&rev=109832&p1=apr/apr/trunk/test/testfile.c&r1=109831&p2=apr/apr/trunk/test/testfile.c&r2=109832
==============================================================================
--- apr/apr/trunk/test/testfile.c	(original)
+++ apr/apr/trunk/test/testfile.c	Sat Dec  4 15:40:37 2004
@@ -553,6 +553,48 @@
     file_contents_equal(tc, fname, LINE1 LINE2, strlen(LINE1 LINE2));
 }
 
+static void test_writev(abts_case *tc, void *data)
+{
+    apr_file_t *f;
+    int nbytes;
+    struct iovec vec[5];
+    const char *fname = "data/testwritev.txt";
+
+    APR_ASSERT_SUCCESS(tc, "open file for writing",
+                       apr_file_open(&f, fname, 
+                                     APR_WRITE|APR_CREATE|APR_TRUNCATE, 
+                                     APR_OS_DEFAULT, p));
+    
+    vec[0].iov_base = LINE1;
+    vec[0].iov_len = strlen(LINE1);
+
+    APR_ASSERT_SUCCESS(tc, "writev of size 1 to file",
+                       apr_file_writev(f, vec, 1, &nbytes));
+
+    file_contents_equal(tc, fname, LINE1, strlen(LINE1));
+    
+    vec[0].iov_base = LINE1;
+    vec[0].iov_len = strlen(LINE1);
+    vec[1].iov_base = LINE2;
+    vec[1].iov_len = strlen(LINE2);
+    vec[2].iov_base = LINE1;
+    vec[2].iov_len = strlen(LINE1);
+    vec[3].iov_base = LINE1;
+    vec[3].iov_len = strlen(LINE1);
+    vec[4].iov_base = LINE2;
+    vec[4].iov_len = strlen(LINE2);
+
+    APR_ASSERT_SUCCESS(tc, "writev of size 5 to file",
+                       apr_file_writev(f, vec, 5, &nbytes));
+
+    APR_ASSERT_SUCCESS(tc, "close for writing",
+                       apr_file_close(f));
+
+    file_contents_equal(tc, fname, LINE1 LINE1 LINE2 LINE1 LINE1 LINE2, 
+                        strlen(LINE1)*4 + strlen(LINE2)*2);
+
+}
+
 static void test_truncate(abts_case *tc, void *data)
 {
     apr_status_t rv;
@@ -648,6 +690,7 @@
     abts_run_test(suite, test_ungetc, NULL);
     abts_run_test(suite, test_gets, NULL);
     abts_run_test(suite, test_puts, NULL);
+    abts_run_test(suite, test_writev, NULL);
     abts_run_test(suite, test_bigread, NULL);
     abts_run_test(suite, test_mod_neg, NULL);
     abts_run_test(suite, test_truncate, NULL);

Mime
View raw message