If HAS_WRITEV is not defined the current code
will just push the first vector to the target.
The function should write all the vectors or none.
I propose the following patch, comments will be
appreciated:
Thanks for looking.
JJ
Index: srclib/apr/file_io/unix/readwrite.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/readwrite.c,v
retrieving revision 1.90
diff -u -r1.90 readwrite.c
--- srclib/apr/file_io/unix/readwrite.c 2 Aug 2004 09:47:48 -0000 1.90
+++ srclib/apr/file_io/unix/readwrite.c 4 Oct 2004 22:41:45 -0000
@@ -241,8 +241,22 @@
return APR_SUCCESS;
}
#else
- *nbytes = vec[0].iov_len;
- return apr_file_write(thefile, vec[0].iov_base, nbytes);
+ apr_status_t rv;
+ int i, bytes = 0;
+
+ for (i = 0; i < nvec; i++) {
+ *nbytes = vec[i].iov_len;
+ if ((rv = apr_file_write(thefile, vec[i].iov_base, nbytes)) !=
APR_SUCCESS) {
+ *nbytes = bytes;
+ return rv;
+ }
+ else {
+ bytes += *nbytes;
+ }
+ }
+ *nbytes = bytes;
+
+ return APR_SUCCESS;
#endif
}
|