httpd-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: apache-2.0/src/lib/apr/file_io/win32 readwrite.c
Date Fri, 16 Jun 2000 04:47:48 GMT
On Wed, 14 Jun 2000 14:59:07 -0700, Greg Stein wrote:

>Woah!
>
>Hey... if the file is non-buffered, then the performance here is going to
>suck hard. The old version would read a chunk, then back up the file pointer
>to where the newline was found. That should be much faster than reading a
>byte at a time, until a newline is hit.
>
>Seriously, I think this change should be backed out. Or at least use
>ap_read() only in the buffered case.

If speed is an issue then it should have buffering turned on. Win32 is the
only version that had this seek back & forth style ap_fgets.



>On Wed, Jun 14, 2000 at 04:31:45PM -0000, bjh@locus.apache.org wrote:
>> bjh         00/06/14 09:31:44
>> 
>>   Modified:    src/lib/apr/file_io/win32 readwrite.c
>>   Log:
>>   Win32: Replace ap_fgets() with the code from OS/2 to make it work properly
>>   in buffered mode.
>>   
>>   Revision  Changes    Path
>>   1.36      +19 -25    apache-2.0/src/lib/apr/file_io/win32/readwrite.c
>>   
>>   Index: readwrite.c
>>   ===================================================================
>>   RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/readwrite.c,v
>>   retrieving revision 1.35
>>   retrieving revision 1.36
>>   diff -u -r1.35 -r1.36
>>   --- readwrite.c	2000/06/14 16:10:45	1.35
>>   +++ readwrite.c	2000/06/14 16:31:43	1.36
>>   @@ -271,34 +271,28 @@
>>    
>>    ap_status_t ap_fgets(char *str, int len, ap_file_t *thefile)
>>    {
>>   -    DWORD bread;
>>   -    int i;
>>   -    if (!ReadFile(thefile->filehand, str, len, &bread, NULL)) {
>>   -        switch(GetLastError()) {
>>   -        case ERROR_HANDLE_EOF:
>>   -            return APR_EOF;
>>   -        default:
>>   -            return GetLastError();
>>   +    ap_ssize_t readlen;
>>   +    ap_status_t rv = APR_SUCCESS;
>>   +    int i;    
>>   +
>>   +    for (i = 0; i < len-1; i++) {
>>   +        readlen = 1;
>>   +        rv = ap_read(thefile, str+i, &readlen);
>>   +
>>   +        if (readlen != 1) {
>>   +            rv = APR_EOF;
>>   +            break;
>>            }
>>   +        
>>   +        if (str[i] == '\r' || str[i] == '\x1A')
>>   +            i--;
>>   +        else if (str[i] == '\n')
>>   +            break;
>>        }
>>   -    if (bread == 0) {
>>   -        thefile->eof_hit = TRUE;
>>   -        return APR_EOF;
>>   -    }
>>   -    for (i=0; i<len; i++) {
>>   -        if (str[i] == '\n') {
>>   -            ++i;
>>   -            if (i < len)
>>   -                str[i] = '\0';
>>   -            else
>>   -                str [--i] = '\0';
>>   -            SetFilePointer(thefile->filehand, (i - bread), NULL, FILE_CURRENT);
>>   -            return APR_SUCCESS;
>>   -        }
>>   -    }
>>   -    str[i] = '\0';
>>   -    return APR_SUCCESS; 
>>   +    str[i] = 0;
>>   +    return rv;
>>    }
>>   +
>>    ap_status_t ap_flush(ap_file_t *thefile)
>>    {
>>        if (thefile->buffered) {
>>   
>>   
>>   

-- 
 ______________________________________________________________________________
 |  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