From: Jong Hyuk Choi Date: Mon, 25 Aug 2003 20:20:26 +0000 (+0000) Subject: Context CSN Patch (3) X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~779 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fbb8c9da5e7dc3b5ad28f9d4f4859c7fe9c53c38;p=openldap Context CSN Patch (3) - context csn management for delete - a later patch will take care of inconsistencies caused by interactions between outstanding search and scope-outs --- diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 4fcfc35cfe..a1c191388a 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -37,6 +37,10 @@ bdb_delete( Operation *op, SlapReply *rs ) #ifdef LDAP_SYNC Operation* ps_list; + int rc; + EntryInfo *suffix_ei; + Entry *ctxcsn_e; + int ctxcsn_added = 0; #endif #ifdef NEW_LOGGING @@ -456,6 +460,16 @@ retry: /* transaction retry */ ldap_pvt_thread_mutex_unlock( &bdb->bi_lastid_mutex ); #endif +#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"; @@ -464,8 +478,21 @@ retry: /* transaction retry */ rs->sr_err = LDAP_SUCCESS; } } else { +#ifdef LDAP_SYNC + struct berval ctx_nrdn; +#endif + bdb_cache_delete( &bdb->bi_cache, e, 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 + rs->sr_err = TXN_COMMIT( ltid, 0 ); } ltid = NULL; diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index 7d04e551c1..6b4791e883 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -25,6 +25,10 @@ #include "ldap_pvt.h" #include "slap.h" +#ifdef LDAP_SYNC +#include "lutil.h" +#endif + #ifdef LDAP_SLAPI #include "slapi.h" #endif @@ -198,6 +202,15 @@ do_delete( if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) #endif { + +#ifdef LDAP_SYNC + if ( !repl_user ) { + struct berval csn = { 0 , NULL }; + char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ]; + slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, 1 ); + } +#endif + if ( (op->o_bd->be_delete)( op, rs ) == 0 ) { #ifdef SLAPD_MULTIMASTER if ( !op->o_bd->be_update_ndn.bv_len || !repl_user ) @@ -252,6 +265,11 @@ do_delete( #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 ); return rs->sr_err;