X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Ftxn.c;h=84d7997b13634a1b240e3eaad1d166e368805697;hb=5ed0fc37494b835aeeb39bd55ee6d71cedad8143;hp=d1451c52d45d373903ea44a73ffa296513bfa881;hpb=fad69dbef82204861d359fb9192c851c102aed1d;p=openldap
diff --git a/servers/slapd/txn.c b/servers/slapd/txn.c
index d1451c52d4..84d7997b13 100644
--- a/servers/slapd/txn.c
+++ b/servers/slapd/txn.c
@@ -2,7 +2,7 @@
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software .
*
- * Copyright 1998-2006 The OpenLDAP Foundation.
+ * Copyright 1998-2007 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -18,7 +18,6 @@
#include
-#include
#include
#include
#include
@@ -56,13 +55,14 @@ int txn_start_extop(
/* acquire connection lock */
ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
- if( op->o_conn->c_txn ) {
+ if( op->o_conn->c_txn != CONN_TXN_INACTIVE ) {
rs->sr_text = "Too many transactions";
rc = LDAP_BUSY;
goto done;
}
- ++op->o_conn->c_txn;
+ assert( op->o_conn->c_txn_backend == NULL );
+ op->o_conn->c_txn = CONN_TXN_SPECIFY;
bv = (struct berval *) ch_malloc( sizeof (struct berval) );
bv->bv_len = 0;
@@ -98,6 +98,15 @@ int txn_spec_ctrl(
return LDAP_X_TXN_ID_INVALID;
}
+ if ( op->o_preread ) { /* temporary limitation */
+ rs->sr_text = "cannot perform pre-read in transaction";
+ return LDAP_UNWILLING_TO_PERFORM;
+ }
+ if ( op->o_postread ) { /* temporary limitation */
+ rs->sr_text = "cannot perform post-read in transaction";
+ return LDAP_UNWILLING_TO_PERFORM;
+ }
+
op->o_txnSpec = SLAP_CONTROL_CRITICAL;
return LDAP_SUCCESS;
}
@@ -141,7 +150,6 @@ int txn_end_extop(
}
tag = ber_peek_tag( ber, &len );
- assert( tag == LBER_BOOLEAN );
if( tag == LBER_BOOLEAN ) {
tag = ber_scanf( ber, "b", &commit );
if( tag == LBER_ERROR ) {
@@ -164,13 +172,24 @@ int txn_end_extop(
/* acquire connection lock */
ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
- if( op->o_conn->c_txn == 0 ) {
+ if( op->o_conn->c_txn != CONN_TXN_SPECIFY ) {
rs->sr_text = "invalid transaction identifier";
rc = LDAP_X_TXN_ID_INVALID;
goto done;
}
+ op->o_conn->c_txn = CONN_TXN_SETTLE;
if( commit ) {
+ if ( op->o_abandon ) {
+ }
+
+ if( LDAP_STAILQ_EMPTY(&op->o_conn->c_txn_ops) ) {
+ /* no updates to commit */
+ rs->sr_text = "no updates to commit";
+ rc = LDAP_OPERATIONS_ERROR;
+ goto settled;
+ }
+
rs->sr_text = "not yet implemented";
rc = LDAP_UNWILLING_TO_PERFORM;
@@ -179,7 +198,14 @@ int txn_end_extop(
rc = LDAP_SUCCESS;;
}
- op->o_conn->c_txn = 0;
+drain:
+ /* drain txn ops list */
+
+settled:
+ assert( LDAP_STAILQ_EMPTY(&op->o_conn->c_txn_ops) );
+ assert( op->o_conn->c_txn == CONN_TXN_SETTLE );
+ op->o_conn->c_txn = CONN_TXN_INACTIVE;
+ op->o_conn->c_txn_backend = NULL;
done:
/* release connection lock */