struct metasingleconn {
int msc_candidate;
-#define META_NOT_CANDIDATE ((char)0)
-#define META_CANDIDATE ((char)1)
-#define META_LAST_CONN ((char)(-1))
+#define META_NOT_CANDIDATE ((ber_tag_t)0)
+#define META_CANDIDATE ((ber_tag_t)1)
+#define META_LAST_CONN ((ber_tag_t)(-1))
LDAP *msc_ld;
struct berval msc_bound_ndn;
int mi_network_timeout;
#define META_DEFAULT_TARGET_NONE (-1)
struct metatarget **mi_targets;
- char *mi_candidates;
+ SlapReply *mi_candidates;
struct metadncache mi_cache;
META_OP_REQUIRE_ALL
} meta_op_type;
-char *
+SlapReply *
meta_back_candidates_get( Operation *op );
extern struct metaconn *
int rc = LDAP_OTHER,
i, gotit = 0, isroot = 0;
- char *candidates = meta_back_candidates_get( op );
+ SlapReply *candidates = meta_back_candidates_get( op );
rs->sr_err = LDAP_SUCCESS;
/*
* Skip non-candidates
*/
- if ( candidates[ i ] != META_CANDIDATE ) {
+ if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
continue;
}
lerr = meta_back_single_bind( &op2, rs, mc, i );
if ( lerr != LDAP_SUCCESS ) {
rs->sr_err = lerr;
- candidates[ i ] = META_NOT_CANDIDATE;
+ candidates[ i ].sr_tag = META_NOT_CANDIDATE;
} else {
rc = LDAP_SUCCESS;
struct metasingleconn *msc;
int bound = 0, i;
- char *candidates = meta_back_candidates_get( op );
+ SlapReply *candidates = meta_back_candidates_get( op );
ldap_pvt_thread_mutex_lock( &mc->mc_mutex );
* due to technical reasons (remote host down?)
* so better clear the handle
*/
- candidates[ i ] = META_NOT_CANDIDATE;
+ candidates[ i ].sr_tag = META_NOT_CANDIDATE;
#if 0
( void )meta_clear_one_candidate( msc );
#endif
continue;
} /* else */
- candidates[ i ] = META_CANDIDATE;
+ candidates[ i ].sr_tag = META_CANDIDATE;
msc->msc_bound = META_ANONYMOUS;
++bound;
}
{
struct metainfo *li = ( struct metainfo * )op->o_bd->be_private;
int i;
- char *candidates = meta_back_candidates_get( op );
+ SlapReply *candidates = meta_back_candidates_get( op );
for ( i = 0; i < li->mi_ntargets; ++i ) {
if ( i == candidate ) {
continue;
}
- candidates[ i ] = META_NOT_CANDIDATE;
+ candidates[ i ].sr_tag = META_NOT_CANDIDATE;
}
return 0;
*msgid;
dncookie dc;
- char *candidates = meta_back_candidates_get( op );
+ SlapReply *candidates = meta_back_candidates_get( op );
lc = meta_back_getconn( op, rs, NULL, LDAP_BACK_SENDERR );
if ( !lc || !meta_back_dobind( lc, op, LDAP_BACK_SENDERR ) ) {
struct berval mapped_attr = op->orc_ava->aa_desc->ad_cname;
struct berval mapped_value = op->orc_ava->aa_value;
- if ( candidates[ i ] != META_CANDIDATE ) {
+ if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
msgid[ i ] = -1;
continue;
}
ber_memfree_x( data, NULL );
}
-char *
+SlapReply *
meta_back_candidates_get( Operation *op )
{
struct metainfo *mi = ( struct metainfo * )op->o_bd->be_private;
}
if ( data == NULL ) {
- data = ber_memalloc_x( sizeof( char ) * mi->mi_ntargets, NULL );
+ data = ber_memalloc( sizeof( SlapReply ) * mi->mi_ntargets );
if ( op->o_threadctx ) {
ldap_pvt_thread_pool_setkey( op->o_threadctx,
meta_back_candidate_keyfree, data,
meta_back_candidate_keyfree );
} else {
- mi->mi_candidates = (char *)data;
+ mi->mi_candidates = (SlapReply *)data;
}
}
- return (char *)data;
+ return (SlapReply *)data;
}
/*
struct berval ndn = op->o_req_ndn,
pndn;
- char *candidates = meta_back_candidates_get( op );
+ SlapReply *candidates = meta_back_candidates_get( op );
/* Searches for a metaconn in the avl tree */
mc_curr.mc_conn = op->o_conn;
int lerr = meta_back_init_one_conn( op, rs, mi->mi_targets[ i ],
&mc->mc_conns[ i ], sendok );
if ( lerr == LDAP_SUCCESS ) {
- candidates[ i ] = META_CANDIDATE;
+ candidates[ i ].sr_tag = META_CANDIDATE;
} else {
* be init'd, should the other ones
* be tried?
*/
- candidates[ i ] = META_NOT_CANDIDATE;
+ candidates[ i ].sr_tag = META_NOT_CANDIDATE;
err = lerr;
continue;
}
}
if ( op_type == META_OP_REQUIRE_SINGLE ) {
+ int j;
- memset( candidates, META_NOT_CANDIDATE, sizeof( char ) * mi->mi_ntargets );
+ for ( j = 0; j < mi->mi_ntargets; j++ ) {
+ candidates[ j ].sr_tag = META_NOT_CANDIDATE;
+ }
/*
* tries to get a unique candidate
err = meta_back_init_one_conn( op, rs, mi->mi_targets[ i ],
&mc->mc_conns[ i ], sendok );
if ( err == LDAP_SUCCESS ) {
- candidates[ i ] = META_CANDIDATE;
+ candidates[ i ].sr_tag = META_CANDIDATE;
} else {
* be init'd, should the other ones
* be tried?
*/
- candidates[ i ] = META_NOT_CANDIDATE;
+ candidates[ i ].sr_tag = META_NOT_CANDIDATE;
if ( new_conn ) {
( void )meta_clear_one_candidate( &mc->mc_conns[ i ] );
meta_back_conn_free( mc );
mi->mi_targets[ i ],
&mc->mc_conns[ i ], sendok );
if ( lerr == LDAP_SUCCESS ) {
- candidates[ i ] = META_CANDIDATE;
+ candidates[ i ].sr_tag = META_CANDIDATE;
} else {
* be init'd, should the other ones
* be tried?
*/
- candidates[ i ] = META_NOT_CANDIDATE;
+ candidates[ i ].sr_tag = META_NOT_CANDIDATE;
err = lerr;
Debug( LDAP_DEBUG_ANY, "%s: meta_back_init_one_conn(%d) failed: %d\n",
}
} else {
- candidates[ i ] = META_NOT_CANDIDATE;
+ candidates[ i ].sr_tag = META_NOT_CANDIDATE;
}
}
}
struct metasingleconn *msc;
struct timeval tv = { 0, 0 };
LDAPMessage *res = NULL, *e;
- int rc = 0, *msgid, sres = LDAP_SUCCESS;
+ int rc = 0, sres = LDAP_SUCCESS;
char *err = NULL;
struct berval match = BER_BVNULL, mmatch = BER_BVNULL;
BerVarray v2refs = NULL;
void *savepriv;
- char *candidates = meta_back_candidates_get( op );
+ SlapReply *candidates = meta_back_candidates_get( op );
/*
* controls are set in ldap_back_dobind()
return rs->sr_err;
}
- /*
- * Array of message id of each target
- */
- msgid = ch_calloc( sizeof( int ), mi->mi_ntargets );
- if ( msgid == NULL ) {
- rs->sr_err = LDAP_OTHER;
- send_ldap_result( op, rs );
- return -1;
- }
-
dc.conn = op->o_conn;
dc.rs = rs;
* Inits searches
*/
for ( i = 0, msc = &lc->mc_conns[ 0 ]; !META_LAST( msc ); ++i, ++msc ) {
- msgid[ i ] = -1;
+ candidates[ i ].sr_msgid = -1;
- if ( candidates[ i ] != META_CANDIDATE ) {
+ if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
continue;
}
- switch ( meta_back_search_start( op, rs, &dc, msc, i, &msgid[ i ] ) )
+ switch ( meta_back_search_start( op, rs, &dc, msc, i, &candidates[ i ].sr_msgid ) )
{
case 0:
break;
int i;
for ( i = 0; i < mi->mi_ntargets; i++ ) {
- if ( candidates[ i ] == META_CANDIDATE ) {
+ if ( candidates[ i ].sr_tag == META_CANDIDATE ) {
cnd[ i ] = '*';
} else {
cnd[ i ] = ' ';
int gotit = 0;
for ( i = 0, msc = &lc->mc_conns[ 0 ]; !META_LAST( msc ); msc++, i++ ) {
- if ( msgid[ i ] == -1 ) {
+ if ( candidates[ i ].sr_msgid == -1 ) {
continue;
}
* get a LDAP_TIMELIMIT_EXCEEDED from
* one of them ...
*/
- rc = ldap_result( msc->msc_ld, msgid[ i ],
+ rc = ldap_result( msc->msc_ld, candidates[ i ].sr_msgid,
0, &tv, &res );
if ( rc == 0 ) {
} else if ( rc == -1 ) {
really_bad:;
/* something REALLY bad happened! */
- ( void )meta_clear_unused_candidates( op,
- lc, -1 );
+ ( void )meta_clear_unused_candidates( op, lc, -1 );
rs->sr_err = LDAP_OTHER;
rs->sr_v2ref = v2refs;
savepriv = op->o_private;
* When no candidates are left,
* the outer cycle finishes
*/
- msgid[ i ] = -1;
+ candidates[ i ].sr_msgid = -1;
--ncandidates;
} else {
/* check for abandon */
if ( op->o_abandon ) {
for ( i = 0, msc = lc->mc_conns; !META_LAST( msc ); msc++, i++ ) {
- ldap_abandon_ext( msc->msc_ld, msgid[ i ], NULL, NULL );
+ ldap_abandon_ext( msc->msc_ld, candidates[ i ].sr_msgid, NULL, NULL );
}
rc = SLAPD_ABANDON;
int i;
for ( i = 0; i < mi->mi_ntargets; i++ ) {
- if ( candidates[ i ] == META_CANDIDATE ) {
+ if ( candidates[ i ].sr_tag == META_CANDIDATE ) {
cnd[ i ] = '*';
} else {
cnd[ i ] = ' ';
free( err );
}
- if ( msgid ) {
- ch_free( msgid );
- }
-
return rc;
}