You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by jo...@apache.org on 2005/10/19 18:17:02 UTC
svn commit: r326598 - in /apr/apr/branches/1.2.x: CHANGES
file_io/unix/seek.c test/testfile.c
Author: jorton
Date: Wed Oct 19 09:16:54 2005
New Revision: 326598
URL: http://svn.apache.org/viewcvs?rev=326598&view=rev
Log:
Merge r326593, r326597 from trunk:
* file_io/unix/seek.c (setptr): Don't ignore errors from
apr_file_flush.
* test/testfile.c (test_fail_read_flush): Add test.
* file_io/unix/seek.c (setptr): Tidy up error handling a little; use
apr_status_t, use rv not rc, check lseek return value directly, use
explicit APR_SUCCESS. No functional change.
Modified:
apr/apr/branches/1.2.x/CHANGES
apr/apr/branches/1.2.x/file_io/unix/seek.c
apr/apr/branches/1.2.x/test/testfile.c
Modified: apr/apr/branches/1.2.x/CHANGES
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.2.x/CHANGES?rev=326598&r1=326597&r2=326598&view=diff
==============================================================================
--- apr/apr/branches/1.2.x/CHANGES (original)
+++ apr/apr/branches/1.2.x/CHANGES Wed Oct 19 09:16:54 2005
@@ -1,6 +1,7 @@
Changes for APR 1.2.3-dev
-
+ *) Fix apr_file_seek() to catch write failures when flushing
+ pending writes for a buffered file. [Joe Orton]
Changes for APR 1.2.2
Modified: apr/apr/branches/1.2.x/file_io/unix/seek.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.2.x/file_io/unix/seek.c?rev=326598&r1=326597&r2=326598&view=diff
==============================================================================
--- apr/apr/branches/1.2.x/file_io/unix/seek.c (original)
+++ apr/apr/branches/1.2.x/file_io/unix/seek.c Wed Oct 19 09:16:54 2005
@@ -19,32 +19,33 @@
static apr_status_t setptr(apr_file_t *thefile, apr_off_t pos )
{
apr_off_t newbufpos;
- int rc;
+ apr_status_t rv;
if (thefile->direction == 1) {
- apr_file_flush(thefile);
+ rv = apr_file_flush(thefile);
+ if (rv) {
+ return rv;
+ }
thefile->bufpos = thefile->direction = thefile->dataRead = 0;
}
newbufpos = pos - (thefile->filePtr - thefile->dataRead);
if (newbufpos >= 0 && newbufpos <= thefile->dataRead) {
thefile->bufpos = newbufpos;
- rc = 0;
+ rv = APR_SUCCESS;
}
else {
- rc = lseek(thefile->filedes, pos, SEEK_SET);
-
- if (rc != -1 ) {
+ if (lseek(thefile->filedes, pos, SEEK_SET) != -1) {
thefile->bufpos = thefile->dataRead = 0;
thefile->filePtr = pos;
- rc = 0;
+ rv = APR_SUCCESS;
}
else {
- rc = errno;
+ rv = errno;
}
}
- return rc;
+ return rv;
}
Modified: apr/apr/branches/1.2.x/test/testfile.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.2.x/test/testfile.c?rev=326598&r1=326597&r2=326598&view=diff
==============================================================================
--- apr/apr/branches/1.2.x/test/testfile.c (original)
+++ apr/apr/branches/1.2.x/test/testfile.c Wed Oct 19 09:16:54 2005
@@ -766,6 +766,16 @@
ABTS_ASSERT(tc, "gets should flush buffered write and fail",
rv != APR_SUCCESS && rv != APR_EOF);
+ /* Likewise for seek. */
+ {
+ apr_off_t offset = 0;
+
+ rv = apr_file_seek(f, APR_SET, &offset);
+ }
+
+ ABTS_ASSERT(tc, "seek should flush buffered write and fail",
+ rv != APR_SUCCESS && rv != APR_EOF);
+
apr_file_close(f);
}