This small patch fixes the rollback of the transaction ID as well as
queries for it.

OK for branch?
commit bd83b4594c1f6eee09e0fa7b369557f986291f9b
Author: Torvald Riegel <trie...@redhat.com>
Date:   Fri Jul 29 15:19:04 2011 +0200

    Fix rollback and queries of transaction ID.
    
        * beginend.cc (GTM::gtm_transaction::rollback): Roll back tx id as well.
        * query.cc (_ITM_getTransactionId): There is no active transaction if
        the current nesting level is zero.

diff --git a/libitm/beginend.cc b/libitm/beginend.cc
index 9f84404..d336d60 100644
--- a/libitm/beginend.cc
+++ b/libitm/beginend.cc
@@ -298,6 +298,7 @@ GTM::gtm_transaction::rollback (gtm_transaction_cp *cp)
       if (parent_txns.size() > 0)
         {
           jb = parent_txns[0].jb;
+          id = parent_txns[0].id;
           prop = parent_txns[0].prop;
         }
       // Reset the transaction. Do not reset this->state, which is handled by
diff --git a/libitm/query.cc b/libitm/query.cc
index 4905fc6..9a95211 100644
--- a/libitm/query.cc
+++ b/libitm/query.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc.
    Contributed by Richard Henderson <r...@redhat.com>.
 
    This file is part of the GNU Transactional Memory Library (libitm).
@@ -59,7 +59,7 @@ _ITM_transactionId_t ITM_REGPARM
 _ITM_getTransactionId (void)
 {
   struct gtm_transaction *tx = gtm_tx();
-  return tx ? tx->id : _ITM_noTransactionId;
+  return (tx && (tx->nesting > 0)) ? tx->id : _ITM_noTransactionId;
 }
 
 

Reply via email to