You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gs...@apache.org on 2014/04/28 23:24:32 UTC

svn commit: r1590805 - in /qpid/trunk/qpid/cpp/src/qpid/broker/amqp: NodePolicy.cpp Topic.cpp Topic.h

Author: gsim
Date: Mon Apr 28 21:24:31 2014
New Revision: 1590805

URL: http://svn.apache.org/r1590805
Log:
QPID-5729: handle concurrent triggering of topic policy

Modified:
    qpid/trunk/qpid/cpp/src/qpid/broker/amqp/NodePolicy.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Topic.cpp
    qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Topic.h

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/amqp/NodePolicy.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/amqp/NodePolicy.cpp?rev=1590805&r1=1590804&r2=1590805&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/amqp/NodePolicy.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/amqp/NodePolicy.cpp Mon Apr 28 21:24:31 2014
@@ -195,7 +195,7 @@ std::pair<boost::shared_ptr<Queue>, boos
     qpid::amqp_0_10::translate(exchangeSettings, args);
     boost::shared_ptr<Exchange> exchange = connection.getBroker().createExchange(name, exchangeType, isDurable(), autodelete, alternateExchange,
                                                                                  args, connection.getUserId(), connection.getId()).first;
-    result.second = connection.getTopics().createTopic(connection.getBroker(), name, exchange, topicSettings);
+    result.second = connection.getTopics().declare(connection.getBroker(), name, exchange, topicSettings);
     return result;
 }
 

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Topic.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Topic.cpp?rev=1590805&r1=1590804&r2=1590805&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Topic.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Topic.cpp Mon Apr 28 21:24:31 2014
@@ -115,6 +115,20 @@ boost::shared_ptr<Topic> TopicRegistry::
     return topic;
 }
 
+boost::shared_ptr<Topic> TopicRegistry::declare(Broker& broker, const std::string& name, boost::shared_ptr<Exchange> exchange, const qpid::types::Variant::Map& properties)
+{
+    qpid::sys::Mutex::ScopedLock l(lock);
+    Topics::const_iterator i = topics.find(name);
+    if (i == topics.end()) {
+        boost::shared_ptr<Topic> topic(new Topic(broker, name, exchange, properties));
+        topics.insert(Topics::value_type(name, topic));
+        topic->getExchange()->setDeletionListener(name, boost::bind(&TopicRegistry::remove, this, name));
+        return topic;
+    } else {
+        return i->second;
+    }
+}
+
 bool TopicRegistry::createObject(Broker& broker, const std::string& type, const std::string& name, const qpid::types::Variant::Map& props,
                                  const std::string& /*userId*/, const std::string& /*connectionId*/)
 {

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Topic.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Topic.h?rev=1590805&r1=1590804&r2=1590805&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Topic.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/amqp/Topic.h Mon Apr 28 21:24:31 2014
@@ -78,6 +78,7 @@ class TopicRegistry : public ObjectFacto
     boost::shared_ptr<Topic> remove(const std::string& name);
     boost::shared_ptr<Topic> get(const std::string& name);
     boost::shared_ptr<Topic> createTopic(Broker&, const std::string& name, boost::shared_ptr<Exchange> exchange, const qpid::types::Variant::Map& properties);
+    boost::shared_ptr<Topic> declare(Broker&, const std::string& name, boost::shared_ptr<Exchange> exchange, const qpid::types::Variant::Map& properties);
   private:
     typedef std::map<std::string, boost::shared_ptr<Topic> > Topics;
     qpid::sys::Mutex lock;



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org