From a9990e8914af7c2bc707c61fae6e998bd780e10a Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 17 Apr 2010 21:59:35 +0000 Subject: [PATCH] fix out of order add/rename, when rename to newly added new superior occurs while consumer is offline (ITS#6472) --- servers/slapd/syncrepl.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 526cc0e47b..a5a35d5ba4 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -131,6 +131,8 @@ static int syncrepl_updateCookie( struct sync_cookie * ); static struct berval * slap_uuidstr_from_normalized( struct berval *, struct berval *, void * ); +static int syncrepl_add_glue_ancestors( + Operation* op, Entry *e ); /* callback functions */ static int dn_callback( Operation *, SlapReply * ); @@ -2562,7 +2564,18 @@ retry_add:; mod->sml_next = m2; } op->o_bd = si->si_wbe; +retry_modrdn:; rc = op->o_bd->be_modrdn( op, &rs_modify ); + + /* NOTE: noSuchObject should result because the new superior + * has not been added yet (ITS#6472) */ + if ( rc == LDAP_NO_SUCH_OBJECT && !BER_BVISNULL( op->orr_nnewSup )) { + rc = syncrepl_add_glue_ancestors( op, entry ); + if ( rc == LDAP_SUCCESS ) { + goto retry_modrdn; + } + } + op->o_tmpfree( op->orr_nnewrdn.bv_val, op->o_tmpmemctx ); op->o_tmpfree( op->orr_newrdn.bv_val, op->o_tmpmemctx ); @@ -2888,8 +2901,8 @@ syncrepl_del_nonpresent( return; } -int -syncrepl_add_glue( +static int +syncrepl_add_glue_ancestors( Operation* op, Entry *e ) { @@ -3023,6 +3036,23 @@ syncrepl_add_glue( ndn.bv_len = e->e_nname.bv_len - (ndn.bv_val - e->e_nname.bv_val); } + return rc; +} + +int +syncrepl_add_glue( + Operation* op, + Entry *e ) +{ + int rc; + Backend *be = op->o_bd; + SlapReply rs_add = {REP_RESULT}; + + rc = syncrepl_add_glue_ancestors( op, e ); + if ( rc != LDAP_SUCCESS ) { + return rc; + } + op->o_req_dn = e->e_name; op->o_req_ndn = e->e_nname; op->ora_e = e; -- 2.39.5