You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2017/11/28 18:25:29 UTC

qpid-proton git commit: PROTON-1700: [C++ binding] Interrupt reconnect attempts when container stopped

Repository: qpid-proton
Updated Branches:
  refs/heads/master f9d8cc4ac -> de1e81cc5


PROTON-1700: [C++ binding] Interrupt reconnect attempts when container stopped


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/de1e81cc
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/de1e81cc
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/de1e81cc

Branch: refs/heads/master
Commit: de1e81cc5090b0f10b8ff3e17059ef0d2275f098
Parents: f9d8cc4
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue Nov 28 13:15:03 2017 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Tue Nov 28 13:15:03 2017 -0500

----------------------------------------------------------------------
 examples/cpp/CMakeLists.txt                     |  1 +
 .../cpp/src/proactor_container_impl.cpp         |  6 ++++
 proton-c/bindings/cpp/src/reconnect_test.cpp    | 32 ++++++++++++++++++++
 3 files changed, 39 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/de1e81cc/examples/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt
index 0531aec..58cbb5b 100644
--- a/examples/cpp/CMakeLists.txt
+++ b/examples/cpp/CMakeLists.txt
@@ -77,6 +77,7 @@ if(HAS_CPP11)
   # Examples that use threads directly
   if (Threads_FOUND)
     foreach(example
+        reconnect-and-stop
         multithreaded_client
         multithreaded_client_flow_control)
       add_executable(${example} ${example}.cpp)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/de1e81cc/proton-c/bindings/cpp/src/proactor_container_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proactor_container_impl.cpp b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
index 4a4ddce..2f09f51 100644
--- a/proton-c/bindings/cpp/src/proactor_container_impl.cpp
+++ b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
@@ -281,6 +281,12 @@ void container::impl::reset_reconnect(pn_connection_t* pnc) {
 }
 
 bool container::impl::setup_reconnect(pn_connection_t* pnc) {
+    // If container stopping don't try to reconnect
+    // - we pretend to have set up a reconnect attempt so
+    //   that the proactor disconnect will finish and we will exit
+    //   the run loop without error.
+    if (stopping_) return true;
+
     connection_context& cc = connection_context::get(pnc);
     reconnect_context* rc = cc.reconnect_context_.get();
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/de1e81cc/proton-c/bindings/cpp/src/reconnect_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/reconnect_test.cpp b/proton-c/bindings/cpp/src/reconnect_test.cpp
index 461e873..b7df213 100644
--- a/proton-c/bindings/cpp/src/reconnect_test.cpp
+++ b/proton-c/bindings/cpp/src/reconnect_test.cpp
@@ -29,6 +29,7 @@
 #include "proton/listener.hpp"
 #include "proton/listen_handler.hpp"
 #include "proton/reconnect_options.hpp"
+#include "proton/work_queue.hpp"
 
 #include "proton/internal/pn_unique_ptr.hpp"
 
@@ -161,9 +162,40 @@ int test_failover_simple() {
 
 }
 
+class stop_reconnect_tester : public proton::messaging_handler {
+  public:
+    stop_reconnect_tester() :
+        container_(*this, "reconnect_tester")
+    {
+    }
+
+    void deferred_stop() {
+        container_.stop();
+    }
+
+    void on_container_start(proton::container &c) PN_CPP_OVERRIDE {
+        proton::reconnect_options reconnect_options;
+        c.connect("this-is-not-going-to work.com", proton::connection_options().reconnect(reconnect_options));
+        c.schedule(proton::duration::SECOND, proton::make_work(&stop_reconnect_tester::deferred_stop, this));
+    }
+
+    void run() {
+        container_.run();
+    }
+
+  private:
+    proton::container container_;
+};
+
+int test_stop_reconnect() {
+    stop_reconnect_tester().run();
+    return 0;
+}
+
 int main(int, char**) {
     int failed = 0;
     RUN_TEST(failed, test_failover_simple());
+    RUN_TEST(failed, test_stop_reconnect());
     return failed;
 }
 


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