diff options
author | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2001-08-28 01:56:09 +0000 |
---|---|---|
committer | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2001-08-28 01:56:09 +0000 |
commit | b43054276818e51f0b29b9d15830d5b9557cdb75 (patch) | |
tree | c8908dd50eb7f3b9890770ebdf218685964cb13e /file_io | |
parent | 6ed5783ba6e7b75add4f505b317ee6d42949a6ea (diff) | |
download | libapr-b43054276818e51f0b29b9d15830d5b9557cdb75.tar.gz |
Found a very ugly reaction to using apr_file_seek(APR_CUR, -value) in
conjuction with buffered reads. Thank you for toggling that case Jeff,
so I could shoot out this bug ;)
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@62236 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r-- | file_io/win32/readwrite.c | 15 | ||||
-rw-r--r-- | file_io/win32/seek.c | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/file_io/win32/readwrite.c b/file_io/win32/readwrite.c index 3b26821f3..f8e675fe0 100644 --- a/file_io/win32/readwrite.c +++ b/file_io/win32/readwrite.c @@ -159,7 +159,7 @@ static apr_status_t read_with_timeout(apr_file_t *file, void *buf, apr_size_t le APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size_t *len) { - apr_size_t rv; + apr_status_t rv; DWORD bytes_read = 0; if (*len <= 0) { @@ -196,16 +196,19 @@ APR_DECLARE(apr_status_t) apr_file_read(apr_file_t *thefile, void *buf, apr_size rv = 0; while (rv == 0 && size > 0) { if (thefile->bufpos >= thefile->dataRead) { + apr_size_t read; rv = read_with_timeout(thefile, thefile->buffer, - APR_FILE_BUFSIZE, &thefile->dataRead); - if (thefile->dataRead == 0) { + APR_FILE_BUFSIZE, &read); + if (read == 0) { if (rv == APR_EOF) thefile->eof_hit = TRUE; break; } - - thefile->filePtr += thefile->dataRead; - thefile->bufpos = 0; + else { + thefile->dataRead = read; + thefile->filePtr += thefile->dataRead; + thefile->bufpos = 0; + } } blocksize = size > thefile->dataRead - thefile->bufpos ? thefile->dataRead - thefile->bufpos : size; diff --git a/file_io/win32/seek.c b/file_io/win32/seek.c index 5698c3569..431ba55fd 100644 --- a/file_io/win32/seek.c +++ b/file_io/win32/seek.c @@ -82,7 +82,7 @@ static apr_status_t setptr(apr_file_t *thefile, apr_off_t pos ) else rc = APR_SUCCESS; if (rc == APR_SUCCESS) - thefile->bufpos = thefile->dataRead = 0; + thefile->eof_hit = thefile->bufpos = thefile->dataRead = 0; } return rc; |