}
} else {
+ rs->sr_err = rc;
rc = slap_map_api2result( rs );
}
}
if ( rc != LDAP_SUCCESS ) {
- rs->sr_err = slap_map_api2result( rs );
-
Debug( LDAP_DEBUG_ANY, "%s meta_back_dobind[%d]: "
"(anonymous) err=%d\n",
op->o_log_prefix, i, rc );
* due to technical reasons (remote host down?)
* so better clear the handle
*/
- candidates[ i ].sr_tag = META_NOT_CANDIDATE;
+ /* leave the target candidate, but record the error for later use */
+ candidates[ i ].sr_err = rc;
if ( META_BACK_ONERR_STOP( mi ) ) {
bound = 0;
goto done;
int i,
rerr = LDAP_SUCCESS;
char *rmsg = NULL,
- *save_rmsg = NULL,
- *rmatch = NULL,
+ *rmatch = NULL;
+ const char *save_rmsg = NULL,
*save_rmatch = NULL;
void *rmatch_ctx = NULL;
return candidate;
}
+static void *meta_back_candidates_dummy;
+
static void
meta_back_candidates_keyfree(
void *key,
void *data = NULL;
ldap_pvt_thread_pool_getkey( op->o_threadctx,
- meta_back_candidates_keyfree, &data, NULL );
+ &meta_back_candidates_dummy, &data, NULL );
mc = (metacandidates_t *)data;
} else {
data = (void *)mc;
ldap_pvt_thread_pool_setkey( op->o_threadctx,
- meta_back_candidates_keyfree, data,
+ &meta_back_candidates_dummy, data,
meta_back_candidates_keyfree );
} else {
* The target is activated; if needed, it is
* also init'd
*/
- int lerr = meta_back_init_one_conn( op, rs, &mi->mi_targets[ i ],
- &mc->mc_conns[ i ], sendok );
- if ( lerr == LDAP_SUCCESS ) {
+ candidates[ i ].sr_err =
+ meta_back_init_one_conn( op, rs,
+ &mi->mi_targets[ i ],
+ &mc->mc_conns[ i ], sendok );
+ if ( candidates[ i ].sr_err == LDAP_SUCCESS ) {
candidates[ i ].sr_tag = META_CANDIDATE;
ncandidates++;
* be tried?
*/
candidates[ i ].sr_tag = META_NOT_CANDIDATE;
- err = lerr;
+ err = candidates[ i ].sr_err;
continue;
}
}
return NULL;
}
+ candidates[ i ].sr_err = LDAP_SUCCESS;
candidates[ i ].sr_tag = META_CANDIDATE;
ncandidates++;
&mc->mc_conns[ i ], sendok );
if ( lerr == LDAP_SUCCESS ) {
candidates[ i ].sr_tag = META_CANDIDATE;
+ candidates[ i ].sr_err = LDAP_SUCCESS;
ncandidates++;
Debug( LDAP_DEBUG_TRACE, "%s: meta_back_init_one_conn(%d)\n",
if ( new_conn ) {
( void )meta_clear_one_candidate( &mc->mc_conns[ i ] );
}
- candidates[ i ].sr_tag = META_NOT_CANDIDATE;
+ /* leave the target candidate, but record the error for later use */
+ candidates[ i ].sr_err = lerr;
err = lerr;
Debug( LDAP_DEBUG_ANY, "%s: meta_back_init_one_conn(%d) failed: %d\n",
metasingleconn_t *msc = &mc->mc_conns[ i ];
candidates[ i ].sr_msgid = -1;
-
- if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
- continue;
- }
-
- candidates[ i ].sr_err = LDAP_SUCCESS;
candidates[ i ].sr_matched = NULL;
candidates[ i ].sr_text = NULL;
candidates[ i ].sr_ref = NULL;
candidates[ i ].sr_ctrls = NULL;
+ if ( candidates[ i ].sr_tag != META_CANDIDATE
+ || candidates[ i ].sr_err != LDAP_SUCCESS )
+ {
+ continue;
+ }
+
switch ( meta_back_search_start( op, rs, &dc, msc, i, candidates ) )
{
case 0:
op->o_log_prefix, op->o_req_dn.bv_val,
op->ors_scope );
- send_ldap_error( op, rs, LDAP_NO_SUCH_OBJECT, NULL );
-
+ /* FIXME: we're sending the first error we encounter;
+ * maybe we should pick the worst... */
rc = LDAP_NO_SUCH_OBJECT;
+ for ( i = 0; i < mi->mi_ntargets; i++ ) {
+ if ( candidates[ i ].sr_tag == META_CANDIDATE
+ && candidates[ i ].sr_err != LDAP_SUCCESS )
+ {
+ rc = candidates[ i ].sr_err;
+ break;
+ }
+ }
+
+ send_ldap_error( op, rs, rc, NULL );
+
goto finish;
}