]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/modify.c
Cleanup prev commit
[openldap] / servers / slapd / back-bdb / modify.c
index 19cd76f4abafbed78d9a54fac525d6ad26bc9e06..408ad24f6a4d1454d2366884790b75c6e0bddd79 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-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -205,13 +205,13 @@ int bdb_modify_internal(
        }
 
        /* check that the entry still obeys the schema */
-       rc = entry_schema_check( op, e, save_attrs, get_manageDIT(op),
+       rc = entry_schema_check( op, e, save_attrs, get_relax(op), 0,
                text, textbuf, textlen );
        if ( rc != LDAP_SUCCESS || op->o_noop ) {
                attrs_free( e->e_attrs );
                /* clear the indexing flags */
                for ( ap = save_attrs; ap != NULL; ap = ap->a_next ) {
-                       ap->a_flags = 0;
+                       ap->a_flags &= ~(SLAP_ATTR_IXADD|SLAP_ATTR_IXDEL);
                }
                e->e_attrs = save_attrs;
 
@@ -325,7 +325,7 @@ bdb_modify( Operation *op, SlapReply *rs )
                /* insert operation into transaction */
 
                rs->sr_text = "transaction specified";
-               rs->sr_err = LDAP_SUCCESS;
+               rs->sr_err = LDAP_X_TXN_SPECIFY_OKAY;
 
 txnReturn:
                /* release connection lock */
@@ -499,9 +499,13 @@ retry:     /* transaction retry */
                        &slap_pre_read_bv, preread_ctrl ) )
                {
                        Debug( LDAP_DEBUG_TRACE,
-                               "<=- " LDAP_XSTRING(bdb_modify) ": pre-read failed!\n",
-                               0, 0, 0 );
-                       goto return_results;
+                               "<=- " LDAP_XSTRING(bdb_modify) ": pre-read "
+                               "failed!\n", 0, 0, 0 );
+                       if ( op->o_preread & SLAP_CONTROL_CRITICAL ) {
+                               /* FIXME: is it correct to abort
+                                * operation if control fails? */
+                               goto return_results;
+                       }
                }
        }
 
@@ -570,7 +574,11 @@ retry:     /* transaction retry */
                        Debug( LDAP_DEBUG_TRACE,
                                "<=- " LDAP_XSTRING(bdb_modify)
                                ": post-read failed!\n", 0, 0, 0 );
-                       goto return_results;
+                       if ( op->o_postread & SLAP_CONTROL_CRITICAL ) {
+                               /* FIXME: is it correct to abort
+                                * operation if control fails? */
+                               goto return_results;
+                       }
                }
        }
 
@@ -592,7 +600,7 @@ retry:      /* transaction retry */
                        attrs_free( dummy.e_attrs );
 
                } else {
-                       rc = bdb_cache_modify( e, dummy.e_attrs, bdb->bi_dbenv, locker, &lock );
+                       rc = bdb_cache_modify( bdb, e, dummy.e_attrs, locker, &lock );
                        switch( rc ) {
                        case DB_LOCK_DEADLOCK:
                        case DB_LOCK_NOTGRANTED:
@@ -632,7 +640,7 @@ return_results:
        }
        send_ldap_result( op, rs );
 
-       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 );
        }
@@ -649,11 +657,11 @@ done:
                bdb_unlocked_cache_return_entry_w (&bdb->bi_cache, e);
        }
 
-       if( preread_ctrl != NULL ) {
+       if( preread_ctrl != NULL && (*preread_ctrl) != NULL ) {
                slap_sl_free( (*preread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
                slap_sl_free( *preread_ctrl, op->o_tmpmemctx );
        }
-       if( postread_ctrl != NULL ) {
+       if( postread_ctrl != NULL && (*postread_ctrl) != NULL ) {
                slap_sl_free( (*postread_ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
                slap_sl_free( *postread_ctrl, op->o_tmpmemctx );
        }