Context CSN Patch (4)

- context csn management for modrdn
- call slap_mods_opattrs() for moved entries as well
This commit is contained in:
Jong Hyuk Choi 2003-08-25 22:23:49 +00:00
parent a636f61b01
commit 7ef160494f
2 changed files with 57 additions and 6 deletions

View File

@ -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 {

View File

@ -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;