diff options
author | bojan <bojan@13f79535-47bb-0310-9956-ffa450edef68> | 2007-05-11 02:11:25 +0000 |
---|---|---|
committer | bojan <bojan@13f79535-47bb-0310-9956-ffa450edef68> | 2007-05-11 02:11:25 +0000 |
commit | 567718da876063aeb57ae5d884c7799f762e66ec (patch) | |
tree | ec42b4e701e7a9e40503b21e78678e477b43028e /file_io/unix | |
parent | 0054746b016c46cf445f3023ad8b37e7a6495424 (diff) | |
download | libapr-567718da876063aeb57ae5d884c7799f762e66ec.tar.gz |
The file pointer position must be recalculated and set when writev()ing to a
buffered file.
Fix by Davi Arnaut for bug #40963
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@537066 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io/unix')
-rw-r--r-- | file_io/unix/readwrite.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/file_io/unix/readwrite.c b/file_io/unix/readwrite.c index 3511846d9..412d7c8ba 100644 --- a/file_io/unix/readwrite.c +++ b/file_io/unix/readwrite.c @@ -252,6 +252,15 @@ APR_DECLARE(apr_status_t) apr_file_writev(apr_file_t *thefile, const struct iove if (rv != APR_SUCCESS) { return rv; } + if (thefile->direction == 0) { + /* Position file pointer for writing at the offset we are + * logically reading from + */ + apr_int64_t offset = thefile->filePtr - thefile->dataRead + thefile->bufpos; + if (offset != thefile->filePtr) + lseek(thefile->filedes, offset, SEEK_SET); + thefile->bufpos = thefile->dataRead = 0; + } } #ifdef HAVE_WRITEV |