summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2012-01-13 16:20:11 +0000
committerTed Ross <tross@apache.org>2012-01-13 16:20:11 +0000
commit4f25c4f333c816cae35a43cc3ac2c785c1d9e0b6 (patch)
tree172b3abf6af980e93bcf9ae33fabe1e8aeb26569 /qpid/cpp/src
parentd24ab8f868d536d05c84200698ed42a01dc6934b (diff)
downloadqpid-python-4f25c4f333c816cae35a43cc3ac2c785c1d9e0b6.tar.gz
QPID-3755 - Concurrent queue bind on the same queue results in crash
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1231158 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpid/broker/QueueBindings.cpp10
-rw-r--r--qpid/cpp/src/qpid/broker/QueueBindings.h11
2 files changed, 18 insertions, 3 deletions
diff --git a/qpid/cpp/src/qpid/broker/QueueBindings.cpp b/qpid/cpp/src/qpid/broker/QueueBindings.cpp
index 60d315acfe..c6b3ddf9a9 100644
--- a/qpid/cpp/src/qpid/broker/QueueBindings.cpp
+++ b/qpid/cpp/src/qpid/broker/QueueBindings.cpp
@@ -30,16 +30,22 @@ using namespace qpid::broker;
void QueueBindings::add(const string& exchange, const string& key, const FieldTable& args)
{
+ sys::Mutex::ScopedLock l(lock);
bindings.push_back(QueueBinding(exchange, key, args));
}
void QueueBindings::unbind(ExchangeRegistry& exchanges, Queue::shared_ptr queue)
{
- for (Bindings::iterator i = bindings.begin(); i != bindings.end(); i++) {
+ Bindings local;
+ {
+ sys::Mutex::ScopedLock l(lock);
+ local = bindings;
+ }
+
+ for (Bindings::iterator i = local.begin(); i != local.end(); i++)
try {
exchanges.get(i->exchange)->unbind(queue, i->key, &(i->args));
} catch (const NotFoundException&) {}
- }
}
QueueBinding::QueueBinding(const string& _exchange, const string& _key, const FieldTable& _args)
diff --git a/qpid/cpp/src/qpid/broker/QueueBindings.h b/qpid/cpp/src/qpid/broker/QueueBindings.h
index 1b90ba5540..f9b07e7431 100644
--- a/qpid/cpp/src/qpid/broker/QueueBindings.h
+++ b/qpid/cpp/src/qpid/broker/QueueBindings.h
@@ -22,6 +22,7 @@
#define _QueueBindings_
#include "qpid/framing/FieldTable.h"
+#include "qpid/sys/Mutex.h"
#include <boost/ptr_container/ptr_list.hpp>
#include <boost/shared_ptr.hpp>
#include <algorithm>
@@ -44,12 +45,20 @@ class QueueBindings
public:
/** Apply f to each QueueBinding. */
- template <class F> void eachBinding(F f) const { std::for_each(bindings.begin(), bindings.end(), f); }
+ template <class F> void eachBinding(F f) const {
+ Bindings local;
+ {
+ sys::Mutex::ScopedLock l(lock);
+ local = bindings;
+ }
+ std::for_each(local.begin(), local.end(), f);
+ }
void add(const std::string& exchange, const std::string& key, const qpid::framing::FieldTable& args);
void unbind(ExchangeRegistry& exchanges, boost::shared_ptr<Queue> queue);
private:
+ mutable sys::Mutex lock;
typedef std::vector<QueueBinding> Bindings;
Bindings bindings;
};