break;
}
- switch ( ldap_pvt_thread_mutex_trylock( &lc->lc_mutex ) ) {
- case LDAP_PVT_THREAD_EBUSY:
- default:
- ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
- ldap_pvt_thread_yield();
- goto retry_lock;
-
- case 0:
- break;
- }
-
assert( lc->lc_refcnt > 0 );
if ( --lc->lc_refcnt == 0 ) {
lc = avl_delete( &li->conntree, (caddr_t)lc,
ldap_back_conn_cmp );
assert( lc != NULL );
- ldap_pvt_thread_mutex_unlock( &lc->lc_mutex );
-
ldap_back_conn_free( (void *)lc );
-
- } else {
- ldap_pvt_thread_mutex_unlock( &lc->lc_mutex );
}
ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
{
struct ldapinfo *li = (struct ldapinfo *)op->o_bd->be_private;
struct ldapconn *lc, lc_curr = { 0 };
+ int refcnt = 1;
/* Searches for a ldapconn in the avl tree */
lc = (struct ldapconn *)avl_find( li->conntree,
(caddr_t)&lc_curr, ldap_back_conn_cmp );
if ( lc != NULL ) {
- lc->lc_refcnt++;
+ refcnt = ++lc->lc_refcnt;
}
ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
Debug( LDAP_DEBUG_TRACE,
"=>ldap_back_getconn: conn %p inserted (refcnt=%u)\n",
- (void *)lc, lc->lc_refcnt, 0 );
+ (void *)lc, refcnt, 0 );
/* Err could be -1 in case a duplicate ldapconn is inserted */
if ( rs->sr_err != 0 ) {
} else {
Debug( LDAP_DEBUG_TRACE,
"=>ldap_back_getconn: conn %p fetched (refcnt=%u)\n",
- (void *)lc, lc->lc_refcnt, 0 );
+ (void *)lc, refcnt, 0 );
}
return lc;
break;
}
- switch ( ldap_pvt_thread_mutex_trylock( &lc->lc_mutex ) ) {
- case LDAP_PVT_THREAD_EBUSY:
- default:
- ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
- ldap_pvt_thread_yield();
- goto retry_lock;
-
- case 0:
- break;
- }
-
assert( lc->lc_refcnt > 0 );
lc->lc_refcnt--;
- ldap_pvt_thread_mutex_unlock( &lc->lc_mutex );
ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
}
break;
}
- switch ( ldap_pvt_thread_mutex_trylock( &lc->lc_mutex ) ) {
- case LDAP_PVT_THREAD_EBUSY:
- default:
- ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
- ldap_pvt_thread_yield();
- goto retry_lock;
-
- case 0:
- break;
- }
-
if ( lc->lc_refcnt == 1 ) {
ldap_unbind_ext_s( lc->lc_ld, NULL, NULL );
lc->lc_ld = NULL;
}
}
- ldap_pvt_thread_mutex_unlock( &lc->lc_mutex );
ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
return rc;