qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r1737887 - in /qpid/trunk/qpid/cpp: include/qpid/messaging/ src/ src/qpid/client/ src/qpid/ha/ src/qpid/messaging/ src/qpid/messaging/amqp/
Date Tue, 05 Apr 2016 21:50:04 GMT
Author: aconway
Date: Tue Apr  5 21:50:04 2016
New Revision: 1737887

URL: http://svn.apache.org/viewvc?rev=1737887&view=rev
Log:
QPID-7149: Fixed messaging client shutdown.

Fix previous commit that did not respect the plugin boundaries for
messaging::shutdown.

Removed:
    qpid/trunk/qpid/cpp/include/qpid/messaging/shutdown.h
    qpid/trunk/qpid/cpp/src/qpid/messaging/shutdown.cpp
Modified:
    qpid/trunk/qpid/cpp/src/CMakeLists.txt
    qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.h
    qpid/trunk/qpid/cpp/src/qpid/ha/StatusCheck.cpp
    qpid/trunk/qpid/cpp/src/qpid/messaging/ProtocolRegistry.cpp
    qpid/trunk/qpid/cpp/src/qpid/messaging/ProtocolRegistry.h
    qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.cpp

Modified: qpid/trunk/qpid/cpp/src/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/CMakeLists.txt?rev=1737887&r1=1737886&r2=1737887&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/CMakeLists.txt (original)
+++ qpid/trunk/qpid/cpp/src/CMakeLists.txt Tue Apr  5 21:50:04 2016
@@ -964,7 +964,6 @@ set (qpidmessaging_SOURCES
      qpid/messaging/ReceiverImpl.h
      qpid/messaging/SessionImpl.h
      qpid/messaging/SenderImpl.h
-     qpid/messaging/shutdown.cpp
      qpid/client/amqp0_10/AcceptTracker.h
      qpid/client/amqp0_10/AcceptTracker.cpp
      qpid/client/amqp0_10/AddressResolution.h

Modified: qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.h?rev=1737887&r1=1737886&r2=1737887&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/client/ConnectionImpl.h Tue Apr  5 21:50:04 2016
@@ -99,7 +99,7 @@ class ConnectionImpl : public Bounds,
 };
 
 // Shut down the poller early. Internal use only.
-void shutdown();
+QPID_CLIENT_EXTERN void shutdown();
 
 }}
 

Modified: qpid/trunk/qpid/cpp/src/qpid/ha/StatusCheck.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/ha/StatusCheck.cpp?rev=1737887&r1=1737886&r2=1737887&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/ha/StatusCheck.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/ha/StatusCheck.cpp Tue Apr  5 21:50:04 2016
@@ -23,13 +23,13 @@
 #include "HaBroker.h"
 #include "qpid/broker/Broker.h"
 #include "qpid/log/Statement.h"
-#include "qpid/messaging/shutdown.h"
 #include "qpid/messaging/Address.h"
 #include "qpid/messaging/Connection.h"
 #include "qpid/messaging/Message.h"
 #include "qpid/messaging/Receiver.h"
 #include "qpid/messaging/Sender.h"
 #include "qpid/messaging/Session.h"
