]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Stop locking all of the connections while trying to find an available connection...
authorBradley Nicholes <bnicholes@apache.org>
Mon, 12 Apr 2004 21:17:42 +0000 (21:17 +0000)
committerBradley Nicholes <bnicholes@apache.org>
Mon, 12 Apr 2004 21:17:42 +0000 (21:17 +0000)
Reviewed by: bnicholes, minfrin, trawick

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

STATUS
modules/experimental/util_ldap.c

diff --git a/STATUS b/STATUS
index f73f1fe6088f38dfebaf28cf95dca95a981d6204..48b65a96ef41036e2e149d060b7022f90f3cb1eb 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -1,5 +1,5 @@
 APACHE 2.0 STATUS:                                              -*-text-*-
-Last modified at [$Date: 2004/04/12 17:38:39 $]
+Last modified at [$Date: 2004/04/12 21:17:42 $]
 
 Release:
 
@@ -144,16 +144,6 @@ PATCHES TO BACKPORT FROM 2.1
          modules/experimental/mod_auth_ldap.c: r1.22
        +1: bnicholes, minfrin, trawick
        
-    *) util_ldap_connection_find() locks each cached connection while 
-       testing to see if it matches the specified criteria.  But then 
-       it forgets to unlock the connection if it doesn't match. This 
-       results in all of the connections eventually being locked and 
-       mod_ldap having to create additional connections to handle new
-       requests. This patch unlocks the connection if it doesn't meet
-       the connection criteria.
-         modules/experimental/util_ldap.c: r1.23
-       +1: bnicholes, minfrin, trawick
-       
     *) Update the ldc->binddn and ldc->bindpw associated with the LDAP 
        connection to match the authenticating user DN and password after
        ldap_simple_bind_s() is called to authenticate the user.  Otherwise 
index 2f2d3e1b3d7ac11bbc8b3d12bd958e5b727282ef..e91b2f08f0dd07a9e6edc5843d20f5ed9c3b12c5 100644 (file)
@@ -362,18 +362,22 @@ LDAP_DECLARE(util_ldap_connection_t *)util_ldap_connection_find(request_rec *r,
      */
     for (l=st->connections,p=NULL; l; l=l->next) {
 #if APR_HAS_THREADS
-        if ( (APR_SUCCESS == apr_thread_mutex_trylock(l->lock)) &&
-#else
-        if (
+        if (APR_SUCCESS == apr_thread_mutex_trylock(l->lock)) {
 #endif
-            l->port == port
-           && strcmp(l->host, host) == 0
-           && ( (!l->binddn && !binddn) || (l->binddn && binddn && !strcmp(l->binddn, binddn)) )
-           && ( (!l->bindpw && !bindpw) || (l->bindpw && bindpw && !strcmp(l->bindpw, bindpw)) )
-            && l->deref == deref
-            && l->secure == secure 
-            )
+        if ((l->port == port) && (strcmp(l->host, host) == 0) && 
+            ((!l->binddn && !binddn) || (l->binddn && binddn && !strcmp(l->binddn, binddn))) && 
+            ((!l->bindpw && !bindpw) || (l->bindpw && bindpw && !strcmp(l->bindpw, bindpw))) && 
+            (l->deref == deref) && (l->secure == secure)) {
+
             break;
+        }
+#if APR_HAS_THREADS
+            /* If this connection didn't match the criteria, then we
+             * need to unlock the mutex so it is available to be reused.
+             */
+            apr_thread_mutex_unlock(l->lock);
+        }
+#endif
         p = l;
     }
 
@@ -383,21 +387,25 @@ LDAP_DECLARE(util_ldap_connection_t *)util_ldap_connection_find(request_rec *r,
     if (!l) {
         for (l=st->connections,p=NULL; l; l=l->next) {
 #if APR_HAS_THREADS
-            if ( (APR_SUCCESS == apr_thread_mutex_trylock(l->lock)) &&
-#else
-            if (
+            if (APR_SUCCESS == apr_thread_mutex_trylock(l->lock)) {
+
 #endif
-                l->port == port
-               && strcmp(l->host, host) == 0
-                && l->deref == deref
-                && l->secure == secure
-                ) {
+            if ((l->port == port) && (strcmp(l->host, host) == 0) && 
+                (l->deref == deref) && (l->secure == secure)) {
+
                 /* the bind credentials have changed */
                 l->bound = 0;
                 l->binddn = apr_pstrdup(st->pool, binddn);
                 l->bindpw = apr_pstrdup(st->pool, bindpw);
                 break;
             }
+#if APR_HAS_THREADS
+                /* If this connection didn't match the criteria, then we
+                 * need to unlock the mutex so it is available to be reused.
+                 */
+                apr_thread_mutex_unlock(l->lock);
+            }
+#endif
             p = l;
         }
     }