]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/delete.c
Revert most of last change
[openldap] / servers / slapd / back-bdb / delete.c
index 7658c84fc1bedf24e41f14bf76119ae7fc16c16f..4687765c59bd8fd13917468fb42530753e9f1905 100644 (file)
@@ -47,7 +47,7 @@ retry:        /* transaction retry */
                }
                Debug( LDAP_DEBUG_TRACE, "==> bdb_delete: retrying...\n",
                        0, 0, 0 );
-               rc = txn_abort( ltid );
+               rc = TXN_ABORT( ltid );
                ltid = NULL;
                op->o_private = NULL;
                if( rc != 0 ) {
@@ -58,23 +58,21 @@ retry:      /* transaction retry */
                ldap_pvt_thread_yield();
        }
 
-       if( bdb->bi_txn ) {
-               /* begin transaction */
-               rc = txn_begin( bdb->bi_dbenv, NULL, &ltid, 
-                       bdb->bi_db_opflags );
-               text = NULL;
-               if( rc != 0 ) {
-                       Debug( LDAP_DEBUG_TRACE,
-                               "bdb_delete: txn_begin failed: %s (%d)\n",
-                               db_strerror(rc), rc, 0 );
-                       rc = LDAP_OTHER;
-                       text = "internal error";
-                       goto return_results;
-               }
+       /* begin transaction */
+       rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &ltid, 
+               bdb->bi_db_opflags );
+       text = NULL;
+       if( rc != 0 ) {
+               Debug( LDAP_DEBUG_TRACE,
+                       "bdb_delete: txn_begin failed: %s (%d)\n",
+                       db_strerror(rc), rc, 0 );
+               rc = LDAP_OTHER;
+               text = "internal error";
+               goto return_results;
+       }
 #if 0
-               lockid = TXN_ID( ltid );
+       lockid = TXN_ID( ltid );
 #endif
-       }
 
        opinfo.boi_bdb = be;
        opinfo.boi_txn = ltid;
@@ -82,11 +80,7 @@ retry:       /* transaction retry */
        op->o_private = &opinfo;
 
        if ( !be_issuffix( be, ndn ) ) {
-               rc = dnParent( ndn, &pdn );
-               if ( rc != LDAP_SUCCESS ) {
-                       text = "internal error";
-                       goto return_results;
-               }
+               dnParent( ndn, &pdn );
        }
 
        if( pdn.bv_len != 0 ) {
@@ -126,7 +120,7 @@ retry:      /* transaction retry */
 
                /* check parent for "children" acl */
                rc = access_allowed( be, conn, op, p,
-                       children, NULL, ACL_WRITE );
+                       children, NULL, ACL_WRITE, NULL );
 
                bdb_cache_return_entry_r(&bdb->bi_cache, p);
                p = NULL;
@@ -154,7 +148,7 @@ retry:      /* transaction retry */
 
                                /* check parent for "children" acl */
                                rc = access_allowed( be, conn, op, p,
-                                       children, NULL, ACL_WRITE );
+                                       children, NULL, ACL_WRITE, NULL );
                                p = NULL;
 
                                switch( opinfo.boi_err ) {
@@ -239,8 +233,7 @@ retry:      /* transaction retry */
        }
 
        if ( !manageDSAit && is_entry_referral( e ) ) {
-               /* parent is a referral, don't allow add */
-               /* parent is an alias, don't allow add */
+               /* entry is a referral, don't allow delete */
                BerVarray refs = get_entry_referrals( be,
                        conn, op, e );
 
@@ -338,30 +331,33 @@ retry:    /* transaction retry */
        ldap_pvt_thread_mutex_unlock( &bdb->bi_lastid_mutex );
 #endif
 
-       if( bdb->bi_txn ) {
-               rc = txn_commit( ltid, 0 );
+       if( op->o_noop ) {
+               rc = TXN_ABORT( ltid );
+       } else {
+               rc = TXN_COMMIT( ltid, 0 );
        }
        ltid = NULL;
        op->o_private = NULL;
 
        if( rc != 0 ) {
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_delete: txn_commit failed: %s (%d)\n",
-                       db_strerror(rc), rc, 0 );
+                       "bdb_delete: txn_%s failed: %s (%d)\n",
+                       op->o_noop ? "abort (no-op)" : "commit",
+                       db_strerror(rc), rc );
                rc = LDAP_OTHER;
                text = "commit failed";
 
        } else {
                Debug( LDAP_DEBUG_TRACE,
-                       "bdb_delete: deleted id=%08lx dn=\"%s\"\n",
-                       e->e_id, e->e_dn, 0 );
+                       "bdb_delete: deleted%s id=%08lx dn=\"%s\"\n",
+                       op->o_noop ? " (no-op)" : "",
+                       e->e_id, e->e_dn );
                rc = LDAP_SUCCESS;
                text = NULL;
        }
 
 return_results:
-       send_ldap_result( conn, op, LDAP_SUCCESS,
-               NULL, text, NULL, NULL );
+       send_ldap_result( conn, op, rc, NULL, text, NULL, NULL );
 
        if(rc == LDAP_SUCCESS && bdb->bi_txn_cp ) {
                ldap_pvt_thread_yield();
@@ -376,7 +372,7 @@ done:
        }
 
        if( ltid != NULL ) {
-               txn_abort( ltid );
+               TXN_ABORT( ltid );
                op->o_private = NULL;
        }