summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2011-04-12 15:04:00 +0000
committerGordon Sim <gsim@apache.org>2011-04-12 15:04:00 +0000
commit2b36efb651ffc14e1ad5081c8a7d6f8707342008 (patch)
tree101ea5e2ce52e6981835ef11e96b7e78358b44ef
parent5d62bad99e3be0177ca684fffaddbd86698b3fe1 (diff)
downloadqpid-python-2b36efb651ffc14e1ad5081c8a7d6f8707342008.tar.gz
QPID-3201: locking in NullMessageStore to protect set of prepared xids
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1091443 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/qpid/broker/NullMessageStore.cpp4
-rw-r--r--qpid/cpp/src/qpid/broker/NullMessageStore.h2
2 files changed, 6 insertions, 0 deletions
diff --git a/qpid/cpp/src/qpid/broker/NullMessageStore.cpp b/qpid/cpp/src/qpid/broker/NullMessageStore.cpp
index dc8615d58b..43f600eaf1 100644
--- a/qpid/cpp/src/qpid/broker/NullMessageStore.cpp
+++ b/qpid/cpp/src/qpid/broker/NullMessageStore.cpp
@@ -126,21 +126,25 @@ std::auto_ptr<TPCTransactionContext> NullMessageStore::begin(const std::string&
void NullMessageStore::prepare(TPCTransactionContext& ctxt)
{
+ qpid::sys::ScopedLock<qpid::sys::Mutex> l(lock);
prepared.insert(DummyCtxt::getXid(ctxt));
}
void NullMessageStore::commit(TransactionContext& ctxt)
{
+ qpid::sys::ScopedLock<qpid::sys::Mutex> l(lock);
prepared.erase(DummyCtxt::getXid(ctxt));
}
void NullMessageStore::abort(TransactionContext& ctxt)
{
+ qpid::sys::ScopedLock<qpid::sys::Mutex> l(lock);
prepared.erase(DummyCtxt::getXid(ctxt));
}
void NullMessageStore::collectPreparedXids(std::set<std::string>& out)
{
+ qpid::sys::ScopedLock<qpid::sys::Mutex> l(lock);
out.insert(prepared.begin(), prepared.end());
}
diff --git a/qpid/cpp/src/qpid/broker/NullMessageStore.h b/qpid/cpp/src/qpid/broker/NullMessageStore.h
index e148ec4d51..5f51d53886 100644
--- a/qpid/cpp/src/qpid/broker/NullMessageStore.h
+++ b/qpid/cpp/src/qpid/broker/NullMessageStore.h
@@ -25,6 +25,7 @@
#include "qpid/broker/BrokerImportExport.h"
#include "qpid/broker/MessageStore.h"
#include "qpid/broker/Queue.h"
+#include "qpid/sys/Mutex.h"
#include <boost/intrusive_ptr.hpp>
@@ -38,6 +39,7 @@ class NullMessageStore : public MessageStore
{
std::set<std::string> prepared;
uint64_t nextPersistenceId;
+ qpid::sys::Mutex lock;
public:
QPID_BROKER_EXTERN NullMessageStore();