if ( !SLAP_SINGLE_SHADOW(op->o_bd) || repl_user ) {
int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
- op->o_bd = op_be;
-
if ( !update ) {
rs->sr_err = slap_mods_no_user_mod_check( op, op->ora_modlist,
&rs->sr_text, textbuf, textlen );
}
}
+ if ( op->o_txnSpec ) {
+ rc = txn_preop( op, rs );
+ goto done;
+ }
+
+ op->o_bd = op_be;
rc = op->o_bd->be_add( op, rs );
if ( rc == LDAP_SUCCESS ) {
OpExtra *oex;
Debug(LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(mdb_add) ": %s\n",
op->ora_e->e_name.bv_val );
- if( op->o_txnSpec && txn_preop( op, rs ))
- return rs->sr_err;
-
ctrls[num_ctrls] = 0;
/* check entry's schema */
Debug( LDAP_DEBUG_ARGS, "==> " LDAP_XSTRING(mdb_delete) ": %s\n",
op->o_req_dn.bv_val );
- if( op->o_txnSpec && txn_preop( op, rs ))
- return rs->sr_err;
-
ctrls[num_ctrls] = 0;
/* begin transaction */
SLAP_BFLAG_INCREMENT |
SLAP_BFLAG_SUBENTRIES |
SLAP_BFLAG_ALIASES |
- SLAP_BFLAG_REFERRALS;
+ SLAP_BFLAG_REFERRALS |
+ SLAP_BFLAG_TXNS;
bi->bi_controls = controls;
Debug( LDAP_DEBUG_ARGS, LDAP_XSTRING(mdb_modify) ": %s\n",
op->o_req_dn.bv_val );
- if( op->o_txnSpec && txn_preop( op, rs ))
- return rs->sr_err;
-
ctrls[num_ctrls] = NULL;
/* begin transaction */
op->o_req_dn.bv_val,op->oq_modrdn.rs_newrdn.bv_val,
op->oq_modrdn.rs_newSup ? op->oq_modrdn.rs_newSup->bv_val : "NULL" );
- if( op->o_txnSpec && txn_preop( op, rs ))
- return rs->sr_err;
-
ctrls[num_ctrls] = NULL;
/* begin transaction */
struct berval org_ndn = BER_BVNULL;
int org_managedsait;
+ if ( op->o_txnSpec ) {
+ txn_preop( op, rs );
+ goto cleanup;
+ }
+
op->o_bd = op_be;
op->o_bd->be_delete( op, rs );
op->o_bd = frontendDB;
rs->sr_err = frontendDB->be_extended( op, rs );
- if ( rs->sr_err == SLAPD_ASYNCOP ){
+ if ( rs->sr_err == SLAPD_ASYNCOP ||
+ rs->sr_err == LDAP_TXN_SPECIFY_OKAY ) {
/* skip cleanup */
return rs->sr_err;
}
if ( !SLAP_SINGLE_SHADOW(op->o_bd) || repl_user ) {
int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
- op->o_bd = op_be;
-
if ( !update ) {
rs->sr_err = slap_mods_no_user_mod_check( op, op->orm_modlist,
&rs->sr_text, textbuf, textlen );
goto cleanup;
}
}
+ if ( op->o_txnSpec ) {
+ txn_preop( op, rs );
+ goto cleanup;
+ }
+ op->o_bd = op_be;
op->o_bd->be_modify( op, rs );
} else { /* send a referral */
int repl_user = be_isupdate( op );
if ( !SLAP_SINGLE_SHADOW(op->o_bd) || repl_user )
{
+ if ( op->o_txnSpec ) {
+ txn_preop( op, rs );
+ goto cleanup;
+ }
+
op->o_bd = op_be;
op->o_bd->be_modrdn( op, rs );
goto error_return;
}
+ if ( op->o_txnSpec ) {
+ rc = txn_preop( op, rs );
+ goto error_return;
+ }
+
op->o_bd = op_be;
/* Give the backend a chance to handle this itself */
#define SLAP_BFLAG_SUBENTRIES 0x4000U
#define SLAP_BFLAG_DYNAMIC 0x8000U
#define SLAP_BFLAG_STANDALONE 0x10000U /* started up regardless of whether any databases use it */
+#define SLAP_BFLAG_TXNS 0x20000U /* supports LDAP transactions */
/* overlay specific */
#define SLAPO_BFLAG_SINGLE 0x01000000U
#define SLAP_DYNAMIC(be) ((SLAP_BFLAGS(be) & SLAP_BFLAG_DYNAMIC) || (SLAP_DBFLAGS(be) & SLAP_DBFLAG_DYNAMIC))
#define SLAP_NOLASTMODCMD(be) (SLAP_BFLAGS(be) & SLAP_BFLAG_NOLASTMODCMD)
#define SLAP_LASTMODCMD(be) (!SLAP_NOLASTMODCMD(be))
+#define SLAP_TXNS(be) (SLAP_BFLAGS(be) & SLAP_BFLAG_TXNS)
/* overlay specific */
#define SLAPO_SINGLE(be) (SLAP_BFLAGS(be) & SLAPO_BFLAG_SINGLE)
int txn_preop( Operation *op, SlapReply *rs )
{
- int settle = 0;
-
/* 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_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 ) {
goto txnReturn;
}
+ if ( !SLAP_TXNS( op->o_bd )) {
+ rs->sr_text = "backend doesn't support transactions";
+ rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+ goto txnReturn;
+ }
+
/* insert operation into transaction */
LDAP_STAILQ_REMOVE( &op->o_conn->c_ops, op, Operation, o_next );
LDAP_STAILQ_INSERT_TAIL( &op->o_conn->c_txn_ops, op, o_next );
/* release connection lock */
ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
- if( !settle ) {
+ if ( op->o_tag != LDAP_REQ_EXTENDED )
send_ldap_result( op, rs );
- if ( !rs->sr_err )
- rs->sr_err = LDAP_TXN_SPECIFY_OKAY;
- return rs->sr_err;
- }
- return LDAP_SUCCESS; /* proceed with operation */
+ if ( !rs->sr_err )
+ rs->sr_err = LDAP_TXN_SPECIFY_OKAY;
+ return rs->sr_err;
}