]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/unbind.c
ITS#8167 Fix non-blocking TLS with referrals
[openldap] / libraries / libldap / unbind.c
index 385ad9e711d6e11ab044c803b1887284c23172ae..1d23cc71cfd660f334b6fd229670229f81fba854 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2014 The OpenLDAP Foundation.
+ * Copyright 1998-2017 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -97,13 +97,14 @@ ldap_ld_free(
                if ( ld->ld_referrals != NULL) {
                        LDAP_VFREE(ld->ld_referrals);
                        ld->ld_referrals = NULL;
-               }  
+               }
                LDAP_MUTEX_UNLOCK( &ld->ld_ldcmutex );
                LDAP_FREE( (char *) ld );
                return( err );
        }
 
        /* This ld is the last thread. */
+       LDAP_MUTEX_UNLOCK( &ld->ld_ldcmutex );
 
        /* free LDAP structure and outstanding requests/responses */
        LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
@@ -123,7 +124,7 @@ ldap_ld_free(
                next = lm->lm_next;
                ldap_msgfree( lm );
        }
-    
+
        if ( ld->ld_abandoned != NULL ) {
                LDAP_FREE( ld->ld_abandoned );
                ld->ld_abandoned = NULL;
@@ -159,8 +160,8 @@ ldap_ld_free(
        if ( ld->ld_referrals != NULL) {
                LDAP_VFREE(ld->ld_referrals);
                ld->ld_referrals = NULL;
-       }  
-    
+       }
+
        if ( ld->ld_selectinfo != NULL ) {
                ldap_free_select_info( ld->ld_selectinfo );
                ld->ld_selectinfo = NULL;
@@ -227,7 +228,6 @@ ldap_ld_free(
        ldap_pvt_thread_mutex_destroy( &ld->ld_res_mutex );
        ldap_pvt_thread_mutex_destroy( &ld->ld_abandon_mutex );
        ldap_pvt_thread_mutex_destroy( &ld->ld_ldopts_mutex );
-       ldap_pvt_thread_mutex_unlock( &ld->ld_ldcmutex );
        ldap_pvt_thread_mutex_destroy( &ld->ld_ldcmutex );
 #endif
 #ifndef NDEBUG
@@ -235,7 +235,7 @@ ldap_ld_free(
 #endif
        LDAP_FREE( (char *) ld->ldc );
        LDAP_FREE( (char *) ld );
-   
+
        return( err );
 }