]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/delete.c
Happy New Year
[openldap] / servers / slapd / back-bdb / delete.c
index 36910907c4d57476bb541c968834d3a56fcb9c11..eb27c8788fe31de7d9857c536ea0304f86c5c4e3 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2013 The OpenLDAP Foundation.
+ * Copyright 2000-2018 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -51,49 +51,12 @@ bdb_delete( Operation *op, SlapReply *rs )
        int     parent_is_glue = 0;
        int parent_is_leaf = 0;
 
-#ifdef LDAP_X_TXN
-       int settle = 0;
-#endif
-
        Debug( LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(bdb_delete) ": %s\n",
                op->o_req_dn.bv_val, 0, 0 );
 
 #ifdef LDAP_X_TXN
-       if( op->o_txnSpec ) {
-               /* acquire connection lock */
-               ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
-               if( op->o_conn->c_txn == CONN_TXN_INACTIVE ) {
-                       rs->sr_text = "invalid transaction identifier";
-                       rs->sr_err = LDAP_X_TXN_ID_INVALID;
-                       goto txnReturn;
-               } else if( op->o_conn->c_txn == CONN_TXN_SETTLE ) {
-                       settle=1;
-                       goto txnReturn;
-               }
-
-               if( op->o_conn->c_txn_backend == NULL ) {
-                       op->o_conn->c_txn_backend = op->o_bd;
-
-               } else if( op->o_conn->c_txn_backend != op->o_bd ) {
-                       rs->sr_text = "transaction cannot span multiple database contexts";
-                       rs->sr_err = LDAP_AFFECTS_MULTIPLE_DSAS;
-                       goto txnReturn;
-               }
-
-               /* insert operation into transaction */
-
-               rs->sr_text = "transaction specified";
-               rs->sr_err = LDAP_X_TXN_SPECIFY_OKAY;
-
-txnReturn:
-               /* release connection lock */
-               ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
-
-               if( !settle ) {
-                       send_ldap_result( op, rs );
-                       return rs->sr_err;
-               }
-       }
+       if( op->o_txnSpec && txn_preop( op, rs ))
+               return rs->sr_err;
 #endif
 
        ctrls[num_ctrls] = 0;
@@ -141,8 +104,12 @@ retry:     /* transaction retry */
        }
 
        /* begin transaction */
-       rs->sr_err = TXN_BEGIN( bdb->bi_dbenv, NULL, &ltid, 
-               bdb->bi_db_opflags );
+       {
+               int tflags = bdb->bi_db_opflags;
+               if ( get_lazyCommit( op ))
+                       tflags |= DB_TXN_NOSYNC;
+               rs->sr_err = TXN_BEGIN( bdb->bi_dbenv, NULL, &ltid, tflags );
+       }
        Debug( LDAP_DEBUG_TRACE, LDAP_XSTRING(bdb_delete) ": txn1 id: %x\n",
                ltid->id(ltid), 0, 0 );
        rs->sr_text = NULL;