httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1343099 - /httpd/httpd/trunk/modules/metadata/mod_setenvif.c
Date Sun, 27 May 2012 21:02:09 GMT
Author: sf
Date: Sun May 27 21:02:09 2012
New Revision: 1343099

URL: http://svn.apache.org/viewvc?rev=1343099&view=rev
Log:
Compile the regex used by is_header_regex() only once during startup
This should save some memory, especially with .htaccess

Modified:
    httpd/httpd/trunk/modules/metadata/mod_setenvif.c

Modified: httpd/httpd/trunk/modules/metadata/mod_setenvif.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/metadata/mod_setenvif.c?rev=1343099&r1=1343098&r2=1343099&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/metadata/mod_setenvif.c (original)
+++ httpd/httpd/trunk/modules/metadata/mod_setenvif.c Sun May 27 21:02:09 2012
@@ -165,17 +165,15 @@ static void *merge_setenvif_config(apr_p
 #define ICASE_MAGIC  ((void *)(&setenvif_module))
 #define SEI_MAGIC_HEIRLOOM "setenvif-phase-flag"
 
+static ap_regex_t *is_header_regex_regex;
+
 static int is_header_regex(apr_pool_t *p, const char* name)
 {
     /* If a Header name contains characters other than:
      *    -,_,[A-Z\, [a-z] and [0-9].
      * assume the header name is a regular expression.
      */
-    ap_regex_t *preg = ap_pregcomp(p, "^[-A-Za-z0-9_]*$",
-                                   (AP_REG_EXTENDED | AP_REG_NOSUB ));
-    ap_assert(preg != NULL);
-
-    if (ap_regexec(preg, name, 0, NULL, 0)) {
+    if (ap_regexec(is_header_regex_regex, name, 0, NULL, 0)) {
         return 1;
     }
 
@@ -633,6 +631,10 @@ static void register_hooks(apr_pool_t *p
 {
     ap_hook_header_parser(match_headers, NULL, NULL, APR_HOOK_MIDDLE);
     ap_hook_post_read_request(match_headers, NULL, NULL, APR_HOOK_MIDDLE);
+
+    is_header_regex_regex = ap_pregcomp(p, "^[-A-Za-z0-9_]*$",
+                                        (AP_REG_EXTENDED | AP_REG_NOSUB ));
+    ap_assert(is_header_regex_regex != NULL);
 }
 
 AP_DECLARE_MODULE(setenvif) =



Mime
View raw message