summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/broker/SessionAdapter.cpp
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-03-17 12:17:55 +0000
committerGordon Sim <gsim@apache.org>2008-03-17 12:17:55 +0000
commit6574ab48665039ae9b8b1d2c5dd26ea94a3d23fa (patch)
tree01091458f1db56d09953cd129305586057df1384 /cpp/src/qpid/broker/SessionAdapter.cpp
parent1c1efeddef24ef18d75af65e4249b541b1382ea8 (diff)
downloadqpid-python-6574ab48665039ae9b8b1d2c5dd26ea94a3d23fa.tar.gz
Scope exclusive queues to sessions.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@637854 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/SessionAdapter.cpp')
-rw-r--r--cpp/src/qpid/broker/SessionAdapter.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/cpp/src/qpid/broker/SessionAdapter.cpp b/cpp/src/qpid/broker/SessionAdapter.cpp
index 64bb7cdae3..5d33e68fab 100644
--- a/cpp/src/qpid/broker/SessionAdapter.cpp
+++ b/cpp/src/qpid/broker/SessionAdapter.cpp
@@ -19,6 +19,7 @@
#include "Connection.h"
#include "DeliveryToken.h"
#include "MessageDelivery.h"
+#include "Queue.h"
#include "qpid/Exception.h"
#include "qpid/framing/reply_exceptions.h"
#include <boost/format.hpp>
@@ -180,6 +181,22 @@ Exchange010BoundResult SessionAdapter::ExchangeHandlerImpl::bound(const std::str
}
}
+SessionAdapter::QueueHandlerImpl::QueueHandlerImpl(SemanticState& session) : HandlerHelper(session), broker(getBroker())
+{}
+
+
+SessionAdapter::QueueHandlerImpl::~QueueHandlerImpl()
+{
+ while (!exclusiveQueues.empty()) {
+ Queue::shared_ptr q(exclusiveQueues.front());
+ q->releaseExclusiveOwnership();
+ if (q->canAutoDelete()) {
+ Queue::tryAutoDelete(broker, q);
+ }
+ exclusiveQueues.erase(exclusiveQueues.begin());
+ }
+}
+
Queue010QueryResult SessionAdapter::QueueHandlerImpl::query(const string& name)
{
Queue::shared_ptr queue = getQueue(name);
@@ -212,7 +229,7 @@ void SessionAdapter::QueueHandlerImpl::declare(const string& name, const string&
getBroker().getQueues().declare(
name, durable,
autoDelete,
- exclusive ? &getConnection() : 0);
+ exclusive ? this : 0);
queue = queue_created.first;
assert(queue);
if (queue_created.second) { // This is a new queue
@@ -230,15 +247,15 @@ void SessionAdapter::QueueHandlerImpl::declare(const string& name, const string&
//handle automatic cleanup:
if (exclusive) {
- getConnection().exclusiveQueues.push_back(queue);
+ exclusiveQueues.push_back(queue);
}
} else {
- if (exclusive && queue->setExclusiveOwner(&getConnection())) {
- getConnection().exclusiveQueues.push_back(queue);
+ if (exclusive && queue->setExclusiveOwner(this)) {
+ exclusiveQueues.push_back(queue);
}
}
}
- if (exclusive && !queue->isExclusiveOwner(&getConnection()))
+ if (exclusive && !queue->isExclusiveOwner(this))
throw ResourceLockedException(
QPID_MSG("Cannot grant exclusive access to queue "
<< queue->getName()));