return mc;
}
-static void
-meta_back_freeconn(
- Operation *op,
- metaconn_t *mc )
-{
- metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
-
- assert( mc != NULL );
-
- ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
-
- if ( --mc->mc_refcnt == 0 ) {
- meta_back_conn_free( mc );
- }
-
- ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
-}
-
/*
* meta_back_init_one_conn
*
if ( ncandidates == 0 ) {
if ( new_conn ) {
- meta_back_freeconn( op, mc );
+ mc->mc_refcnt = 0;
+ meta_back_conn_free( mc );
} else {
meta_back_release_conn( op, mc );
*/
META_CANDIDATE_RESET( &candidates[ i ] );
if ( new_conn ) {
- (void)meta_clear_one_candidate( msc );
- meta_back_freeconn( op, mc );
+ mc->mc_refcnt = 0;
+ meta_back_conn_free( mc );
} else {
meta_back_release_conn( op, mc );
rs->sr_text = NULL;
}
if ( new_conn ) {
- meta_back_freeconn( op, mc );
+ mc->mc_refcnt = 0;
+ meta_back_conn_free( mc );
} else {
meta_back_release_conn( op, mc );
if ( ncandidates == 0 ) {
if ( new_conn ) {
- meta_back_freeconn( op, mc );
+ mc->mc_refcnt = 0;
+ meta_back_conn_free( mc );
} else {
meta_back_release_conn( op, mc );
"%s meta_back_getconn: candidates=%d conn=%ld insert failed\n",
op->o_log_prefix, ncandidates,
LDAP_BACK_PCONN_ID( mc->mc_conn ) );
-
- meta_back_freeconn( op, mc );
+
+ mc->mc_refcnt = 0;
+ meta_back_conn_free( mc );
rs->sr_err = LDAP_OTHER;
rs->sr_text = "proxy bind collision";
mc->mc_refcnt--;
LDAP_BACK_CONN_BINDING_CLEAR( mc );
if ( LDAP_BACK_CONN_TAINTED( mc ) ) {
- Debug( LDAP_DEBUG_TRACE, "%s meta_back_release_conn: mc=%p conn=%ld expired.\n",
+ Debug( LDAP_DEBUG_TRACE, "%s meta_back_release_conn: mc=%p conn=%ld tainted.\n",
op->o_log_prefix, (void *)mc, LDAP_BACK_PCONN_ID( mc->mc_conn ) );
(void)avl_delete( &mi->mi_conninfo.lai_tree,
( caddr_t )mc, meta_back_conndnmc_cmp );
if ( mc->mc_refcnt == 0 ) {
- meta_clear_candidates( op, mc );
meta_back_conn_free( mc );
}
}
return 0;
}
+/*
+ * meta_back_conn_free()
+ *
+ * actually frees a connection; the reference count must be 0,
+ * and it must not (or no longer) be in the cache.
+ */
void
meta_back_conn_free(
void *v_mc )
{
metaconn_t *mc = v_mc;
- int i, ntargets;
+ int ntargets;
assert( mc != NULL );
assert( mc->mc_refcnt == 0 );
- if ( !BER_BVISNULL( &mc->mc_local_ndn ) ) {
- free( mc->mc_local_ndn.bv_val );
- }
-
- assert( mc->mc_conns != NULL );
-
/* at least one must be present... */
+ assert( mc->mc_conns != NULL );
ntargets = mc->mc_conns[ 0 ].msc_info->mi_ntargets;
+ assert( ntargets > 0 );
+
+ for ( ; ntargets--; ) {
+ (void)meta_clear_one_candidate( &mc->mc_conns[ ntargets ] );
+ }
- for ( i = 0; i < ntargets; i++ ) {
- (void)meta_clear_one_candidate( &mc->mc_conns[ i ] );
+ if ( !BER_BVISNULL( &mc->mc_local_ndn ) ) {
+ free( mc->mc_local_ndn.bv_val );
}
free( mc );