]> git.sur5r.net Git - openldap/commitdiff
ITS#7712 Fix lock ordering in libldap abandon
authorEmily Backes <ebackes@symas.com>
Mon, 30 Sep 2013 22:14:22 +0000 (15:14 -0700)
committerHoward Chu <hyc@openldap.org>
Mon, 30 Sep 2013 22:31:27 +0000 (15:31 -0700)
libraries/libldap/abandon.c

index ea492604b89ad0fe0a9f6492cf19b8b7eeab91d0..d999b073a11f94d70014a39eb144afccc251f94b 100644 (file)
@@ -279,9 +279,14 @@ start_again:;
 
        if ( lr != NULL ) {
                if ( sendabandon || lr->lr_status == LDAP_REQST_WRITING ) {
+                       /* release ld_req_mutex while grabbing ld_conn_mutex to
+                        * prevent deadlock.
+                        */
+                       LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
                        LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
                        ldap_free_connection( ld, lr->lr_conn, 0, 1 );
                        LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
+                       LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
                }
 
                if ( origid == msgid ) {