Skip to content
Snippets Groups Projects
Commit 9b1a8c1d authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

merge fixes for ITS#4419,ITS#4429

parent 39915289
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ meta_back_modify( Operation *op, SlapReply *rs ) ...@@ -37,6 +37,7 @@ meta_back_modify( Operation *op, SlapReply *rs )
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private; metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
metaconn_t *mc; metaconn_t *mc;
int rc = 0; int rc = 0;
int maperr = 1;
LDAPMod **modv = NULL; LDAPMod **modv = NULL;
LDAPMod *mods = NULL; LDAPMod *mods = NULL;
Modifications *ml; Modifications *ml;
...@@ -64,7 +65,7 @@ meta_back_modify( Operation *op, SlapReply *rs ) ...@@ -64,7 +65,7 @@ meta_back_modify( Operation *op, SlapReply *rs )
dc.ctx = "modifyDN"; dc.ctx = "modifyDN";
if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) { if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) {
rc = -1; maperr = 0;
goto cleanup; goto cleanup;
} }
...@@ -74,13 +75,13 @@ meta_back_modify( Operation *op, SlapReply *rs ) ...@@ -74,13 +75,13 @@ meta_back_modify( Operation *op, SlapReply *rs )
mods = ch_malloc( sizeof( LDAPMod )*i ); mods = ch_malloc( sizeof( LDAPMod )*i );
if ( mods == NULL ) { if ( mods == NULL ) {
rs->sr_err = LDAP_NO_MEMORY; rs->sr_err = LDAP_NO_MEMORY;
rc = -1; maperr = 0;
goto cleanup; goto cleanup;
} }
modv = ( LDAPMod ** )ch_malloc( ( i + 1 )*sizeof( LDAPMod * ) ); modv = ( LDAPMod ** )ch_malloc( ( i + 1 )*sizeof( LDAPMod * ) );
if ( modv == NULL ) { if ( modv == NULL ) {
rs->sr_err = LDAP_NO_MEMORY; rs->sr_err = LDAP_NO_MEMORY;
rc = -1; maperr = 0;
goto cleanup; goto cleanup;
} }
...@@ -178,9 +179,10 @@ retry:; ...@@ -178,9 +179,10 @@ retry:;
modv, op->o_ctrls, NULL, &msgid ); modv, op->o_ctrls, NULL, &msgid );
if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) { if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) {
do_retry = 0; do_retry = 0;
if ( meta_back_retry( op, rs, mc, candidate, LDAP_BACK_SENDERR ) ) { if ( meta_back_retry( op, rs, &mc, candidate, LDAP_BACK_SENDERR ) ) {
goto retry; goto retry;
} }
goto done;
} else if ( rs->sr_err == LDAP_SUCCESS ) { } else if ( rs->sr_err == LDAP_SUCCESS ) {
struct timeval tv, *tvp = NULL; struct timeval tv, *tvp = NULL;
...@@ -197,7 +199,7 @@ retry:; ...@@ -197,7 +199,7 @@ retry:;
msgid, LDAP_MSG_ALL, tvp, &res ); msgid, LDAP_MSG_ALL, tvp, &res );
switch ( rc ) { switch ( rc ) {
case -1: case -1:
rc = -1; maperr = 0;
break; break;
case 0: case 0:
...@@ -205,7 +207,7 @@ retry:; ...@@ -205,7 +207,7 @@ retry:;
msgid, NULL, NULL ); msgid, NULL, NULL );
rs->sr_err = op->o_protocol >= LDAP_VERSION3 ? rs->sr_err = op->o_protocol >= LDAP_VERSION3 ?
LDAP_ADMINLIMIT_EXCEEDED : LDAP_OPERATIONS_ERROR; LDAP_ADMINLIMIT_EXCEEDED : LDAP_OPERATIONS_ERROR;
rc = -1; maperr = 0;
break; break;
case LDAP_RES_MODIFY: case LDAP_RES_MODIFY:
...@@ -214,17 +216,25 @@ retry:; ...@@ -214,17 +216,25 @@ retry:;
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
rs->sr_err = rc; rs->sr_err = rc;
} }
rc = 0; maperr = 1;
break; break;
default: default:
rc = -1; maperr = 0;
ldap_msgfree( res ); ldap_msgfree( res );
break; break;
} }
} }
cleanup:; cleanup:;
if ( maperr ) {
rc = meta_back_op_result( mc, op, rs, candidate );
} else {
send_ldap_result( op, rs );
}
done:;
if ( mdn.bv_val != op->o_req_dn.bv_val ) { if ( mdn.bv_val != op->o_req_dn.bv_val ) {
free( mdn.bv_val ); free( mdn.bv_val );
BER_BVZERO( &mdn ); BER_BVZERO( &mdn );
...@@ -237,16 +247,10 @@ cleanup:; ...@@ -237,16 +247,10 @@ cleanup:;
free( mods ); free( mods );
free( modv ); free( modv );
if ( rc != -1 ) { if ( mc ) {
rc = meta_back_op_result( mc, op, rs, candidate ); meta_back_release_conn( op, mc );
} else {
send_ldap_result( op, rs );
rc = 0;
} }
meta_back_release_conn( op, mc ); return rs->sr_err;
return rc;
} }
...@@ -42,6 +42,7 @@ meta_back_modrdn( Operation *op, SlapReply *rs ) ...@@ -42,6 +42,7 @@ meta_back_modrdn( Operation *op, SlapReply *rs )
dncookie dc; dncookie dc;
int msgid; int msgid;
int do_retry = 1; int do_retry = 1;
int maperr = 1;
mc = meta_back_getconn( op, rs, &candidate, LDAP_BACK_SENDERR ); mc = meta_back_getconn( op, rs, &candidate, LDAP_BACK_SENDERR );
if ( !mc || !meta_back_dobind( op, rs, mc, LDAP_BACK_SENDERR ) ) { if ( !mc || !meta_back_dobind( op, rs, mc, LDAP_BACK_SENDERR ) ) {
...@@ -87,6 +88,7 @@ meta_back_modrdn( Operation *op, SlapReply *rs ) ...@@ -87,6 +88,7 @@ meta_back_modrdn( Operation *op, SlapReply *rs )
dc.ctx = "newSuperiorDN"; dc.ctx = "newSuperiorDN";
if ( ldap_back_dn_massage( &dc, op->orr_newSup, &mnewSuperior ) ) { if ( ldap_back_dn_massage( &dc, op->orr_newSup, &mnewSuperior ) ) {
rs->sr_err = LDAP_OTHER; rs->sr_err = LDAP_OTHER;
maperr = 0;
goto cleanup; goto cleanup;
} }
} }
...@@ -98,6 +100,7 @@ meta_back_modrdn( Operation *op, SlapReply *rs ) ...@@ -98,6 +100,7 @@ meta_back_modrdn( Operation *op, SlapReply *rs )
dc.ctx = "modrDN"; dc.ctx = "modrDN";
if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) { if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) {
rs->sr_err = LDAP_OTHER; rs->sr_err = LDAP_OTHER;
maperr = 0;
goto cleanup; goto cleanup;
} }
...@@ -108,9 +111,10 @@ retry:; ...@@ -108,9 +111,10 @@ retry:;
op->o_ctrls, NULL, &msgid ); op->o_ctrls, NULL, &msgid );
if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) { if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) {
do_retry = 0; do_retry = 0;
if ( meta_back_retry( op, rs, mc, candidate, LDAP_BACK_SENDERR ) ) { if ( meta_back_retry( op, rs, &mc, candidate, LDAP_BACK_SENDERR ) ) {
goto retry; goto retry;
} }
goto done;
} else if ( rs->sr_err == LDAP_SUCCESS ) { } else if ( rs->sr_err == LDAP_SUCCESS ) {
struct timeval tv, *tvp = NULL; struct timeval tv, *tvp = NULL;
...@@ -126,6 +130,7 @@ retry:; ...@@ -126,6 +130,7 @@ retry:;
rs->sr_err = LDAP_OTHER; rs->sr_err = LDAP_OTHER;
rc = ldap_result( mc->mc_conns[ candidate ].msc_ld, rc = ldap_result( mc->mc_conns[ candidate ].msc_ld,
msgid, LDAP_MSG_ALL, tvp, &res ); msgid, LDAP_MSG_ALL, tvp, &res );
maperr = 0;
switch ( rc ) { switch ( rc ) {
case -1: case -1:
break; break;
...@@ -143,6 +148,7 @@ retry:; ...@@ -143,6 +148,7 @@ retry:;
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
rs->sr_err = rc; rs->sr_err = rc;
} }
maperr = 1;
break; break;
default: default:
...@@ -152,6 +158,14 @@ retry:; ...@@ -152,6 +158,14 @@ retry:;
} }
cleanup:; cleanup:;
if ( maperr ) {
meta_back_op_result( mc, op, rs, candidate );
} else {
send_ldap_result( op, rs );
}
done:;
if ( mdn.bv_val != op->o_req_dn.bv_val ) { if ( mdn.bv_val != op->o_req_dn.bv_val ) {
free( mdn.bv_val ); free( mdn.bv_val );
BER_BVZERO( &mdn ); BER_BVZERO( &mdn );
...@@ -164,14 +178,10 @@ cleanup:; ...@@ -164,14 +178,10 @@ cleanup:;
BER_BVZERO( &mnewSuperior ); BER_BVZERO( &mnewSuperior );
} }
if ( rs->sr_err == LDAP_SUCCESS ) { if ( mc ) {
meta_back_op_result( mc, op, rs, candidate ); meta_back_release_conn( op, mc );
} else {
send_ldap_result( op, rs );
} }
meta_back_release_conn( op, mc );
return rs->sr_err; return rs->sr_err;
} }
...@@ -416,7 +416,7 @@ really_bad:; ...@@ -416,7 +416,7 @@ really_bad:;
if ( candidates[ i ].sr_type == REP_INTERMEDIATE ) { if ( candidates[ i ].sr_type == REP_INTERMEDIATE ) {
candidates[ i ].sr_type = REP_RESULT; candidates[ i ].sr_type = REP_RESULT;
if ( meta_back_retry( op, rs, mc, i, LDAP_BACK_DONTSEND ) ) { if ( meta_back_retry( op, rs, &mc, i, LDAP_BACK_DONTSEND ) ) {
switch ( meta_back_search_start( op, rs, &dc, msc, i, candidates ) ) switch ( meta_back_search_start( op, rs, &dc, msc, i, candidates ) )
{ {
case META_SEARCH_CANDIDATE: case META_SEARCH_CANDIDATE:
...@@ -427,6 +427,12 @@ really_bad:; ...@@ -427,6 +427,12 @@ really_bad:;
goto finish; goto finish;
} }
} }
savepriv = op->o_private;
op->o_private = (void *)i;
send_ldap_result( op, rs );
op->o_private = savepriv;
goto finish;
} }
/* /*
...@@ -468,7 +474,10 @@ really_bad:; ...@@ -468,7 +474,10 @@ really_bad:;
} }
op->o_private = savepriv; op->o_private = savepriv;
/* don't wait any longer... */
gotit = 1; gotit = 1;
tv.tv_sec = 0;
tv.tv_usec = 0;
#if 0 #if 0
/* /*
...@@ -574,16 +583,16 @@ really_bad:; ...@@ -574,16 +583,16 @@ really_bad:;
* back-meta would need to merge them * back-meta would need to merge them
* consistently (think of pagedResults...) * consistently (think of pagedResults...)
*/ */
if ( ldap_parse_result( msc->msc_ld, rs->sr_err = ldap_parse_result( msc->msc_ld,
res, res,
&candidates[ i ].sr_err, &candidates[ i ].sr_err,
(char **)&candidates[ i ].sr_matched, (char **)&candidates[ i ].sr_matched,
NULL /* (char **)&candidates[ i ].sr_text */ , NULL /* (char **)&candidates[ i ].sr_text */ ,
&references, &references,
NULL /* &candidates[ i ].sr_ctrls (unused) */ , NULL /* &candidates[ i ].sr_ctrls (unused) */ ,
1 ) != LDAP_SUCCESS ) 1 );
{ res = NULL;
res = NULL; if ( rs->sr_err != LDAP_SUCCESS ) {
ldap_get_option( msc->msc_ld, ldap_get_option( msc->msc_ld,
LDAP_OPT_ERROR_NUMBER, LDAP_OPT_ERROR_NUMBER,
&rs->sr_err ); &rs->sr_err );
...@@ -592,10 +601,6 @@ really_bad:; ...@@ -592,10 +601,6 @@ really_bad:;
goto really_bad; goto really_bad;
} }
rs->sr_err = candidates[ i ].sr_err;
sres = slap_map_api2result( rs );
res = NULL;
/* massage matchedDN if need be */ /* massage matchedDN if need be */
if ( candidates[ i ].sr_matched != NULL ) { if ( candidates[ i ].sr_matched != NULL ) {
#ifndef LDAP_NULL_IS_NULL #ifndef LDAP_NULL_IS_NULL
...@@ -671,13 +676,21 @@ really_bad:; ...@@ -671,13 +676,21 @@ really_bad:;
rs->sr_err = candidates[ i ].sr_err; rs->sr_err = candidates[ i ].sr_err;
sres = slap_map_api2result( rs ); sres = slap_map_api2result( rs );
snprintf( buf, sizeof( buf ), if ( StatslogTest( LDAP_DEBUG_TRACE | LDAP_DEBUG_ANY ) ) {
"%s meta_back_search[%ld] " snprintf( buf, sizeof( buf ),
"match=\"%s\" err=%ld\n", "%s meta_back_search[%ld] "
op->o_log_prefix, i, "match=\"%s\" err=%ld",
candidates[ i ].sr_matched ? candidates[ i ].sr_matched : "", op->o_log_prefix, i,
(long) candidates[ i ].sr_err ); candidates[ i ].sr_matched ? candidates[ i ].sr_matched : "",
Debug( LDAP_DEBUG_ANY, "%s", buf, 0, 0 ); (long) candidates[ i ].sr_err );
if ( candidates[ i ].sr_err == LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "%s.\n", buf, 0, 0 );
} else {
Debug( LDAP_DEBUG_ANY, "%s (%s).\n",
buf, ldap_err2string( candidates[ i ].sr_err ), 0 );
}
}
switch ( sres ) { switch ( sres ) {
case LDAP_NO_SUCH_OBJECT: case LDAP_NO_SUCH_OBJECT:
...@@ -697,6 +710,26 @@ really_bad:; ...@@ -697,6 +710,26 @@ really_bad:;
is_ok++; is_ok++;
break; break;
case LDAP_SIZELIMIT_EXCEEDED:
/* if a target returned sizelimitExceeded
* and the entry count is equal to the
* proxy's limit, the target would have
* returned more, and the error must be
* propagated to the client; otherwise,
* the target enforced a limit lower
* than what requested by the proxy;
* ignore it */
if ( rs->sr_nentries == op->ors_slimit
|| META_BACK_ONERR_STOP( mi ) )
{
savepriv = op->o_private;
op->o_private = (void *)i;
send_ldap_result( op, rs );
op->o_private = savepriv;
goto finish;
}
break;
default: default:
if ( META_BACK_ONERR_STOP( mi ) ) { if ( META_BACK_ONERR_STOP( mi ) ) {
savepriv = op->o_private; savepriv = op->o_private;
...@@ -743,13 +776,11 @@ really_bad:; ...@@ -743,13 +776,11 @@ really_bad:;
} }
} }
/* if no entry was found during this loop,
* set a minimal timeout */
if ( gotit == 0 ) { if ( gotit == 0 ) {
LDAP_BACK_TV_SET( &tv ); LDAP_BACK_TV_SET( &tv );
ldap_pvt_thread_yield(); ldap_pvt_thread_yield();
} else {
tv.tv_sec = 0;
tv.tv_usec = 0;
} }
} }
...@@ -903,7 +934,9 @@ finish:; ...@@ -903,7 +934,9 @@ finish:;
} }
} }
meta_back_release_conn( op, mc ); if ( mc ) {
meta_back_release_conn( op, mc );
}
return rs->sr_err; return rs->sr_err;
} }
...@@ -1158,6 +1191,7 @@ next_attr:; ...@@ -1158,6 +1191,7 @@ next_attr:;
rs->sr_entry = &ent; rs->sr_entry = &ent;
rs->sr_attrs = op->ors_attrs; rs->sr_attrs = op->ors_attrs;
rs->sr_flags = 0; rs->sr_flags = 0;
rs->sr_err = LDAP_SUCCESS;
rc = send_search_entry( op, rs ); rc = send_search_entry( op, rs );
switch ( rc ) { switch ( rc ) {
case LDAP_UNAVAILABLE: case LDAP_UNAVAILABLE:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment