]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#8950 move txn setup to frontend
authorHoward Chu <hyc@openldap.org>
Mon, 22 Mar 2021 15:18:30 +0000 (15:18 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Tue, 23 Mar 2021 14:58:09 +0000 (14:58 +0000)
Backends should just execute when invoked, frontend should
exclusively take care of queueing for txn setup.

13 files changed:
servers/slapd/add.c
servers/slapd/back-mdb/add.c
servers/slapd/back-mdb/delete.c
servers/slapd/back-mdb/init.c
servers/slapd/back-mdb/modify.c
servers/slapd/back-mdb/modrdn.c
servers/slapd/delete.c
servers/slapd/extended.c
servers/slapd/modify.c
servers/slapd/modrdn.c
servers/slapd/passwd.c
servers/slapd/slap.h
servers/slapd/txn.c

index 5b99570a6bcbba0fcb803616ac60b3c08cb9e80d..8e5008f2d6561e178b0975bc4e36e02563510ca7 100644 (file)
@@ -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;
index 148d2d68b76e7507712548808158374e68f0540b..b2233756003348f6892ade6ef8698887f0e81eca 100644 (file)
@@ -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 */
index 9ca35011e7873747e2873ac05cfdf782032fda2d..7dab5ee8f1f512318966f514facdf53126e24dbd 100644 (file)
@@ -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 */
index 867559a9db587d08a21ea5b1393c6f26ad68d6cf..9d9e7ae775d9fccf4d215055f1b74025c43c1791 100644 (file)
@@ -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;
 
index 84e4585e3b77c30e3fde9a1cd989b50bdad82bd8..d1a2a7324fe3f742ea9a51a83b1b58b80854e2fb 100644 (file)
@@ -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 */
index f51631773c86d2d127b4ffb94488f4d830eb0aea..c3b0a6cd3c9d33c744cd2391dfd19cfd9e040833 100644 (file)
@@ -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 */
index 7759c60793ea510544f7ce8dae174e838cc0ad89..b6fd093d8e74e935b7bba5b7dabc3d9a82eb302f 100644 (file)
@@ -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 );
 
index 509ce5cfbe7ff01baee40ae3ea7cf5095e494a17..6b47d3a355547f4bf8bb272185c0099f7612f3bc 100644 (file)
@@ -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;
        }
index b00090328e61faf8b6229d27be745c0607d1acd4..faa10bac6da0ac398fa3e366edc1b497796bc4bc 100644 (file)
@@ -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 */
index a48cc4add754473f0c7586e13354c98aed86487d..260eafcd9975e8fc4fa2ce486b8ad65fe560e9d2 100644 (file)
@@ -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 );
 
index 9de1bc0c416eb79e6694201224ff9d8d9a619fe5..9a450fa0bd6a5da33438815c023406fdded1a149 100644 (file)
@@ -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 */
index a5fe408dc6d2faa252132fdddb3794d893f1ad6a..0f14cdc265db7b800bd15af9909aa1881b57dc55 100644 (file)
@@ -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)
index 7e5614433574ee2b0c593459566241c5d7af9a22..b2e8d1532103ddd9a1ff5f6dd2acc0ce4aeea0dc 100644 (file)
@@ -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;
 }