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:17:26 UTC

svn commit: r1080928 - in /apr/apr/trunk: CHANGES ldap/apr_ldap_rebind.c

Author: covener
Date: Sat Mar 12 12:17:26 2011
New Revision: 1080928

URL: http://svn.apache.org/viewvc?rev=1080928&view=rev
Log:
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/trunk/CHANGES
    apr/apr/trunk/ldap/apr_ldap_rebind.c

Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=1080928&r1=1080927&r2=1080928&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES [utf-8] (original)
+++ apr/apr/trunk/CHANGES [utf-8] Sat Mar 12 12:17:26 2011
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 2.0.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]
+
   *) apr_ring: Workaround for aliasing problem that causes gcc 4.5 to
      miscompile some brigade related code. PR 50190. [Stefan Fritsch]
 

Modified: apr/apr/trunk/ldap/apr_ldap_rebind.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/ldap/apr_ldap_rebind.c?rev=1080928&r1=1080927&r2=1080928&view=diff
==============================================================================
--- apr/apr/trunk/ldap/apr_ldap_rebind.c (original)
+++ apr/apr/trunk/ldap/apr_ldap_rebind.c Sat Mar 12 12:17:26 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. */
 APR_DECLARE_LDAP(apr_status_t) apr_ldap_rebind_init(apr_pool_t *pool)
 {
@@ -73,6 +81,9 @@ APR_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 @@ APR_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 @@ APR_DECLARE_LDAP(apr_status_t) apr_ldap_
 APR_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 @@ APR_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 */



Re: svn commit: r1080928 - in /apr/apr/trunk: CHANGES ldap/apr_ldap_rebind.c

Posted by Eric Covener <co...@gmail.com>.
On Sat, Mar 12, 2011 at 6:41 PM, William A. Rowe Jr.
<wr...@rowe-clan.net> wrote:
> On 3/12/2011 6:17 AM, covener@apache.org wrote:
>> Author: covener
>> Date: Sat Mar 12 12:17:26 2011
>> New Revision: 1080928
>>
>> URL: http://svn.apache.org/viewvc?rev=1080928&view=rev
>> Log:
>> PR50918: check mutex during rebind calls, and set mutex to null when init
>> pool is cleaned up so the mutex can be re-initialized.
>
> If this is new to apr-util 1.3, then noting the change in 1.4...2.0 seems
> pretty redundant, no?

I see, will remove in the unreleased ones.

Re: svn commit: r1080928 - in /apr/apr/trunk: CHANGES ldap/apr_ldap_rebind.c

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 3/12/2011 6:17 AM, covener@apache.org wrote:
> Author: covener
> Date: Sat Mar 12 12:17:26 2011
> New Revision: 1080928
> 
> URL: http://svn.apache.org/viewvc?rev=1080928&view=rev
> Log:
> PR50918: check mutex during rebind calls, and set mutex to null when init
> pool is cleaned up so the mutex can be re-initialized.

If this is new to apr-util 1.3, then noting the change in 1.4...2.0 seems
pretty redundant, no?