From e21f57cf050f5348558b1f6519440bc357db9fa3 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 4 Apr 2006 18:45:59 +0000 Subject: [PATCH] complete previous commit (protect binds) --- servers/slapd/back-meta/bind.c | 11 +++++++++++ servers/slapd/back-meta/conn.c | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/servers/slapd/back-meta/bind.c b/servers/slapd/back-meta/bind.c index 82ece95fa0..43f8297378 100644 --- a/servers/slapd/back-meta/bind.c +++ b/servers/slapd/back-meta/bind.c @@ -577,6 +577,7 @@ retry:; mt, mc, candidate, LDAP_BACK_CONN_ISPRIV( mc ), LDAP_BACK_DONTSEND ); + LDAP_BACK_CONN_BINDING_SET( msc ); } else { /* can't do anything about it */ @@ -614,6 +615,7 @@ retry:; done:; rs->sr_err = rc; if ( rc != LDAP_SUCCESS && META_BACK_ONERR_STOP( mi ) ) { + LDAP_BACK_CONN_BINDING_CLEAR( msc ); meta_back_release_conn_lock( op, mc, 1, dolock ); *mcp = NULL; @@ -713,14 +715,23 @@ retry:; goto send_err; } + if ( rc == LDAP_UNAVAILABLE && do_retry ) { do_retry = 0; if ( meta_back_retry( op, rs, &mc, i, sendok ) ) { goto retry; } + ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex ); + LDAP_BACK_CONN_BINDING_CLEAR( msc ); + ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex ); + return 0; } + ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex ); + LDAP_BACK_CONN_BINDING_CLEAR( msc ); + ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex ); + snprintf( buf, sizeof( buf ), "meta_back_dobind[%d]: (%s) err=%d (%s).", i, rootdn ? rootdn : "anonymous", diff --git a/servers/slapd/back-meta/conn.c b/servers/slapd/back-meta/conn.c index 9faa12d7ac..657881ca50 100644 --- a/servers/slapd/back-meta/conn.c +++ b/servers/slapd/back-meta/conn.c @@ -488,9 +488,10 @@ meta_back_retry( { metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private; metatarget_t *mt = &mi->mi_targets[ candidate ]; - int rc = LDAP_UNAVAILABLE; metaconn_t *mc = *mcp; metasingleconn_t *msc = &mc->mc_conns[ candidate ]; + int rc = LDAP_UNAVAILABLE, + binding = LDAP_BACK_CONN_BINDING( msc ); ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex ); @@ -515,6 +516,9 @@ meta_back_retry( /* mc here must be the regular mc, reset and ready for init */ rc = meta_back_init_one_conn( op, rs, mt, mc, candidate, LDAP_BACK_CONN_ISPRIV( mc ), sendok ); + if ( binding ) { + LDAP_BACK_CONN_BINDING_SET( msc ); + } if ( rc == LDAP_SUCCESS ) { rc = meta_back_single_dobind( op, rs, mcp, candidate, @@ -524,6 +528,9 @@ meta_back_retry( if ( rc != LDAP_SUCCESS ) { if ( *mcp != NULL ) { + if ( binding ) { + LDAP_BACK_CONN_BINDING_CLEAR( msc ); + } meta_back_release_conn_lock( op, mc, 1, 0 ); *mcp = NULL; } -- 2.39.5