You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by co...@apache.org on 2011/03/12 13:42:42 UTC
svn commit: r1080930 - in /apr/apr-util/branches/1.5.x: CHANGES
ldap/apr_ldap_rebind.c
Author: covener
Date: Sat Mar 12 12:42:41 2011
New Revision: 1080930
URL: http://svn.apache.org/viewvc?rev=1080930&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.5.x/CHANGES
apr/apr-util/branches/1.5.x/ldap/apr_ldap_rebind.c
Modified: apr/apr-util/branches/1.5.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.5.x/CHANGES?rev=1080930&r1=1080929&r2=1080930&view=diff
==============================================================================
--- apr/apr-util/branches/1.5.x/CHANGES [utf-8] (original)
+++ apr/apr-util/branches/1.5.x/CHANGES [utf-8] Sat Mar 12 12:42:41 2011
@@ -1,6 +1,10 @@
-*- coding: utf-8 -*-
Changes with APR-util 1.5.0
+ *) 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]
+
Changes with APR-util 1.4.0
*) http://svn.apache.org/viewvc/apr/apr-util/branches/1.4.x/CHANGES?view=markup
Modified: apr/apr-util/branches/1.5.x/ldap/apr_ldap_rebind.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.5.x/ldap/apr_ldap_rebind.c?rev=1080930&r1=1080929&r2=1080930&view=diff
==============================================================================
--- apr/apr-util/branches/1.5.x/ldap/apr_ldap_rebind.c (original)
+++ apr/apr-util/branches/1.5.x/ldap/apr_ldap_rebind.c Sat Mar 12 12:42:41 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 */