]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge r1831773 from trunk:
authorJim Jagielski <jim@apache.org>
Tue, 11 Dec 2018 14:09:11 +0000 (14:09 +0000)
committerJim Jagielski <jim@apache.org>
Tue, 11 Dec 2018 14:09:11 +0000 (14:09 +0000)
PR62311: only create the rewritelock when needed

Submitted By: Hank Ibell <hwibell gmail.com>
Committed By: covener

Submitted by: covener
Reviewed by: jailletc36, icing (by inspection), covener

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1848681 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index 4e1cbb3abe2a998d031232f1dff28fa5f8f00c7b..88e5320671ba559ca1bcbc6290e3f27ea474b481 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,10 @@ Changes with Apache 2.4.38
      and we should just set the value for the environment variable 
      like in the pattern case. [Christophe Jaillet]
 
+  *) mod_rewrite: Only create the global mutex used by "RewriteMap prg:" when
+     this type of map is present in the configuration.  PR62311.  
+     [Hank Ibell <hwibell gmail.com>]
+
   *) mod_dav: Fix invalid Location header when a resource is created by
      passing an absolute URI on the request line [Jim Jagielski]
 
diff --git a/STATUS b/STATUS
index fbcefb785a5d10745290b09acefcfeb47ba9c12d..2b23806d9f1414057b19d6594930d5da9f83e7dd 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -126,11 +126,6 @@ RELEASE SHOWSTOPPERS:
 PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
   [ start all new proposals below, under PATCHES PROPOSED. ]
 
-  *) mod_rewrite: Only create the rewritelock when needed. PR 62311
-     trunk patch: http://svn.apache.org/r1831773
-     2.4.x patch: svn merge -c 1831773 ^/httpd/httpd/trunk .
-     +1: jailletc36, icing (by inspection), covener
-
   *) Easy patches: synch 2.4.x and trunk
      - mod_ssl: Add some missing logno tags.
      - mod_ssl: Simplify code, no functional change
index fb897a97604e86b415bbdee49091d6f33be0c573..68a33b68a523331bdf677d5eee985660e2aea906 100644 (file)
@@ -416,6 +416,7 @@ static cache *cachep;
 static int proxy_available;
 
 /* Locks/Mutexes */
+static int rewrite_lock_needed = 0;
 static apr_global_mutex_t *rewrite_mapr_lock_acquire = NULL;
 static const char *rewritemap_mutex_type = "rewrite-map";
 
@@ -2687,9 +2688,6 @@ static apr_status_t rewritelock_create(server_rec *s, apr_pool_t *p)
     apr_status_t rc;
 
     /* create the lockfile */
-    /* XXX See if there are any rewrite map programs before creating
-     * the mutex.
-     */
     rc = ap_global_mutex_create(&rewrite_mapr_lock_acquire, NULL,
                                 rewritemap_mutex_type, NULL, s, p, 0);
     if (rc != APR_SUCCESS) {
@@ -3163,6 +3161,8 @@ static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, const char *a1,
 
         newmap->type      = MAPTYPE_PRG;
         newmap->checkfile = newmap->argv[0];
+        rewrite_lock_needed = 1;
+
         if (a3) {
             char *tok_cntx;
             newmap->user = apr_strtok(apr_pstrdup(cmd->pool, a3), ":", &tok_cntx);
@@ -4469,6 +4469,7 @@ static int pre_config(apr_pool_t *pconf,
 {
     APR_OPTIONAL_FN_TYPE(ap_register_rewrite_mapfunc) *map_pfn_register;
 
+    rewrite_lock_needed = 0; 
     ap_mutex_register(pconf, rewritemap_mutex_type, NULL, APR_LOCK_DEFAULT, 0);
 
     /* register int: rewritemap handlers */
@@ -4494,13 +4495,15 @@ static int post_config(apr_pool_t *p,
     /* check if proxy module is available */
     proxy_available = (ap_find_linked_module("mod_proxy.c") != NULL);
 
-    rv = rewritelock_create(s, p);
-    if (rv != APR_SUCCESS) {
-        return HTTP_INTERNAL_SERVER_ERROR;
-    }
+    if (rewrite_lock_needed) {
+        rv = rewritelock_create(s, p);
+        if (rv != APR_SUCCESS) {
+            return HTTP_INTERNAL_SERVER_ERROR;
+        }
 
-    apr_pool_cleanup_register(p, (void *)s, rewritelock_remove,
-                              apr_pool_cleanup_null);
+        apr_pool_cleanup_register(p, (void *)s, rewritelock_remove,
+                apr_pool_cleanup_null);
+    }
 
     /* if we are not doing the initial config, step through the servers and
      * open the RewriteMap prg:xxx programs,