Skip to content

Commit

Permalink
* file_io/unix/readwrite.c: Revert to the original code for apr_file …
Browse files Browse the repository at this point in the history
…writev() in the !HAVE_WRITEV case, and a large comment

                            explaining why we cannot use a better method without breaking writev()'s semantics.


git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@111571 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
pquerna committed Dec 11, 2004
1 parent 2098265 commit d024e61
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
4 changes: 0 additions & 4 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ Changes for APR 1.1.0
*) 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]

Expand Down
31 changes: 16 additions & 15 deletions file_io/unix/readwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,21 +241,22 @@ APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, const struct iove
return APR_SUCCESS;
}
#else
int i;
int tbytes;
apr_status_t rv = APR_SUCCESS;

*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;
/**
* 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 = vec[0].iov_len;
return apr_file_write(thefile, vec[0].iov_base, nbytes);
#endif
}

Expand Down

0 comments on commit d024e61

Please sign in to comment.