ldap_back_release_conn_lock(
Operation *op,
SlapReply *rs,
- ldapconn_t *lc,
+ ldapconn_t **lcp,
int dolock )
{
ldapinfo_t *li = (ldapinfo_t *)op->o_bd->be_private;
+ ldapconn_t *lc = *lcp;
+
if ( dolock ) {
ldap_pvt_thread_mutex_lock( &li->li_conninfo.lai_mutex );
}
lc->lc_refcnt--;
if ( LDAP_BACK_CONN_TAINTED( lc ) ) {
ldap_back_freeconn( op, lc, 0 );
+ *lcp = NULL;
}
if ( dolock ) {
ldap_pvt_thread_mutex_unlock( &li->li_conninfo.lai_mutex );
*/
static int
ldap_back_dobind_int(
- ldapconn_t *lc,
+ ldapconn_t **lcp,
Operation *op,
SlapReply *rs,
ldap_back_send_t sendok,
{
ldapinfo_t *li = (ldapinfo_t *)op->o_bd->be_private;
+ ldapconn_t *lc = *lcp;
+
int rc,
isbound,
binding = 0;
/* FIXME: one binding-- too many? */
lc->lc_binding--;
ldap_back_freeconn( op, lc, dolock );
+ *lcp = NULL;
rs->sr_err = slap_map_api2result( rs );
if ( LDAP_BACK_QUARANTINE( li ) ) {
LDAP_BACK_CONN_BINDING_CLEAR( lc );
rc = LDAP_BACK_CONN_ISBOUND( lc );
if ( !rc ) {
- ldap_back_release_conn_lock( op, rs, lc, dolock );
+ ldap_back_release_conn_lock( op, rs, lcp, dolock );
}
return rc;
{
ldapinfo_t *li = (ldapinfo_t *)op->o_bd->be_private;
- return ldap_back_dobind_int( lc, op, rs, sendok, li->li_nretries, 1 );
+ /* NOTE: ldap_back_dobind_int() may free lc;
+ * callers of ldap_back_dobind() MUST no longer deal with lc
+ * in case of failure */
+ return ldap_back_dobind_int( &lc, op, rs, sendok, li->li_nretries, 1 );
}
/*
rc = 0;
} else {
- rc = ldap_back_dobind_int( *lcp, op, rs, sendok, 0, 0 );
+ rc = ldap_back_dobind_int( lcp, op, rs, sendok, 0, 0 );
if ( rc == 0 && *lcp != NULL ) {
/* freeit, because lc_refcnt == 1 */
(*lcp)->lc_refcnt = 0;
(void *)(*lcp), (*lcp)->lc_refcnt, 0 );
LDAP_BACK_CONN_TAINTED_SET( *lcp );
- ldap_back_release_conn_lock( op, rs, *lcp, 0 );
- *lcp = NULL;
+ ldap_back_release_conn_lock( op, rs, lcp, 0 );
+ assert( *lcp == NULL );
if ( sendok ) {
rs->sr_err = LDAP_UNAVAILABLE;
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_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)
+void ldap_back_release_conn_lock( Operation *op, SlapReply *rs, ldapconn_t **lcp, 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 );