apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Havard" <bri...@kheldar.apana.org.au>
Subject Re: cvs commit: apr/file_io/win32 readwrite.c seek.c
Date Tue, 28 Aug 2001 16:26:33 GMT
On Wed, 29 Aug 2001 01:14:23 +1000 (EST), Brian Havard wrote:

>On 28 Aug 2001 01:56:09 -0000, wrowe@apache.org wrote:
>
>>wrowe       01/08/27 18:56:09
>>
>>  Modified:    file_io/win32 readwrite.c seek.c
>>  Log:
>>    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 ;)
>
>Did this actually fix things for you? You see the new offset calculation in 
>the buffered seek is wrong (my fault). I've only tested on OS/2 but it should 
>apply equally to all platforms. The fix is:

Forget it, different bug. Just applied similar fix to the OS/2 version.
For unix, the patch below should do it but I can't test.


Index: readwrite.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/readwrite.c,v
retrieving revision 1.71
diff -u -r1.71 readwrite.c
--- readwrite.c	2001/08/24 12:19:01	1.71
+++ readwrite.c	2001/08/28 16:19:02
@@ -137,16 +137,17 @@
         }
         while (rv == 0 && size > 0) {
             if (thefile->bufpos >= thefile->dataRead) {
-                thefile->dataRead = read(thefile->filedes, thefile->buffer, APR_FILE_BUFSIZE);
-                if (thefile->dataRead == 0) {
+                int bytesread = read(thefile->filedes, thefile->buffer, APR_FILE_BUFSIZE);
+                if (bytesread == 0) {
                     thefile->eof_hit = TRUE;
                     rv = APR_EOF;
                     break;
                 }
-                else if (thefile->dataRead == -1) {
+                else if (bytesread == -1) {
                     rv = errno;
                     break;
                 }
+                thefile->dataRead = bytesread;
                 thefile->filePtr += thefile->dataRead;
                 thefile->bufpos = 0;
             }

-- 
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------


Mime
View raw message