]> git.sur5r.net Git - openldap/commitdiff
Context CSN Patch (3)
authorJong Hyuk Choi <jongchoi@openldap.org>
Mon, 25 Aug 2003 20:20:26 +0000 (20:20 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Mon, 25 Aug 2003 20:20:26 +0000 (20:20 +0000)
- context csn management for delete
- a later patch will take care of inconsistencies caused by
  interactions between outstanding search and scope-outs

servers/slapd/back-bdb/delete.c
servers/slapd/delete.c

index 4fcfc35cfe157c15681ccb145ce6f31c49c476e0..a1c191388aa4d48c83127b13051c17b1ce68bc22 100644 (file)
@@ -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;
index 7d04e551c17504b3319725b4bf2d84c68c7a9178..6b4791e88344a13c4033226bdba8577226d108ff 100644 (file)
 #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;