}
void
-ldap_back_release_conn(
+ldap_back_release_conn_lock(
Operation *op,
SlapReply *rs,
- ldapconn_t *lc )
+ ldapconn_t *lc,
+ int dolock )
{
ldapinfo_t *li = (ldapinfo_t *)op->o_bd->be_private;
- ldap_pvt_thread_mutex_lock( &li->li_conninfo.lai_mutex );
+ if ( dolock ) {
+ ldap_pvt_thread_mutex_lock( &li->li_conninfo.lai_mutex );
+ }
assert( lc->lc_refcnt > 0 );
lc->lc_refcnt--;
LDAP_BACK_CONN_BINDING_CLEAR( lc );
- ldap_pvt_thread_mutex_unlock( &li->li_conninfo.lai_mutex );
+ if ( dolock ) {
+ ldap_pvt_thread_mutex_unlock( &li->li_conninfo.lai_mutex );
+ }
}
/*
while ( lc->lc_refcnt > 1 ) {
ldap_pvt_thread_yield();
- if (( rc = LDAP_BACK_CONN_ISBOUND( lc )))
+ rc = LDAP_BACK_CONN_ISBOUND( lc );
+ if ( rc ) {
return rc;
+ }
}
+ if ( dolock ) {
+ ldap_pvt_thread_mutex_lock( &li->li_conninfo.lai_mutex );
+ }
+ LDAP_BACK_CONN_BINDING_SET( lc );
+ if ( dolock ) {
+ ldap_pvt_thread_mutex_unlock( &li->li_conninfo.lai_mutex );
+ }
+
/*
* FIXME: we need to let clients use proxyAuthz
* otherwise we cannot do symmetric pools of servers;
rc = ldap_back_op_result( lc, op, rs, msgid, 0, sendok );
if ( rc == LDAP_SUCCESS ) {
LDAP_BACK_CONN_ISBOUND_SET( lc );
-
- } else {
- ldap_back_release_conn( op, rs, lc );
}
done:;
+ LDAP_BACK_CONN_BINDING_CLEAR( lc );
rc = LDAP_BACK_CONN_ISBOUND( lc );
+ if ( !rc ) {
+ ldap_back_release_conn_lock( op, rs, lc, dolock );
+ }
return rc;
}
int ldap_back_freeconn( Operation *op, ldapconn_t *lc, int dolock );
ldapconn_t *ldap_back_getconn( Operation *op, SlapReply *rs, ldap_back_send_t sendok );
-void ldap_back_release_conn( Operation *op, SlapReply *rs, ldapconn_t *lc );
+void ldap_back_release_conn_lock( Operation *op, SlapReply *rs, ldapconn_t *lc, int dolock );
+#define ldap_back_release_conn(op, rs, lc) ldap_back_release_conn_lock((op), (rs), (lc), 1)
int ldap_back_dobind( ldapconn_t *lc, Operation *op, SlapReply *rs, ldap_back_send_t sendok );
int ldap_back_retry( ldapconn_t **lcp, Operation *op, SlapReply *rs, ldap_back_send_t sendok );
int ldap_back_map_result( SlapReply *rs );