- ldap_pvt_thread_mutex_lock( &li->conn_mutex );
- tmplc = avl_delete( &li->conntree, (caddr_t)lc,
- ldap_back_conn_cmp );
- if ( tmplc != NULL ) {
- if ( !BER_BVISNULL( &lc->lc_local_ndn ) ) {
- ch_free( lc->lc_local_ndn.bv_val );
- }
- ber_dupbv( &lc->lc_local_ndn, &op->o_req_ndn );
- lerr = avl_insert( &li->conntree, (caddr_t)lc,
- ldap_back_conn_cmp, ldap_back_conn_dup );
+ /* wait for all other ops to release the connection */
+retry_lock:;
+ switch ( ldap_pvt_thread_mutex_trylock( &li->conn_mutex ) ) {
+ case LDAP_PVT_THREAD_EBUSY:
+ default:
+ ldap_pvt_thread_yield();
+ goto retry_lock;