summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/asyncStore
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/qpid/asyncStore')
-rw-r--r--cpp/src/qpid/asyncStore/AsyncStoreImpl.cpp8
-rw-r--r--cpp/src/qpid/asyncStore/AsyncStoreImpl.h4
-rw-r--r--cpp/src/qpid/asyncStore/TxnHandleImpl.cpp71
-rw-r--r--cpp/src/qpid/asyncStore/TxnHandleImpl.h14
4 files changed, 18 insertions, 79 deletions
diff --git a/cpp/src/qpid/asyncStore/AsyncStoreImpl.cpp b/cpp/src/qpid/asyncStore/AsyncStoreImpl.cpp
index 4aeab4c7bf..aa66e7adb8 100644
--- a/cpp/src/qpid/asyncStore/AsyncStoreImpl.cpp
+++ b/cpp/src/qpid/asyncStore/AsyncStoreImpl.cpp
@@ -81,16 +81,18 @@ AsyncStoreImpl::createTxnHandle(qpid::broker::TxnBuffer* tb)
}
qpid::broker::TxnHandle
-AsyncStoreImpl::createTxnHandle(const std::string& xid)
+AsyncStoreImpl::createTxnHandle(const std::string& xid,
+ const bool tpcFlag)
{
- return qpid::broker::TxnHandle(new TxnHandleImpl(xid));
+ return qpid::broker::TxnHandle(new TxnHandleImpl(xid, tpcFlag));
}
qpid::broker::TxnHandle
AsyncStoreImpl::createTxnHandle(const std::string& xid,
+ const bool tpcFlag,
qpid::broker::TxnBuffer* tb)
{
- return qpid::broker::TxnHandle(new TxnHandleImpl(xid, tb));
+ return qpid::broker::TxnHandle(new TxnHandleImpl(xid, tpcFlag, tb));
}
void
diff --git a/cpp/src/qpid/asyncStore/AsyncStoreImpl.h b/cpp/src/qpid/asyncStore/AsyncStoreImpl.h
index 3e29039aea..eb3f090ad7 100644
--- a/cpp/src/qpid/asyncStore/AsyncStoreImpl.h
+++ b/cpp/src/qpid/asyncStore/AsyncStoreImpl.h
@@ -60,8 +60,10 @@ public:
qpid::broker::TxnHandle createTxnHandle();
qpid::broker::TxnHandle createTxnHandle(qpid::broker::TxnBuffer* tb);
- qpid::broker::TxnHandle createTxnHandle(const std::string& xid);
qpid::broker::TxnHandle createTxnHandle(const std::string& xid,
+ const bool tpcFlag);
+ qpid::broker::TxnHandle createTxnHandle(const std::string& xid,
+ const bool tpcFlag,
qpid::broker::TxnBuffer* tb);
void submitPrepare(qpid::broker::TxnHandle& txnHandle,
diff --git a/cpp/src/qpid/asyncStore/TxnHandleImpl.cpp b/cpp/src/qpid/asyncStore/TxnHandleImpl.cpp
index 2b343e9517..dd644b29bd 100644
--- a/cpp/src/qpid/asyncStore/TxnHandleImpl.cpp
+++ b/cpp/src/qpid/asyncStore/TxnHandleImpl.cpp
@@ -23,53 +23,32 @@
#include "TxnHandleImpl.h"
-#include "qpid/Exception.h"
-#include "qpid/broker/TxnBuffer.h"
-#include "qpid/log/Statement.h"
-
-#include <uuid/uuid.h>
-
namespace qpid {
namespace asyncStore {
TxnHandleImpl::TxnHandleImpl() :
m_tpcFlag(false),
- m_asyncOpCnt(0UL),
m_txnBuffer(0)
-{
- createLocalXid();
-}
+{}
TxnHandleImpl::TxnHandleImpl(qpid::broker::TxnBuffer* tb) :
m_tpcFlag(false),
- m_asyncOpCnt(0UL),
m_txnBuffer(tb)
-{
- createLocalXid();
-}
+{}
-TxnHandleImpl::TxnHandleImpl(const std::string& xid) :
+TxnHandleImpl::TxnHandleImpl(const std::string& xid, const bool tpcFlag) :
m_xid(xid),
- m_tpcFlag(!xid.empty()),
- m_asyncOpCnt(0UL),
+ m_tpcFlag(tpcFlag),
m_txnBuffer(0)
-{
- if (m_xid.empty()) {
- createLocalXid();
- }
-}
+{}
TxnHandleImpl::TxnHandleImpl(const std::string& xid,
+ const bool tpcFlag,
qpid::broker::TxnBuffer* tb) :
m_xid(xid),
- m_tpcFlag(!xid.empty()),
- m_asyncOpCnt(0UL),
+ m_tpcFlag(tpcFlag),
m_txnBuffer(tb)
-{
- if (m_xid.empty()) {
- createLocalXid();
- }
-}
+{}
TxnHandleImpl::~TxnHandleImpl()
{}
@@ -86,38 +65,4 @@ TxnHandleImpl::is2pc() const
return m_tpcFlag;
}
-void
-TxnHandleImpl::incrOpCnt()
-{
- qpid::sys::ScopedLock<qpid::sys::Mutex> l(m_asyncOpCntMutex);
- ++m_asyncOpCnt;
-}
-
-void
-TxnHandleImpl::decrOpCnt()
-{
- qpid::sys::ScopedLock<qpid::sys::Mutex> l(m_asyncOpCntMutex);
- if (m_asyncOpCnt == 0UL) {
- throw qpid::Exception("Transaction async operation count underflow");
- }
- if (--m_asyncOpCnt == 0UL && m_txnBuffer) {
- m_txnBuffer->asyncLocalCommit();
- }
-}
-
-// private
-void
-TxnHandleImpl::createLocalXid()
-{
- uuid_t uuid;
-
- // TODO: This call might not be thread safe - Valgrind's helgrind tool emits warnings for this:
- ::uuid_generate_random(uuid);
-
- char uuidStr[37]; // 36-char uuid + trailing '\0'
- ::uuid_unparse(uuid, uuidStr);
- m_xid.assign(uuidStr);
- QPID_LOG(debug, "Local XID created: \"" << m_xid << "\"");
-}
-
}} // namespace qpid::asyncStore
diff --git a/cpp/src/qpid/asyncStore/TxnHandleImpl.h b/cpp/src/qpid/asyncStore/TxnHandleImpl.h
index 9452044d66..e1f8afff3e 100644
--- a/cpp/src/qpid/asyncStore/TxnHandleImpl.h
+++ b/cpp/src/qpid/asyncStore/TxnHandleImpl.h
@@ -43,26 +43,16 @@ class TxnHandleImpl : public virtual qpid::RefCounted
public:
TxnHandleImpl();
TxnHandleImpl(qpid::broker::TxnBuffer* tb);
- TxnHandleImpl(const std::string& xid);
- TxnHandleImpl(const std::string& xid, qpid::broker::TxnBuffer* tb);
+ TxnHandleImpl(const std::string& xid, const bool tpcFlag);
+ TxnHandleImpl(const std::string& xid, const bool tpcFlag, qpid::broker::TxnBuffer* tb);
virtual ~TxnHandleImpl();
const std::string& getXid() const;
bool is2pc() const;
- void submitPrepare();
- void submitCommit();
- void submitAbort();
-
- void incrOpCnt();
- void decrOpCnt();
private:
std::string m_xid;
bool m_tpcFlag;
- uint32_t m_asyncOpCnt;
- qpid::sys::Mutex m_asyncOpCntMutex;
qpid::broker::TxnBuffer* const m_txnBuffer;
-
- void createLocalXid();
};
}} // namespace qpid::asyncStore