]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-mdb/add.c
Consolidate LDAP_TXN precheck
[openldap] / servers / slapd / back-mdb / add.c
index b92e922ec78c89dfd222e124c96d5438c2dcc863..36b76453d9ee8f79f569ec09b46f2457ed3214c0 100644 (file)
@@ -44,49 +44,12 @@ mdb_add(Operation *op, SlapReply *rs )
        LDAPControl *ctrls[SLAP_MAX_RESPONSE_CONTROLS];
        int num_ctrls = 0;
 
-#ifdef LDAP_X_TXN
-       int settle = 0;
-#endif
-
        Debug(LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(mdb_add) ": %s\n",
                op->ora_e->e_name.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;