apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cove...@apache.org
Subject svn commit: r1080932 - in /apr/apr-util/branches/1.3.x: CHANGES ldap/apr_ldap_rebind.c
Date Sat, 12 Mar 2011 12:48:50 GMT
Author: covener
Date: Sat Mar 12 12:48:50 2011
New Revision: 1080932

URL: http://svn.apache.org/viewvc?rev=1080932&view=rev
Log:
backport r1080928 from trunk:

PR50918: check mutex during rebind calls, and set mutex to null when init
pool is cleaned up so the mutex can be re-initialized.


Modified:
    apr/apr-util/branches/1.3.x/CHANGES
    apr/apr-util/branches/1.3.x/ldap/apr_ldap_rebind.c

Modified: apr/apr-util/branches/1.3.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/CHANGES?rev=1080932&r1=1080931&r2=1080932&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/CHANGES [utf-8] (original)
+++ apr/apr-util/branches/1.3.x/CHANGES [utf-8] Sat Mar 12 12:48:50 2011
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes with APR-util 1.3.11
 
+  *) apr_ldap: resolve possible hangs or crashes when the pool passed
+     to apr_ldap_rebind_init() is cleaned up and apr_ldap_rebind
+     is re-initted and re-used. PR50918. [Eric Covener]
+
   *) DBD ODBC support: Fix stack buffer overwrite when an unexpected
      number of parameters is passed to open.  Fix range checking of the
      APR DBD type enum passed to some of the APIs.  [Jeff Trawick]

Modified: apr/apr-util/branches/1.3.x/ldap/apr_ldap_rebind.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/ldap/apr_ldap_rebind.c?rev=1080932&r1=1080931&r2=1080932&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/ldap/apr_ldap_rebind.c (original)
+++ apr/apr-util/branches/1.3.x/ldap/apr_ldap_rebind.c Sat Mar 12 12:48:50 2011
@@ -64,6 +64,14 @@ static apr_ldap_rebind_entry_t *xref_hea
 static int apr_ldap_rebind_set_callback(LDAP *ld);
 static apr_status_t apr_ldap_rebind_remove_helper(void *data);
 
+static apr_status_t apr_ldap_pool_cleanup_set_null(void *data_)
+{
+    void **ptr = (void **)data_;
+    *ptr = NULL;
+    return APR_SUCCESS;
+}
+
+
 /* APR utility routine used to create the xref_lock. */
 APU_DECLARE_LDAP(apr_status_t) apr_ldap_rebind_init(apr_pool_t *pool)
 {
@@ -73,6 +81,9 @@ APU_DECLARE_LDAP(apr_status_t) apr_ldap_
     get_apd
 #endif
 
+    /* run after apr_thread_mutex_create cleanup */
+    apr_pool_cleanup_register(pool, &apr_ldap_xref_lock, apr_ldap_pool_cleanup_set_null,
NULL);
+
 #if APR_HAS_THREADS
     if (apr_ldap_xref_lock == NULL) {
         retcode = apr_thread_mutex_create(&apr_ldap_xref_lock, APR_THREAD_MUTEX_DEFAULT,
pool);
@@ -107,14 +118,20 @@ APU_DECLARE_LDAP(apr_status_t) apr_ldap_
         }
     
 #if APR_HAS_THREADS
-       apr_thread_mutex_lock(apr_ldap_xref_lock);
+       retcode = apr_thread_mutex_lock(apr_ldap_xref_lock);
+       if (retcode != APR_SUCCESS) { 
+           return retcode;
+       }
 #endif
     
         new_xref->next = xref_head;
         xref_head = new_xref;
     
 #if APR_HAS_THREADS
-        apr_thread_mutex_unlock(apr_ldap_xref_lock);
+        retcode = apr_thread_mutex_unlock(apr_ldap_xref_lock);
+        if (retcode != APR_SUCCESS) { 
+           return retcode;
+        }
 #endif
     }
     else {
@@ -138,13 +155,17 @@ APU_DECLARE_LDAP(apr_status_t) apr_ldap_
 APU_DECLARE_LDAP(apr_status_t) apr_ldap_rebind_remove(LDAP *ld)
 {
     apr_ldap_rebind_entry_t *tmp_xref, *prev = NULL;
+    apr_status_t retcode = 0;
 
 #ifdef NETWARE
     get_apd
 #endif
 
 #if APR_HAS_THREADS
-    apr_thread_mutex_lock(apr_ldap_xref_lock);
+    retcode = apr_thread_mutex_lock(apr_ldap_xref_lock);
+    if (retcode != APR_SUCCESS) { 
+        return retcode;
+    }
 #endif
     tmp_xref = xref_head;
 
@@ -169,7 +190,10 @@ APU_DECLARE_LDAP(apr_status_t) apr_ldap_
     }
 
 #if APR_HAS_THREADS
-    apr_thread_mutex_unlock(apr_ldap_xref_lock);
+    retcode = apr_thread_mutex_unlock(apr_ldap_xref_lock);
+    if (retcode != APR_SUCCESS) { 
+       return retcode;
+    }
 #endif
     return APR_SUCCESS;
 }
@@ -348,4 +372,5 @@ static int apr_ldap_rebind_set_callback(
 
 #endif
 
+
 #endif       /* APR_HAS_LDAP */



Mime
View raw message