From 0dce854ce4345c763162390622533a7a68184f1f Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Wed, 11 Jan 2006 12:11:59 +0000 Subject: [PATCH] complete fix to back-ldap (ITS#4315?); not sure dobind should actually be treated as a bind... --- servers/slapd/back-ldap/bind.c | 32 +++++++++++++++++++++------- servers/slapd/back-ldap/proto-ldap.h | 3 ++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index 55984982f6..a2673c6c09 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -620,18 +620,23 @@ done:; } 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 ); + } } /* @@ -665,10 +670,20 @@ ldap_back_dobind_int( 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; @@ -785,13 +800,14 @@ retry:; 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; } diff --git a/servers/slapd/back-ldap/proto-ldap.h b/servers/slapd/back-ldap/proto-ldap.h index f690061fe1..e668a717d5 100644 --- a/servers/slapd/back-ldap/proto-ldap.h +++ b/servers/slapd/back-ldap/proto-ldap.h @@ -49,7 +49,8 @@ extern BI_entry_get_rw ldap_back_entry_get; 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 ); -- 2.39.5