From: Jong Hyuk Choi Date: Mon, 25 Aug 2003 22:23:49 +0000 (+0000) Subject: Context CSN Patch (4) X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~777 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7ef160494fb01eae5edb5f30739b9434087a4ecf;p=openldap Context CSN Patch (4) - context csn management for modrdn - call slap_mods_opattrs() for moved entries as well --- diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 76ab5ee9c5..8f20bd0c42 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -54,8 +54,12 @@ bdb_modrdn( Operation *op, SlapReply *rs ) int num_retries = 0; #ifdef LDAP_SYNC - Operation *ps_list; + Operation *ps_list; struct psid_entry *pm_list, *pm_prev; + int rc; + EntryInfo *suffix_ei; + Entry *ctxcsn_e; + int ctxcsn_added = 0; #endif #ifdef NEW_LOGGING @@ -89,13 +93,13 @@ retry: /* transaction retry */ #endif #ifdef LDAP_SYNC - pm_list = LDAP_LIST_FIRST(&op->o_pm_list); - while ( pm_list != NULL ) { - LDAP_LIST_REMOVE ( pm_list, ps_link ); + pm_list = LDAP_LIST_FIRST(&op->o_pm_list); + while ( pm_list != NULL ) { + LDAP_LIST_REMOVE ( pm_list, ps_link ); pm_prev = pm_list; - pm_list = LDAP_LIST_NEXT ( pm_list, ps_link ); + pm_list = LDAP_LIST_NEXT ( pm_list, ps_link ); ch_free( pm_prev ); - } + } #endif rs->sr_err = TXN_ABORT( ltid ); @@ -911,6 +915,16 @@ retry: /* transaction retry */ goto return_results; } +#ifdef LDAP_SYNC + rc = bdb_csn_commit( op, rs, ltid, ei, &suffix_ei, &ctxcsn_e, &ctxcsn_added, locker ); + switch ( rc ) { + case BDB_CSN_ABORT : + goto return_results; + case BDB_CSN_RETRY : + goto retry; + } +#endif + if( op->o_noop ) { if(( rs->sr_err=TXN_ABORT( ltid )) != 0 ) { rs->sr_text = "txn_abort (no-op) failed"; @@ -928,8 +942,21 @@ retry: /* transaction retry */ if(( rs->sr_err=TXN_PREPARE( ltid, gid )) != 0 ) { rs->sr_text = "txn_prepare failed"; } else { +#ifdef LDAP_SYNC + struct berval ctx_nrdn; +#endif + bdb_cache_modrdn( save, &op->orr_nnewrdn, e, neip, bdb->bi_dbenv, locker, &lock ); + +#ifdef LDAP_SYNC + if ( ctxcsn_added ) { + ctx_nrdn.bv_val = "cn=ldapsync"; + ctx_nrdn.bv_len = strlen( ctx_nrdn.bv_val ); + bdb_cache_add( bdb, suffix_ei, ctxcsn_e, &ctx_nrdn, locker ); + } +#endif + if(( rs->sr_err=TXN_COMMIT( ltid, 0 )) != 0 ) { rs->sr_text = "txn_commit failed"; } else { diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index c901dd3434..4f8551a53e 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -416,6 +416,11 @@ do_modrdn( #endif /* defined( LDAP_SLAPI ) */ cleanup: + +#ifdef LDAP_SYNC + slap_graduate_commit_csn( op ); +#endif + op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx ); op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx ); @@ -438,11 +443,15 @@ slap_modrdn2mods( Modifications **pmod ) { Modifications *mod = NULL; + Modifications **modtail = &mod; int a_cnt, d_cnt; + int repl_user; assert( new_rdn != NULL ); assert( !op->orr_deleteoldrdn || old_rdn != NULL ); + repl_user = be_isupdate( op->o_bd, &op->o_ndn ); + /* Add new attribute values to the entry */ for ( a_cnt = 0; new_rdn[a_cnt]; a_cnt++ ) { AttributeDescription *desc = NULL; @@ -578,6 +587,21 @@ slap_modrdn2mods( } done: + + if ( !repl_user ) { + char textbuf[ SLAP_TEXT_BUFLEN ]; + size_t textlen = sizeof textbuf; + + for( modtail = &mod; + *modtail != NULL; + modtail = &(*modtail)->sml_next ) + { + /* empty */ + } + + rs->sr_err = slap_mods_opattrs( op, mod, modtail, &rs->sr_text, textbuf, textlen ); + } + /* LDAP v2 supporting correct attribute handling. */ if ( rs->sr_err != LDAP_SUCCESS && mod != NULL ) { Modifications *tmp;