]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/delete.c
TS#7303 tweak
[openldap] / servers / slapd / back-bdb / delete.c
index 64baaa48d923fdefb0273eeaaa569ab3d856c20c..9b9b3e63dbe83ebf19ef333b90b091c7dad73bee 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2006 The OpenLDAP Foundation.
+ * Copyright 2000-2012 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -35,10 +35,9 @@ bdb_delete( Operation *op, SlapReply *rs )
        AttributeDescription *children = slap_schema.si_ad_children;
        AttributeDescription *entry = slap_schema.si_ad_entry;
        DB_TXN          *ltid = NULL, *lt2;
-       struct bdb_op_info opinfo = {0};
+       struct bdb_op_info opinfo = {{{ 0 }}};
        ID      eid;
 
-       u_int32_t       locker = 0;
        DB_LOCK         lock, plock;
 
        int             num_retries = 0;
@@ -100,9 +99,9 @@ txnReturn:
        ctrls[num_ctrls] = 0;
 
        /* allocate CSN */
-       if ( BER_BVISEMPTY( &op->o_csn )) {
+       if ( BER_BVISNULL( &op->o_csn ) ) {
                struct berval csn;
-               char csnbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];
+               char csnbuf[LDAP_PVT_CSNSTR_BUFSIZE];
 
                csn.bv_val = csnbuf;
                csn.bv_len = sizeof(csnbuf);
@@ -124,7 +123,8 @@ retry:      /* transaction retry */
                        0, 0, 0 );
                rs->sr_err = TXN_ABORT( ltid );
                ltid = NULL;
-               op->o_private = NULL;
+               LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+               opinfo.boi_oe.oe_key = NULL;
                op->o_do_not_cache = opinfo.boi_acl_cache;
                if( rs->sr_err != 0 ) {
                        rs->sr_err = LDAP_OTHER;
@@ -153,14 +153,11 @@ retry:    /* transaction retry */
                goto return_results;
        }
 
-       locker = TXN_ID ( ltid );
-
-       opinfo.boi_bdb = op->o_bd;
+       opinfo.boi_oe.oe_key = bdb;
        opinfo.boi_txn = ltid;
-       opinfo.boi_locker = locker;
        opinfo.boi_err = 0;
        opinfo.boi_acl_cache = op->o_do_not_cache;
-       op->o_private = &opinfo;
+       LDAP_SLIST_INSERT_HEAD( &op->o_extra, &opinfo.boi_oe, oe_next );
 
        if ( !be_issuffix( op->o_bd, &op->o_req_ndn ) ) {
                dnParent( &op->o_req_ndn, &pdn );
@@ -168,7 +165,7 @@ retry:      /* transaction retry */
 
        /* get entry */
        rs->sr_err = bdb_dn2entry( op, ltid, &op->o_req_ndn, &ei, 1,
-               locker, &lock );
+               &lock );
 
        switch( rs->sr_err ) {
        case 0:
@@ -217,7 +214,7 @@ retry:      /* transaction retry */
                goto return_results;
        }
 
-       rc = bdb_cache_find_id( op, ltid, eip->bei_id, &eip, 0, locker, &plock );
+       rc = bdb_cache_find_id( op, ltid, eip->bei_id, &eip, 0, &plock );
        switch( rc ) {
        case DB_LOCK_DEADLOCK:
        case DB_LOCK_NOTGRANTED:
@@ -372,6 +369,9 @@ retry:      /* transaction retry */
                goto return_results;
        }
 
+       BDB_LOG_PRINTF( bdb->bi_dbenv, lt2, "slapd Starting delete %s(%d)",
+               e->e_nname.bv_val, e->e_id );
+
        /* Can't do it if we have kids */
        rs->sr_err = bdb_cache_children( op, lt2, e );
        if( rs->sr_err != DB_NOTFOUND ) {
@@ -492,6 +492,9 @@ retry:      /* transaction retry */
                p = NULL;
        }
 
+       BDB_LOG_PRINTF( bdb->bi_dbenv, lt2, "slapd Commit1 delete %s(%d)",
+               e->e_nname.bv_val, e->e_id );
+
        if ( TXN_COMMIT( lt2, 0 ) != 0 ) {
                rs->sr_err = LDAP_OTHER;
                rs->sr_text = "txn_commit(2) failed";
@@ -517,8 +520,11 @@ retry:     /* transaction retry */
                        goto return_results;
                }
        } else {
-               rc = bdb_cache_delete( &bdb->bi_cache, e, bdb->bi_dbenv,
-                       locker, &lock );
+
+               BDB_LOG_PRINTF( bdb->bi_dbenv, ltid, "slapd Cache delete %s(%d)",
+                       e->e_nname.bv_val, e->e_id );
+
+               rc = bdb_cache_delete( bdb, e, ltid, &lock );
                switch( rc ) {
                case DB_LOCK_DEADLOCK:
                case DB_LOCK_NOTGRANTED:
@@ -528,7 +534,11 @@ retry:     /* transaction retry */
                rs->sr_err = TXN_COMMIT( ltid, 0 );
        }
        ltid = NULL;
-       op->o_private = NULL;
+       LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+       opinfo.boi_oe.oe_key = NULL;
+
+       BDB_LOG_PRINTF( bdb->bi_dbenv, NULL, "slapd Committed delete %s(%d)",
+               e->e_nname.bv_val, e->e_id );
 
        if( rs->sr_err != 0 ) {
                Debug( LDAP_DEBUG_TRACE,
@@ -561,6 +571,7 @@ return_results:
        if( e != NULL ) {
                if ( rs->sr_err == LDAP_SUCCESS ) {
                        /* Free the EntryInfo and the Entry */
+                       bdb_cache_entryinfo_lock( BEI(e) );
                        bdb_cache_delete_cleanup( &bdb->bi_cache, BEI(e) );
                } else {
                        bdb_unlocked_cache_return_entry_w(&bdb->bi_cache, e);
@@ -570,7 +581,9 @@ return_results:
        if( ltid != NULL ) {
                TXN_ABORT( ltid );
        }
-       op->o_private = NULL;
+       if ( opinfo.boi_oe.oe_key ) {
+               LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.boi_oe, OpExtra, oe_next );
+       }
 
        send_ldap_result( op, rs );
        slap_graduate_commit_csn( op );
@@ -580,7 +593,7 @@ return_results:
                slap_sl_free( *preread_ctrl, op->o_tmpmemctx );
        }
 
-       if( rs->sr_err == LDAP_SUCCESS && bdb->bi_txn_cp ) {
+       if( rs->sr_err == LDAP_SUCCESS && bdb->bi_txn_cp_kbyte ) {
                TXN_CHECKPOINT( bdb->bi_dbenv,
                        bdb->bi_txn_cp_kbyte, bdb->bi_txn_cp_min, 0 );
        }