From: Pierangelo Masarati Date: Wed, 3 Aug 2005 16:54:08 +0000 (+0000) Subject: little more about potential concurrency issues X-Git-Tag: OPENLDAP_AC_BP~95 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a3a9bb9bfa3dc526786d3bc5b67853e65df50166;p=openldap little more about potential concurrency issues --- diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index 12fc3af447..7e352fa23e 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -491,8 +491,10 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) ldap_int_sasl_close( ld, lc ); prevlc = NULL; - for ( tmplc = ld->ld_conns; tmplc != NULL; - tmplc = tmplc->lconn_next ) { + for ( tmplc = ld->ld_conns; + tmplc != NULL; + tmplc = tmplc->lconn_next ) + { if ( tmplc == lc ) { if ( prevlc == NULL ) { ld->ld_conns = tmplc->lconn_next; @@ -514,9 +516,6 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) if ( force ) { LDAPRequest *lr; -#ifdef LDAP_R_COMPILE - ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex ); -#endif for ( lr = ld->ld_requests; lr; ) { LDAPRequest *lr_next = lr->lr_next; @@ -526,9 +525,6 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind ) lr = lr_next; } -#ifdef LDAP_R_COMPILE - ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); -#endif } if ( lc->lconn_sb != ld->ld_sb ) { ber_sockbuf_free( lc->lconn_sb ); diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index cbb744d882..56eb3291c3 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -749,7 +749,13 @@ lr->lr_res_matched ? lr->lr_res_matched : "" ); } if ( lc != NULL ) { +#ifdef LDAP_R_COMPILE + ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex ); +#endif ldap_free_connection( ld, lc, 0, 1 ); +#ifdef LDAP_R_COMPILE + ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); +#endif *lcp = NULL; } }