]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/delete.c
TS#7303 tweak
[openldap] / servers / slapd / back-bdb / delete.c
index 2e711cc846e02aeffb4818073eab5ce15e745067..9b9b3e63dbe83ebf19ef333b90b091c7dad73bee 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2007 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;
 
-       BDB_LOCKER      locker = 0;
        DB_LOCK         lock, plock;
 
        int             num_retries = 0;
@@ -102,7 +101,7 @@ txnReturn:
        /* allocate 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:
@@ -527,7 +524,7 @@ retry:      /* transaction retry */
                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, locker, &lock );
+               rc = bdb_cache_delete( bdb, e, ltid, &lock );
                switch( rc ) {
                case DB_LOCK_DEADLOCK:
                case DB_LOCK_NOTGRANTED:
@@ -537,7 +534,8 @@ 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 );
@@ -573,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);
@@ -582,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 );