From b32c30ec005b9e6af28785f2c924c3cb01f3c452 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 11 Mar 2008 15:34:20 +0000 Subject: Fixed headers exchange to allow unbind using binding key and not args Converted alternate exchange python tests git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@635976 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/HeadersExchange.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/qpid/broker/HeadersExchange.cpp b/cpp/src/qpid/broker/HeadersExchange.cpp index 634fcd7b88..34fbbef305 100644 --- a/cpp/src/qpid/broker/HeadersExchange.cpp +++ b/cpp/src/qpid/broker/HeadersExchange.cpp @@ -72,7 +72,7 @@ std::string HeadersExchange::getMatch(const FieldTable* args) return what->get(); } -bool HeadersExchange::bind(Queue::shared_ptr queue, const string& /*routingKey*/, const FieldTable* args){ +bool HeadersExchange::bind(Queue::shared_ptr queue, const string& bindingKey, const FieldTable* args){ RWlock::ScopedWlock locker(lock); std::string what = getMatch(args); if (what != all && what != any) @@ -85,7 +85,7 @@ bool HeadersExchange::bind(Queue::shared_ptr queue, const string& /*routingKey*/ break; if (i == bindings.end()) { - Binding::shared_ptr binding (new Binding ("", queue, this)); + Binding::shared_ptr binding (new Binding (bindingKey, queue, this)); HeaderMap headerMap(*args, binding); bindings.push_back(headerMap); @@ -98,12 +98,18 @@ bool HeadersExchange::bind(Queue::shared_ptr queue, const string& /*routingKey*/ } } -bool HeadersExchange::unbind(Queue::shared_ptr queue, const string& /*routingKey*/, const FieldTable* args){ +bool HeadersExchange::unbind(Queue::shared_ptr queue, const string& bindingKey, const FieldTable* args){ RWlock::ScopedWlock locker(lock); Bindings::iterator i; - for (i = bindings.begin(); i != bindings.end(); i++) - if (i->first == *args && i->second->queue == queue) - break; + for (i = bindings.begin(); i != bindings.end(); i++) { + if (args) { + if (i->first == *args && i->second->queue == queue) + break; + } else { + if (i->second->key == bindingKey && i->second->queue == queue) + break; + } + } if (i != bindings.end()) { bindings.erase(i); -- cgit v1.2.1