From 45f0ee18e3dacf9e8c746009eaef4e17b0a44bf8 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Fri, 25 May 2007 11:24:54 +0000 Subject: Added support for recovering prepared transactions. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@541619 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/DtxManager.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'cpp/src/qpid/broker/DtxManager.cpp') diff --git a/cpp/src/qpid/broker/DtxManager.cpp b/cpp/src/qpid/broker/DtxManager.cpp index 6c074bbd51..2af87a8751 100644 --- a/cpp/src/qpid/broker/DtxManager.cpp +++ b/cpp/src/qpid/broker/DtxManager.cpp @@ -29,11 +29,20 @@ DtxManager::~DtxManager() {} void DtxManager::start(std::string xid, DtxBuffer::shared_ptr ops) { + /* WorkMap::iterator i = work.find(xid); if (i == work.end()) { i = work.insert(xid, new DtxWorkRecord(xid, store)).first; } i->add(ops); + */ + + getOrCreateWork(xid)->add(ops); +} + +void DtxManager::recover(std::string xid, std::auto_ptr txn, DtxBuffer::shared_ptr ops) +{ + getOrCreateWork(xid)->recover(txn, ops); } void DtxManager::prepare(const std::string& xid) @@ -54,6 +63,17 @@ void DtxManager::rollback(const std::string& xid) DtxManager::WorkMap::iterator DtxManager::getWork(const std::string& xid) { WorkMap::iterator i = work.find(xid); - if (i == work.end()) throw ConnectionException(503, boost::format("Unrecognised xid %1%!") % xid); + if (i == work.end()) { + throw ConnectionException(503, boost::format("Unrecognised xid %1%!") % xid); + } + return i; +} + +DtxManager::WorkMap::iterator DtxManager::getOrCreateWork(std::string& xid) +{ + WorkMap::iterator i = work.find(xid); + if (i == work.end()) { + i = work.insert(xid, new DtxWorkRecord(xid, store)).first; + } return i; } -- cgit v1.2.1