summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2008-06-06 20:14:09 +0000
committerTed Ross <tross@apache.org>2008-06-06 20:14:09 +0000
commit76c922baf182bb367feed2ec014e7cab9db7f79d (patch)
tree71f4a9c9603f8583f27ddf290f20f0aae4ed8fc6 /cpp/src
parent955bfffaa6f6567add6af4a9fd3a7a3d930ad790 (diff)
downloadqpid-python-76c922baf182bb367feed2ec014e7cab9db7f79d.tar.gz
Added mutexes back in to protect management counts from corruption
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@664112 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/broker/Queue.cpp11
-rw-r--r--cpp/src/qpid/management/ManagementObject.h4
2 files changed, 11 insertions, 4 deletions
diff --git a/cpp/src/qpid/broker/Queue.cpp b/cpp/src/qpid/broker/Queue.cpp
index 08af97eb48..becca8dfcf 100644
--- a/cpp/src/qpid/broker/Queue.cpp
+++ b/cpp/src/qpid/broker/Queue.cpp
@@ -127,15 +127,17 @@ void Queue::deliver(boost::intrusive_ptr<Message>& msg){
} else {
// if no store then mark as enqueued
if (!enqueue(0, msg)){
- push(msg);
- msg->enqueueComplete();
if (mgmtObject.get() != 0) {
+ Mutex::ScopedLock mutex(mgmtObject->getLock());
mgmtObject->inc_msgTotalEnqueues ();
mgmtObject->inc_byteTotalEnqueues (msg->contentSize ());
mgmtObject->inc_msgDepth ();
}
+ push(msg);
+ msg->enqueueComplete();
}else {
if (mgmtObject.get() != 0) {
+ Mutex::ScopedLock mutex(mgmtObject->getLock());
mgmtObject->inc_msgTotalEnqueues ();
mgmtObject->inc_byteTotalEnqueues (msg->contentSize ());
mgmtObject->inc_msgDepth ();
@@ -153,6 +155,7 @@ void Queue::recover(boost::intrusive_ptr<Message>& msg){
push(msg);
msg->enqueueComplete(); // mark the message as enqueued
if (mgmtObject.get() != 0) {
+ Mutex::ScopedLock mutex(mgmtObject->getLock());
mgmtObject->inc_msgTotalEnqueues ();
mgmtObject->inc_byteTotalEnqueues (msg->contentSize ());
mgmtObject->inc_msgPersistEnqueues ();
@@ -170,6 +173,7 @@ void Queue::recover(boost::intrusive_ptr<Message>& msg){
void Queue::process(boost::intrusive_ptr<Message>& msg){
push(msg);
if (mgmtObject.get() != 0) {
+ Mutex::ScopedLock mutex(mgmtObject->getLock());
mgmtObject->inc_msgTotalEnqueues ();
mgmtObject->inc_byteTotalEnqueues (msg->contentSize ());
mgmtObject->inc_msgTxnEnqueues ();
@@ -359,6 +363,7 @@ void Queue::consume(Consumer& c, bool requestExclusive){
consumerCount++;
if (mgmtObject.get() != 0){
+ Mutex::ScopedLock mutex(mgmtObject->getLock());
mgmtObject->inc_consumerCount ();
}
}
@@ -369,6 +374,7 @@ void Queue::cancel(Consumer& c){
consumerCount--;
if(exclusive) exclusive = 0;
if (mgmtObject.get() != 0){
+ Mutex::ScopedLock mutex(mgmtObject->getLock());
mgmtObject->dec_consumerCount ();
}
}
@@ -407,6 +413,7 @@ void Queue::pop(){
if (policy.get()) policy->dequeued(msg.payload->contentSize());
if (mgmtObject.get() != 0){
+ Mutex::ScopedLock mutex(mgmtObject->getLock());
mgmtObject->inc_msgTotalDequeues ();
mgmtObject->inc_byteTotalDequeues (msg.payload->contentSize());
mgmtObject->dec_msgDepth ();
diff --git a/cpp/src/qpid/management/ManagementObject.h b/cpp/src/qpid/management/ManagementObject.h
index 38f72710de..cf2da13b09 100644
--- a/cpp/src/qpid/management/ManagementObject.h
+++ b/cpp/src/qpid/management/ManagementObject.h
@@ -112,8 +112,8 @@ class ManagementObject
destroyTime = uint64_t (qpid::sys::Duration (qpid::sys::now ()));
deleted = true;
}
- bool isDeleted (void) { return deleted; }
- sys::Mutex& getLock() { return accessLock; }
+ inline bool isDeleted (void) { return deleted; }
+ inline sys::Mutex& getLock() { return accessLock; }
};
typedef std::map<uint64_t,ManagementObject::shared_ptr> ManagementObjectMap;