Commit c6e521fa authored by Howard Chu's avatar Howard Chu Committed by Quanah Gibson-Mount
Browse files

ITS#8950 move txn setup to frontend

Backends should just execute when invoked, frontend should
exclusively take care of queueing for txn setup.
parent f9cb918d
......@@ -302,8 +302,6 @@ fe_op_add( Operation *op, SlapReply *rs )
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 );
......@@ -334,6 +332,12 @@ fe_op_add( Operation *op, SlapReply *rs )
}
}
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;
......
......@@ -48,9 +48,6 @@ mdb_add(Operation *op, SlapReply *rs )
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 */
......
......@@ -46,9 +46,6 @@ mdb_delete( Operation *op, SlapReply *rs )
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 */
......
......@@ -408,7 +408,8 @@ mdb_back_initialize(
SLAP_BFLAG_INCREMENT |
SLAP_BFLAG_SUBENTRIES |
SLAP_BFLAG_ALIASES |
SLAP_BFLAG_REFERRALS;
SLAP_BFLAG_REFERRALS |
SLAP_BFLAG_TXNS;
bi->bi_controls = controls;
......
......@@ -589,9 +589,6 @@ mdb_modify( Operation *op, SlapReply *rs )
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 */
......
......@@ -59,9 +59,6 @@ mdb_modrdn( Operation *op, SlapReply *rs )
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 */
......
......@@ -172,6 +172,11 @@ fe_op_delete( Operation *op, SlapReply *rs )
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 );
......
......@@ -174,7 +174,8 @@ do_extended(
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;
}
......
......@@ -289,8 +289,6 @@ fe_op_modify( Operation *op, SlapReply *rs )
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 );
......@@ -299,6 +297,11 @@ fe_op_modify( Operation *op, SlapReply *rs )
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 */
......
......@@ -313,6 +313,11 @@ fe_op_modrdn( Operation *op, SlapReply *rs )
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 );
......
......@@ -203,6 +203,11 @@ int passwd_extop(
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 */
......
......@@ -2338,6 +2338,7 @@ struct BackendInfo {
#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
......@@ -2357,6 +2358,7 @@ struct BackendInfo {
#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)
......
......@@ -324,17 +324,12 @@ done:
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 ) {
......@@ -346,6 +341,12 @@ int txn_preop( Operation *op, SlapReply *rs )
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 );
......@@ -354,11 +355,9 @@ txnReturn:
/* 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;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment