From 567718da876063aeb57ae5d884c7799f762e66ec Mon Sep 17 00:00:00 2001 From: bojan Date: Fri, 11 May 2007 02:11:25 +0000 Subject: 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 --- file_io/unix/readwrite.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'file_io/unix') 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 -- cgit v1.2.1