httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ed Korthof ...@organic.com>
Subject [PATCH] Performance improvement for mod_include
Date Fri, 31 Jan 1997 16:51:25 GMT
Earlier, someone noted that mod_include still does a feof and ferror test
for every character read.  According to my a reference on C/C++ (I can't
find my K&R C book, so if anyone knows if this is true or not, please
say), getc returns EOF on either end of file or on error.  In the latter
case, the FILE * pointer has the appropriate error bit set; given that,
all we should need to test for is if we recieved EOF when we tried to get
the next character.

This patch fixes that.  Ideally, of course, it'd probably be better to
rewrite the whole section to mmap the file or use some other similarly
efficient system, but I don't have time to rewrite the code in each place
where the GET_CHAR macro is used.  It'd also make sense to try to figure
out what the error is, but I'm not sure what function to use to get the
error from the FILE * stream.

     -- Ed Korthof        |  Web Server Engineer --
     -- ed@organic.com    |  Organic Online, Inc --
     -- (415) 278-5676    |  Fax: (415) 284-6891 --

*** mod_include.c.orig	Mon Jan 20 00:00:16 1997
--- mod_include.c	Fri Jan 31 08:47:31 1997
***************
*** 116,122 ****
  #define GET_CHAR(f,c,r,p) \
   { \
     int i = getc(f); \
!    if(feof(f) || ferror(f) || (i == -1)) { \
          pfclose(p,f); \
          return r; \
     } \
--- 116,126 ----
  #define GET_CHAR(f,c,r,p) \
   { \
     int i = getc(f); \
!    if (i == EOF) { /* either EOF or error--needs error handling if latter */ \
!         if (ferror(f) && r && r->server) \
!         { \
!             log_printf(r->server,"error in GET_CHAR macro in mod_include"); \
!         } \
          pfclose(p,f); \
          return r; \
     } \


Mime
View raw message