apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject [PATCH seek.c] apr_file_seek doesn't reset eof_hit to 0
Date Tue, 18 Jun 2002 17:45:25 GMT
the following pseudo-code was failing with the current apr:

apr_file_read(...)       // read full so eof is hit
apr_file_seek(..., 0, 0) // rewind
apr_file_eof             // should return 0

apr_file_eof isn't supposed to return true, after the file was seek()ed. 
Here is the patch (thanks to wrowe for the hint!):

tested on unix, please check that it's the same on other platforms.

Index: srclib/apr/file_io/os2/seek.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/os2/seek.c,v
retrieving revision 1.20
diff -u -r1.20 seek.c
--- srclib/apr/file_io/os2/seek.c	13 Mar 2002 20:39:10 -0000	1.20
+++ srclib/apr/file_io/os2/seek.c	18 Jun 2002 17:40:09 -0000
@@ -91,6 +91,8 @@
          return APR_EBADF;
      }

+    thefile->eof_hit = 0;
+
      if (thefile->buffered) {
          int rc = EINVAL;
          apr_finfo_t finfo;
Index: srclib/apr/file_io/unix/seek.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/unix/seek.c,v
retrieving revision 1.26
diff -u -r1.26 seek.c
--- srclib/apr/file_io/unix/seek.c	13 Mar 2002 20:39:11 -0000	1.26
+++ srclib/apr/file_io/unix/seek.c	18 Jun 2002 17:40:09 -0000
@@ -90,6 +90,7 @@
  {
      apr_off_t rv;

+    thefile->eof_hit = 0;

      if (thefile->buffered) {
          int rc = EINVAL;
Index: srclib/apr/file_io/win32/seek.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/win32/seek.c,v
retrieving revision 1.23
diff -u -r1.23 seek.c
--- srclib/apr/file_io/win32/seek.c	14 Mar 2002 22:22:32 -0000	1.23
+++ srclib/apr/file_io/win32/seek.c	18 Jun 2002 17:40:09 -0000
@@ -96,6 +96,8 @@
      apr_finfo_t finfo;
      apr_status_t rc = APR_SUCCESS;

+    thefile->eof_hit = 0;
+
      if (thefile->buffered) {
          switch (where) {
              case APR_SET:

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Mime
View raw message