]> git.sur5r.net Git - openldap/commitdiff
Consolidate LDAP_TXN precheck
authorHoward Chu <hyc@openldap.org>
Mon, 15 Sep 2014 18:18:30 +0000 (19:18 +0100)
committerHoward Chu <hyc@openldap.org>
Mon, 15 Sep 2014 23:09:10 +0000 (00:09 +0100)
This commit was accidentally omitted from previous push

servers/slapd/back-bdb/add.c
servers/slapd/back-bdb/delete.c
servers/slapd/back-bdb/modify.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-mdb/add.c
servers/slapd/back-mdb/delete.c
servers/slapd/back-mdb/modify.c
servers/slapd/back-mdb/modrdn.c
servers/slapd/proto-slap.h

index 54fce684982e242f13a093bfcfa2c34cfb4a7e1c..03f415b494ca36acb2d9fe74688d8b0e4c5701c9 100644 (file)
@@ -45,49 +45,12 @@ bdb_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(bdb_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;
index d361de479a88ad6546936d904f64e486512f6f86..a88e03c406f9f4bc82a9b1e182a85387ebd47387 100644 (file)
@@ -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;
index 3a81d9021764f1eb18b96dabf60f5e8b3f73d9ba..540280ab5b054e22d63e282c47a9081b50b65bda 100644 (file)
@@ -466,49 +466,12 @@ bdb_modify( Operation *op, SlapReply *rs )
 
        int rc;
 
-#ifdef LDAP_X_TXN
-       int settle = 0;
-#endif
-
        Debug( LDAP_DEBUG_ARGS, LDAP_XSTRING(bdb_modify) ": %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] = NULL;
index 2103591d217ac79a47b3083725711005b5d62aa7..42f5669483101c1c7045e1c42517729852cdd25f 100644 (file)
@@ -60,50 +60,13 @@ bdb_modrdn( 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_TRACE, "==>" LDAP_XSTRING(bdb_modrdn) "(%s,%s,%s)\n",
                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" );
 
 #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] = NULL;
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;
index 9002fba0564af04029f3a8496d07e0a32308fec9..77717aeb6cb64970550a15f91c92e2724ae68501 100644 (file)
@@ -43,49 +43,12 @@ mdb_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(mdb_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;
index c08e95cc695e3828c7a734ac194eff8b76bf1432..9a261882b92e5ac7e1c07ab5d741c92f6ad878d9 100644 (file)
@@ -459,49 +459,12 @@ mdb_modify( 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_modify) ": %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] = NULL;
index 3bf46ea69ac48f68e0d4f6bd41ee00fc7b812ced..ba8c01920980030071652d7d7af20ed8afede015 100644 (file)
@@ -55,50 +55,13 @@ mdb_modrdn( 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_TRACE, "==>" LDAP_XSTRING(mdb_modrdn) "(%s,%s,%s)\n",
                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" );
 
 #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] = NULL;
index c112e2fbaab940a733bbfbd4b9341433ef743840..dca7de0736ffd85f491dba85117df3114f5451b3 100644 (file)
@@ -1096,6 +1096,7 @@ LDAP_SLAPD_F (struct berval *) get_supported_extop LDAP_P((int index));
 LDAP_SLAPD_F ( SLAP_CTRL_PARSE_FN ) txn_spec_ctrl;
 LDAP_SLAPD_F ( SLAP_EXTOP_MAIN_FN ) txn_start_extop;
 LDAP_SLAPD_F ( SLAP_EXTOP_MAIN_FN ) txn_end_extop;
+LDAP_SLAPD_F ( int ) txn_preop LDAP_P(( Operation *op, SlapReply *rs ));
 #endif
 
 /*