little more about potential concurrency issues

This commit is contained in:
Pierangelo Masarati 2005-08-03 16:54:08 +00:00
parent cc361f7aa0
commit a3a9bb9bfa
2 changed files with 10 additions and 8 deletions

View File

@ -491,8 +491,10 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
ldap_int_sasl_close( ld, lc ); ldap_int_sasl_close( ld, lc );
prevlc = NULL; prevlc = NULL;
for ( tmplc = ld->ld_conns; tmplc != NULL; for ( tmplc = ld->ld_conns;
tmplc = tmplc->lconn_next ) { tmplc != NULL;
tmplc = tmplc->lconn_next )
{
if ( tmplc == lc ) { if ( tmplc == lc ) {
if ( prevlc == NULL ) { if ( prevlc == NULL ) {
ld->ld_conns = tmplc->lconn_next; ld->ld_conns = tmplc->lconn_next;
@ -514,9 +516,6 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
if ( force ) { if ( force ) {
LDAPRequest *lr; LDAPRequest *lr;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
for ( lr = ld->ld_requests; lr; ) { for ( lr = ld->ld_requests; lr; ) {
LDAPRequest *lr_next = lr->lr_next; LDAPRequest *lr_next = lr->lr_next;
@ -526,9 +525,6 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
lr = lr_next; lr = lr_next;
} }
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
} }
if ( lc->lconn_sb != ld->ld_sb ) { if ( lc->lconn_sb != ld->ld_sb ) {
ber_sockbuf_free( lc->lconn_sb ); ber_sockbuf_free( lc->lconn_sb );

View File

@ -749,7 +749,13 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
} }
if ( lc != NULL ) { if ( lc != NULL ) {
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
ldap_free_connection( ld, lc, 0, 1 ); ldap_free_connection( ld, lc, 0, 1 );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
*lcp = NULL; *lcp = NULL;
} }
} }