httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-2.0/modules/mappers mod_rewrite.c
Date Tue, 29 Jul 2003 00:33:13 GMT
nd          2003/07/28 17:33:13

  Modified:    modules/mappers mod_rewrite.c
  Log:
  minor optimizations in lookup_map_program function.
  - make it compile time configurable, how long
    a response from a rewrite map prg may be.
  - avoid unnecessary memory operations
  
  Revision  Changes    Path
  1.198     +11 -9     httpd-2.0/modules/mappers/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.c,v
  retrieving revision 1.197
  retrieving revision 1.198
  diff -u -r1.197 -r1.198
  --- mod_rewrite.c	28 Jul 2003 23:41:18 -0000	1.197
  +++ mod_rewrite.c	29 Jul 2003 00:33:13 -0000	1.198
  @@ -220,6 +220,11 @@
   #define REWRITE_MAX_TXT_MAP_LINE 1024
   #endif
   
  +/* max response length (incl.\n) in prg rewrite maps */
  +#ifndef REWRITE_MAX_PRG_MAP_LINE
  +#define REWRITE_MAX_PRG_MAP_LINE 2048
  +#endif
  +
   /*
    * +-------------------------------------------------------+
    * |                                                       |
  @@ -1270,9 +1275,9 @@
   static char *lookup_map_program(request_rec *r, apr_file_t *fpin,
                                   apr_file_t *fpout, char *key)
   {
  -    char buf[LONG_STRING_LEN];
  +    char buf[REWRITE_MAX_PRG_MAP_LINE];
       char c;
  -    int i;
  +    apr_size_t i;
       apr_size_t nbytes;
       apr_status_t rv;
   
  @@ -1291,7 +1296,6 @@
       }
   
       /* take the lock */
  -
       if (rewrite_mapr_lock_acquire) {
           rv = apr_global_mutex_lock(rewrite_mapr_lock_acquire);
           if (rv != APR_SUCCESS) {
  @@ -1322,7 +1326,7 @@
       i = 0;
       nbytes = 1;
       apr_file_read(fpout, &c, &nbytes);
  -    while (nbytes == 1 && (i < LONG_STRING_LEN-1)) {
  +    while (nbytes == 1 && (i < REWRITE_MAX_PRG_MAP_LINE)) {
           if (c == '\n') {
               break;
           }
  @@ -1330,7 +1334,6 @@
   
           apr_file_read(fpout, &c, &nbytes);
       }
  -    buf[i] = '\0';
   
       /* give the lock back */
       if (rewrite_mapr_lock_acquire) {
  @@ -1343,12 +1346,11 @@
           }
       }
   
  -    if (strcasecmp(buf, "NULL") == 0) {
  +    if (i == 4 && strncasecmp(buf, "NULL", 4) == 0) {
           return NULL;
       }
  -    else {
  -        return apr_pstrdup(r->pool, buf);
  -    }
  +
  +    return apr_pstrmemdup(r->pool, buf, i);
   }
   
   /*
  
  
  

Mime
View raw message