+#include "qpid/messaging/ProtocolRegistry.h"
 #include "qpid/types/Variant.h"
 
 namespace qpid {
@@ -136,7 +136,7 @@ void StatusCheck::endThread() {
     // Shut down the client poller ASAP to avoid conflict with the broker's poller.
     // See https://issues.apache.org/jira/browse/QPID-7149
     if (--threadCount == 0) {
-        messaging::shutdown();
+        messaging::ProtocolRegistry::shutdown();
     }
 }
 

Modified: qpid/trunk/qpid/cpp/src/qpid/messaging/ProtocolRegistry.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/messaging/ProtocolRegistry.cpp?rev=1737887&r1=1737886&r2=1737887&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/messaging/ProtocolRegistry.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/messaging/ProtocolRegistry.cpp Tue Apr  5 21:50:04 2016
@@ -20,9 +20,11 @@
  */
 #include "ProtocolRegistry.h"
 #include "qpid/messaging/exceptions.h"
+#include "qpid/client/ConnectionImpl.h"
 #include "qpid/client/amqp0_10/ConnectionImpl.h"
 #include "qpid/client/LoadPlugins.h"
 #include "qpid/log/Statement.h"
+#include "qpid/sys/Mutex.h"
 #include "qpid/Options.h"
 #include "qpid/StringUtils.h"
 #include "config.h"
@@ -59,6 +61,7 @@ std::string join(const std::vector<std::
 }
 
 typedef std::map<std::string, ProtocolRegistry::Factory*> Factories;
+typedef std::vector<ProtocolRegistry::Shutdown*> Shutdowns;
 
 ConnectionImpl* create_0_10(const std::string& url, const qpid::types::Variant::Map&
options)
 {
@@ -71,6 +74,7 @@ class Registry
     Registry()
     {
         factories["amqp0-10"] = &create_0_10;
+        shutdowns.push_back(&qpid::client::shutdown);
         CommonOptions common("", "", QPIDC_CONF_FILE);
         ProtocolOptions options;
         try {
@@ -96,9 +100,10 @@ class Registry
             return i->second;
         }
     }
-    void add(const std::string& name, ProtocolRegistry::Factory* factory)
+    void add(const std::string& name, ProtocolRegistry::Factory* factory, ProtocolRegistry::Shutdown*
shutdown)
     {
         factories[name] = factory;
+        shutdowns.push_back(shutdown);
     }
     std::string getNames() const
     {
@@ -128,8 +133,17 @@ class Registry
             }
         }
     }
+    void shutdown() {
+        sys::Mutex::ScopedLock l(shutdownLock);
+        while (!shutdowns.empty()) {
+            shutdowns.back()();
+            shutdowns.pop_back();
+        }
+    }
   private:
     Factories factories;
+    Shutdowns shutdowns;
+    sys::Mutex shutdownLock;
     std::vector<std::string> versions;
 };
 
@@ -192,9 +206,14 @@ ConnectionImpl* ProtocolRegistry::next(C
     throw MessagingException("No suitable protocol version supported by peer");
 }
 
-void ProtocolRegistry::add(const std::string& name, Factory* factory)
+void ProtocolRegistry::add(const std::string& name, Factory* factory, Shutdown* shutdown)
 {
-    theRegistry().add(name, factory);
+    theRegistry().add(name, factory, shutdown);
 }
 
+void ProtocolRegistry::shutdown() {
+    theRegistry().shutdown();
+}
+
+
 }} // namespace qpid::messaging

Modified: qpid/trunk/qpid/cpp/src/qpid/messaging/ProtocolRegistry.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/messaging/ProtocolRegistry.h?rev=1737887&r1=1737886&r2=1737887&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/messaging/ProtocolRegistry.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/messaging/ProtocolRegistry.h Tue Apr  5 21:50:04 2016
@@ -36,9 +36,12 @@ class ProtocolRegistry
 {
   public:
     typedef ConnectionImpl* Factory(const std::string& url, const qpid::types::Variant::Map&
options);
+    typedef void Shutdown();
+
     static ConnectionImpl* create(const std::string& url, const qpid::types::Variant::Map&
options);
     static ConnectionImpl* next(ConnectionImpl*);
-    QPID_MESSAGING_EXTERN static void add(const std::string& name, Factory* factory);
+    QPID_MESSAGING_EXTERN static void add(const std::string& name, Factory*, Shutdown*);
+    QPID_MESSAGING_EXTERN static void shutdown();
   private:
     static ConnectionImpl* createInternal(const std::vector<std::string>& versions,
const std::string& url, const qpid::types::Variant::Map& options, const std::string&
error);
 };

Modified: qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.cpp?rev=1737887&r1=1737886&r2=1737887&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/messaging/amqp/ConnectionHandle.cpp Tue Apr  5 21:50:04 2016
@@ -21,6 +21,7 @@
 #include "ConnectionHandle.h"
 #include "ConnectionContext.h"
 #include "SessionHandle.h"
+#include "DriverImpl.h"
 #include "qpid/messaging/Session.h"
 #include "qpid/messaging/ProtocolRegistry.h"
 
@@ -40,11 +41,15 @@ ConnectionImpl* create(const std::string
     }
 }
 
+void shutdown() {
+    DriverImpl::getDefault()->stop();
+}
+
 struct StaticInit
 {
     StaticInit()
     {
-        ProtocolRegistry::add("amqp1.0", &create);
+        ProtocolRegistry::add("amqp1.0", &create, &shutdown);
     };
 } init;
 }



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


Mime
View raw message