diff options
author | Brian Havard <bjh@apache.org> | 2010-04-04 14:37:24 +0000 |
---|---|---|
committer | Brian Havard <bjh@apache.org> | 2010-04-04 14:37:24 +0000 |
commit | 8198db87938a3bd6921a0c012bf7033d18724a83 (patch) | |
tree | 57659f35332712d6328abe4be32e95e3df110e6e | |
parent | cf3b85497b995a75dadabb9131e92e8a1424ce61 (diff) | |
download | apr-8198db87938a3bd6921a0c012bf7033d18724a83.tar.gz |
OS/2: Change implementation of apr_file_writev() to just call apr_file_write()
in a loop. OS/2 doesn't have a system call equivalent to writev() so the C
library was just emulating it, providing no performance benefit.
This also fixes a problem with the old implementation failing to handle buffered
files correctly which resulted in a testfile failure.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@930694 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | file_io/os2/readwrite.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/file_io/os2/readwrite.c b/file_io/os2/readwrite.c index deaf5c262..a3cc650ed 100644 --- a/file_io/os2/readwrite.c +++ b/file_io/os2/readwrite.c @@ -219,29 +219,21 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a -#ifdef HAVE_WRITEV - APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, const struct iovec *vec, apr_size_t nvec, apr_size_t *nbytes) { - int bytes; - - if (thefile->buffered) { - apr_status_t rv = apr_file_flush(thefile); - if (rv != APR_SUCCESS) { - return rv; - } - } - - if ((bytes = writev(thefile->filedes, vec, nvec)) < 0) { - *nbytes = 0; - return errno; - } - else { - *nbytes = bytes; - return APR_SUCCESS; - } + int c; + apr_status_t rv = APR_SUCCESS; + apr_size_t written = 0; + + for (c = 0; c < nvec && rv == APR_SUCCESS; c++) { + apr_size_t nbytes = vec[c].iov_len; + rv = apr_file_write(thefile, vec[c].iov_base, &nbytes); + written += nbytes; + } + + *nbytes = written; + return rv; } -#endif |