]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Backport from trunk and 2.2.x:
authorJeff Trawick <trawick@apache.org>
Tue, 11 Apr 2006 17:27:53 +0000 (17:27 +0000)
committerJeff Trawick <trawick@apache.org>
Tue, 11 Apr 2006 17:27:53 +0000 (17:27 +0000)
  mod_ldap: Brad's pool fixes to fix a race condition during
  first request as well as thread-safety issues between threads
  handling different vhosts at steady state

Submitted by: bnicholes
Reviewed by:  trawick, gregames

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

STATUS
modules/experimental/util_ldap.c

diff --git a/STATUS b/STATUS
index 72cea928be67427dfc01201dd49031dcbd987a16..b58acdc137adacdd0acfc713a0b4d1e3de15df0b 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -150,21 +150,6 @@ PATCHES PROPOSED TO BACKPORT FROM TRUNK:
          http://svn.apache.org/viewcvs?rev=386821&view=rev
        +1: wrowe, trawick
 
-    *) mod_ldap: Brad's pool fixes to fix a race condition during
-       first request as well as thread-safety issues between threads
-       handling different vhosts at steady state
-       trunk revision:
-         http://svn.apache.org/viewcvs.cgi?view=rev&rev=386477
-         (there's some server config merge logic which does not apply
-         to 2.0)
-       2.0 patch is at
-         http://people.apache.org/~trawick/20_ldap_pool.patch
-       Add also Greg's apr_pool_create comment:
-         http://svn.apache.org/viewcvs?rev=393028&view=rev
-         (not gonna create a new 20_ldap_pool.patch to integrate
-         that comment; should be applied separately)
-       +1: trawick, gregames, bnicholes
-
     *) mod_proxy: Fix PR 11971 (HTTP proxy header "Via" with wrong hostname
                   if ServerName not set or UseCanonicalName Off) by
                   backporting r102320.
index dabc4e7dec79dc5d91f1a2d48050e16a68404cc7..13977363ada27f9bd32e78167c6d0fcb41d8c2fc 100644 (file)
@@ -394,9 +394,6 @@ LDAP_DECLARE(util_ldap_connection_t *)util_ldap_connection_find(request_rec *r,
 
 #if APR_HAS_THREADS
     /* mutex lock this function */
-    if (!st->mutex) {
-        apr_thread_mutex_create(&st->mutex, APR_THREAD_MUTEX_DEFAULT, st->pool);
-    }
     apr_thread_mutex_lock(st->mutex);
 #endif
 
@@ -1387,7 +1384,13 @@ void *util_ldap_create_config(apr_pool_t *p, server_rec *s)
     util_ldap_state_t *st = 
         (util_ldap_state_t *)apr_pcalloc(p, sizeof(util_ldap_state_t));
 
-    st->pool = p;
+    /* Create a per vhost pool for mod_ldap to use, serialized with 
+     * st->mutex (also one per vhost) 
+     */
+    apr_pool_create(&st->pool, p);
+#if APR_HAS_THREADS
+    apr_thread_mutex_create(&st->mutex, APR_THREAD_MUTEX_DEFAULT, st->pool);
+#endif
 
     st->cache_bytes = 100000;
     st->search_cache_ttl = 600000000;
@@ -1444,7 +1447,7 @@ static int util_ldap_post_config(apr_pool_t *p, apr_pool_t *plog,
         /* If the cache file already exists then delete it.  Otherwise we are
          * going to run into problems creating the shared memory. */
         if (st->cache_file) {
-            char *lck_file = apr_pstrcat (st->pool, st->cache_file, ".lck", NULL);
+            char *lck_file = apr_pstrcat (ptemp, st->cache_file, ".lck", NULL);
             apr_file_remove(st->cache_file, ptemp);
             apr_file_remove(lck_file, ptemp);
         }