rse 98/02/26 02:18:36
Modified: src CHANGES src/modules/standard mod_rewrite.c Log: One more fix for RewriteMap programs. 0 when treated as NULL is ok as an error condition for filehandles (FILE *) but not for filenumbers. Here we have to use -1 as the error indicator like open() does. Revision Changes Path 1.668 +4 -0 apache-1.3/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.667 retrieving revision 1.668 diff -u -r1.667 -r1.668 --- CHANGES 1998/02/25 09:36:09 1.667 +++ CHANGES 1998/02/26 10:18:31 1.668 @@ -1,5 +1,9 @@ Changes with Apache 1.3b6 + *) Fix `RewriteMap' program lookup in situations where such maps are + defined but disabled (`RewriteEngine off') in per-server context. + [Ralf S. Engelschall, PR#1431] + *) Fix bug introduced in 1.3b4-dev, config with no Port setting would cause server to bind to port 0 rather than 80. [Dean Gaudet] 1.73 +19 -12 apache-1.3/src/modules/standard/mod_rewrite.c Index: mod_rewrite.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v retrieving revision 1.72 retrieving revision 1.73 diff -u -r1.72 -r1.73 --- mod_rewrite.c 1998/02/26 09:32:27 1.72 +++ mod_rewrite.c 1998/02/26 10:18:34 1.73 @@ -488,8 +488,8 @@ new->datafile = a2; new->checkfile = a2; } - new->fpin = 0; - new->fpout = 0; + new->fpin = -1; + new->fpout = -1; if (new->checkfile && (sconf->state == ENGINE_ENABLED) && (stat(new->checkfile, &st) == -1)) @@ -2661,6 +2661,14 @@ char c; int i; + /* when `RewriteEngine off' was used in the per-server + * context then the rewritemap-programs were not spawned. + * In this case using such a map (usually in per-dir context) + * is useless because it is not available. + */ + if (fpin == -1 || fpout == -1) + return NULL; + /* take the lock */ rewritelock_alloc(r); @@ -3027,13 +3035,12 @@ int rc; conf = get_module_config(s->module_config, &rewrite_module); - /* - * If the engine isn't turned on, don't even try to do anything. + + /* If the engine isn't turned on, + * don't even try to do anything. */ - if (conf->state == ENGINE_DISABLED) { + if (conf->state == ENGINE_DISABLED) return; - } - rewritemaps = conf->rewritemaps; entries = (rewritemap_entry *)rewritemaps->elts; @@ -3041,13 +3048,13 @@ map = &entries[i]; if (map->type != MAPTYPE_PRG) continue; - if (map->datafile == NULL || - *(map->datafile) == '\0' || - map->fpin > 0 || - map->fpout > 0 ) + if (map->datafile == NULL + || *(map->datafile) == '\0' + || map->fpin != -1 + || map->fpout != -1 ) continue; fname = server_root_relative(p, map->datafile); - fpin = NULL; + fpin = NULL; fpout = NULL; rc = spawn_child(p, rewritemap_program_child, (void *)map->datafile, kill_after_timeout, &fpin, &fpout);