]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/txn.c
fix idassert mode=self for anonymous operations (ITS#4798)
[openldap] / servers / slapd / txn.c
index 03cc7e337a675e15eaca82c42713d146c1c530d1..2c934266dc96807fbe887ec4b07738c743949945 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * 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
@@ -56,14 +56,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;
        }
 
        assert( op->o_conn->c_txn_backend == NULL );
-       ++op->o_conn->c_txn;
+       op->o_conn->c_txn = CONN_TXN_SPECIFY;
 
        bv = (struct berval *) ch_malloc( sizeof (struct berval) );
        bv->bv_len = 0;
@@ -151,7 +151,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 ) {
@@ -174,13 +173,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;
 
@@ -189,7 +199,13 @@ 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: