if( 0 ) {
retry: /* transaction retry */
+ if( e != NULL ) {
+ bdb_cache_return_entry_w(&bdb->bi_cache, e);
+ }
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 ) {
ldap_pvt_thread_yield();
}
- if( bdb->bi_txn ) {
- /* begin transaction */
- rc = txn_begin( bdb->bi_dbenv, NULL, <id,
- 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, <id,
+ 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;
opinfo.boi_err = 0;
op->o_private = &opinfo;
- if ( !be_issuffix( be, ndn->bv_val ) ) {
- rc = dnParent( ndn->bv_val, &pdn.bv_val );
- if ( rc != LDAP_SUCCESS ) {
- text = "internal error";
- goto return_results;
- }
- if (pdn.bv_val && pdn.bv_val[0]) {
- pdn.bv_len = ndn->bv_len - (pdn.bv_val - ndn->bv_val);
- }
+ if ( !be_issuffix( be, ndn ) ) {
+ dnParent( ndn, &pdn );
}
if( pdn.bv_len != 0 ) {
}
#endif
/* get parent */
- rc = bdb_dn2entry( be, ltid, &pdn, &p, NULL, 0 );
+ rc = bdb_dn2entry_r( be, ltid, &pdn, &p, NULL, 0 );
switch( rc ) {
case 0:
rc = access_allowed( be, conn, op, p,
children, NULL, ACL_WRITE );
- bdb_entry_return( be, p );
+ bdb_cache_return_entry_r(&bdb->bi_cache, p);
p = NULL;
+ switch( opinfo.boi_err ) {
+ case DB_LOCK_DEADLOCK:
+ case DB_LOCK_NOTGRANTED:
+ goto retry;
+ }
+
if ( !rc ) {
Debug( LDAP_DEBUG_TRACE,
"<=- bdb_delete: no access to parent\n",
} else {
/* no parent, must be root to delete */
if( ! be_isroot( be, &op->o_ndn ) ) {
- if ( be_issuffix( be, "" ) || be_isupdate( be, &op->o_ndn ) ) {
+ if ( be_issuffix( be, (struct berval *)&slap_empty_bv )
+ || be_isupdate( be, &op->o_ndn ) ) {
p = (Entry *)&slap_entry_root;
/* check parent for "children" acl */
children, NULL, ACL_WRITE );
p = NULL;
+ switch( opinfo.boi_err ) {
+ case DB_LOCK_DEADLOCK:
+ case DB_LOCK_NOTGRANTED:
+ goto retry;
+ }
+
if ( !rc ) {
Debug( LDAP_DEBUG_TRACE,
"<=- bdb_delete: no access "
goto return_results;
}
}
+
#if 0
if ( ltid ) {
DBT obj;
}
/* get entry for read/modify/write */
- rc = bdb_dn2entry( be, ltid, ndn, &e, &matched, DB_RMW );
+ rc = bdb_dn2entry_w( be, ltid, ndn, &e, &matched, DB_RMW );
switch( rc ) {
case 0:
refs = is_entry_referral( matched )
? get_entry_referrals( be, conn, op, matched )
: NULL;
- bdb_entry_return( be, matched );
+ bdb_cache_return_entry_r(&bdb->bi_cache, matched );
matched = NULL;
} else {
}
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 );
}
/* delete from id2entry */
- rc = bdb_id2entry_delete( be, ltid, e->e_id );
+ rc = bdb_id2entry_delete( be, ltid, e );
if ( rc != 0 ) {
switch( rc ) {
case DB_LOCK_DEADLOCK:
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();
done:
/* free entry */
if( e != NULL ) {
- bdb_entry_return( be, e );
+ bdb_cache_return_entry_w(&bdb->bi_cache, e);
}
if( ltid != NULL ) {
- txn_abort( ltid );
+ TXN_ABORT( ltid );
op->o_private = NULL;
}