mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-12 10:54:48 +08:00
retry if addition of an entry previously added as glue fails; entryUUID must be added to mods in pretty and normalized form
This commit is contained in:
parent
86ef9285b7
commit
66a66db3da
@ -1216,6 +1216,7 @@ syncrepl_entry(
|
|||||||
struct berval org_ndn = BER_BVNULL;
|
struct berval org_ndn = BER_BVNULL;
|
||||||
int org_managedsait;
|
int org_managedsait;
|
||||||
dninfo dni = {0};
|
dninfo dni = {0};
|
||||||
|
int retry = 1;
|
||||||
|
|
||||||
switch( syncstate ) {
|
switch( syncstate ) {
|
||||||
case LDAP_SYNC_PRESENT:
|
case LDAP_SYNC_PRESENT:
|
||||||
@ -1337,7 +1338,9 @@ syncrepl_entry(
|
|||||||
switch ( syncstate ) {
|
switch ( syncstate ) {
|
||||||
case LDAP_SYNC_ADD:
|
case LDAP_SYNC_ADD:
|
||||||
case LDAP_SYNC_MODIFY:
|
case LDAP_SYNC_MODIFY:
|
||||||
|
retry_add:;
|
||||||
if ( BER_BVISNULL( &dni.dn )) {
|
if ( BER_BVISNULL( &dni.dn )) {
|
||||||
|
|
||||||
op->o_req_dn = entry->e_name;
|
op->o_req_dn = entry->e_name;
|
||||||
op->o_req_ndn = entry->e_nname;
|
op->o_req_ndn = entry->e_nname;
|
||||||
op->o_tag = LDAP_REQ_ADD;
|
op->o_tag = LDAP_REQ_ADD;
|
||||||
@ -1361,6 +1364,60 @@ syncrepl_entry(
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* if an entry was added via syncrepl_add_glue(),
|
||||||
|
* it likely has no entryUUID, so the previous
|
||||||
|
* be_search() doesn't find it. In this case,
|
||||||
|
* give syncrepl a chance to modify it. */
|
||||||
|
case LDAP_ALREADY_EXISTS:
|
||||||
|
if ( retry ) {
|
||||||
|
Operation op2 = *op;
|
||||||
|
SlapReply rs2 = { 0 };
|
||||||
|
slap_callback cb2 = { 0 };
|
||||||
|
|
||||||
|
op2.o_tag = LDAP_REQ_SEARCH;
|
||||||
|
ber_dupbv_x( &op2.o_req_dn,
|
||||||
|
&entry->e_name,
|
||||||
|
op2.o_tmpmemctx );
|
||||||
|
ber_dupbv_x( &op2.o_req_ndn,
|
||||||
|
&entry->e_nname,
|
||||||
|
op2.o_tmpmemctx );
|
||||||
|
op2.ors_scope = LDAP_SCOPE_BASE;
|
||||||
|
op2.ors_attrs = slap_anlist_all_attributes;
|
||||||
|
op2.ors_attrsonly = 0;
|
||||||
|
op2.ors_limit = NULL;
|
||||||
|
op2.ors_slimit = 1;
|
||||||
|
op2.ors_tlimit = SLAP_NO_LIMIT;
|
||||||
|
|
||||||
|
f.f_choice = LDAP_FILTER_EQUALITY;
|
||||||
|
f.f_ava = &ava;
|
||||||
|
ava.aa_desc = slap_schema.si_ad_objectClass;
|
||||||
|
ber_dupbv_x( &ava.aa_value,
|
||||||
|
&slap_schema.si_oc_glue->soc_cname,
|
||||||
|
op2.o_tmpmemctx );
|
||||||
|
op2.ors_filter = &f;
|
||||||
|
filter2bv_x( &op2, op2.ors_filter,
|
||||||
|
&op2.ors_filterstr );
|
||||||
|
|
||||||
|
op2.o_callback = &cb2;
|
||||||
|
cb2.sc_response = dn_callback;
|
||||||
|
cb2.sc_private = &dni;
|
||||||
|
|
||||||
|
be->be_search( &op2, &rs2 );
|
||||||
|
|
||||||
|
op2.o_tmpfree( op2.o_req_dn.bv_val,
|
||||||
|
op2.o_tmpmemctx );
|
||||||
|
op2.o_tmpfree( op2.o_req_ndn.bv_val,
|
||||||
|
op2.o_tmpmemctx );
|
||||||
|
op2.o_tmpfree( ava.aa_value.bv_val,
|
||||||
|
op2.o_tmpmemctx );
|
||||||
|
op2.o_tmpfree( op2.ors_filterstr.bv_val,
|
||||||
|
op2.o_tmpmemctx );
|
||||||
|
|
||||||
|
retry = 0;
|
||||||
|
goto retry_add;
|
||||||
|
}
|
||||||
|
/* FALLTHRU */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Debug( LDAP_DEBUG_ANY,
|
Debug( LDAP_DEBUG_ANY,
|
||||||
"syncrepl_entry : be_add failed (%d)\n",
|
"syncrepl_entry : be_add failed (%d)\n",
|
||||||
@ -1438,11 +1495,13 @@ syncrepl_entry(
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod = (Modifications *)ch_calloc(1, sizeof(Modifications));
|
mod = (Modifications *)ch_calloc(1, sizeof(Modifications));
|
||||||
ber_dupbv( &uuid_bv, syncUUID );
|
|
||||||
mod->sml_op = LDAP_MOD_REPLACE;
|
mod->sml_op = LDAP_MOD_REPLACE;
|
||||||
mod->sml_desc = slap_schema.si_ad_entryUUID;
|
mod->sml_desc = slap_schema.si_ad_entryUUID;
|
||||||
mod->sml_type = mod->sml_desc->ad_cname;
|
mod->sml_type = mod->sml_desc->ad_cname;
|
||||||
|
ber_dupbv( &uuid_bv, &syncUUID_strrep );
|
||||||
ber_bvarray_add( &mod->sml_values, &uuid_bv );
|
ber_bvarray_add( &mod->sml_values, &uuid_bv );
|
||||||
|
ber_dupbv( &uuid_bv, syncUUID );
|
||||||
|
ber_bvarray_add( &mod->sml_nvalues, &uuid_bv );
|
||||||
modtail->sml_next = mod;
|
modtail->sml_next = mod;
|
||||||
|
|
||||||
op->o_tag = LDAP_REQ_MODIFY;
|
op->o_tag = LDAP_REQ_MODIFY;
|
||||||
@ -2054,16 +2113,22 @@ dn_callback(
|
|||||||
|
|
||||||
/* Did the DN change? */
|
/* Did the DN change? */
|
||||||
if ( !dn_match( &rs->sr_entry->e_name,
|
if ( !dn_match( &rs->sr_entry->e_name,
|
||||||
&dni->new_entry->e_name )) {
|
&dni->new_entry->e_name ) )
|
||||||
|
{
|
||||||
dni->renamed = 1;
|
dni->renamed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
for ( i = 0, old = rs->sr_entry->e_attrs;
|
||||||
for ( old=rs->sr_entry->e_attrs; old; old=old->a_next ) i++;
|
old;
|
||||||
|
i++, old = old->a_next )
|
||||||
|
;
|
||||||
|
|
||||||
dni->attrs = i;
|
dni->attrs = i;
|
||||||
|
|
||||||
for ( old = rs->sr_entry->e_attrs, new = dni->new_entry->e_attrs;
|
for ( old = rs->sr_entry->e_attrs, new = dni->new_entry->e_attrs;
|
||||||
old && new; old=old->a_next, new=new->a_next ) {
|
old && new;
|
||||||
|
old = old->a_next, new = new->a_next )
|
||||||
|
{
|
||||||
if ( old->a_desc != new->a_desc ) {
|
if ( old->a_desc != new->a_desc ) {
|
||||||
dni->wasChanged = 1;
|
dni->wasChanged = 1;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user