You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/10/23 16:38:23 UTC

[1/2] qpid-proton git commit: PROTON-1628: [cpp] Stopping container in on_container_start will hang

Repository: qpid-proton
Updated Branches:
  refs/heads/master d09511f19 -> bdfe982f5


PROTON-1628: [cpp] Stopping container in on_container_start will hang

Check if already stopping before entering the event loop in container::impl::thread()


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

Branch: refs/heads/master
Commit: e1708890cad88175f5465275a854bd279b7109bc
Parents: d09511f
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Oct 23 17:24:10 2017 +0100
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Oct 23 17:24:10 2017 +0100

----------------------------------------------------------------------
 proton-c/bindings/cpp/src/container_test.cpp    | 30 +++++++---
 .../cpp/src/proactor_container_impl.cpp         | 63 ++++++++++++--------
 2 files changed, 59 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e1708890/proton-c/bindings/cpp/src/container_test.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/container_test.cpp b/proton-c/bindings/cpp/src/container_test.cpp
index fc368d0..c0a9734 100644
--- a/proton-c/bindings/cpp/src/container_test.cpp
+++ b/proton-c/bindings/cpp/src/container_test.cpp
@@ -245,17 +245,31 @@ int test_container_schedule_nohang() {
     return 0;
 }
 
+class immediate_stop_tester : public proton::messaging_handler {
+public:
+    void on_container_start(proton::container &c) PN_CPP_OVERRIDE {
+        c.stop();
+    }
+};
+
+int test_container_immediate_stop() {
+    immediate_stop_tester t;
+    proton::container(t).run();  // will hang
+    return 0;
 }
 
-int main(int, char**) {
+} // namespace
+
+int main(int argc, char** argv) {
     int failed = 0;
-    RUN_TEST(failed, test_container_default_container_id());
-    RUN_TEST(failed, test_container_vhost());
-    RUN_TEST(failed, test_container_default_vhost());
-    RUN_TEST(failed, test_container_no_vhost());
-    RUN_TEST(failed, test_container_bad_address());
-    RUN_TEST(failed, test_container_stop());
-    RUN_TEST(failed, test_container_schedule_nohang());
+    RUN_ARGV_TEST(failed, test_container_default_container_id());
+    RUN_ARGV_TEST(failed, test_container_vhost());
+    RUN_ARGV_TEST(failed, test_container_default_vhost());
+    RUN_ARGV_TEST(failed, test_container_no_vhost());
+    RUN_ARGV_TEST(failed, test_container_bad_address());
+    RUN_ARGV_TEST(failed, test_container_stop());
+    RUN_ARGV_TEST(failed, test_container_schedule_nohang());
+    RUN_ARGV_TEST(failed, test_container_immediate_stop());
     return failed;
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e1708890/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 0965391..427bb7c 100644
--- a/proton-c/bindings/cpp/src/proactor_container_impl.cpp
+++ b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
@@ -455,6 +455,7 @@ void container::impl::run_timer_jobs() {
     }
 }
 
+// Return true if this thread is finished
 bool container::impl::handle(pn_event_t* event) {
 
     // If we have any pending connection work, do it now
@@ -620,32 +621,38 @@ bool container::impl::handle(pn_event_t* event) {
 }
 
 void container::impl::thread() {
+    bool finished;
     {
         GUARD(lock_);
         ++threads_;
+        finished = stopping_;
     }
-    bool finished = false;
-    do {
-      pn_event_batch_t *events = pn_proactor_wait(proactor_);
-      pn_event_t *e;
-      try {
-        while ((e = pn_event_batch_next(events))) {
-          finished = handle(e);
-          if (finished) break;
+    while (!finished) {
+        pn_event_batch_t *events = pn_proactor_wait(proactor_);
+        pn_event_t *e;
+        const char *what = 0;
+        try {
+            while ((e = pn_event_batch_next(events))) {
+                finished = handle(e);
+                if (finished) break;
+            }
+        } catch (const std::exception& e) {
+            // If we caught an exception then shutdown the (other threads of the) container
+            what = e.what();
+        } catch (...) {
+            what = "container shut-down by unknown exception";
+        }
+        pn_proactor_done(proactor_, events);
+        if (what) {
+            finished = true;
+            error_condition error("exception", what);
+            {
+                GUARD(lock_);
+                disconnect_error_ = error;
+            }
+            stop(error);
         }
-      } catch (const std::exception& e) {
-        // If we caught an exception then shutdown the (other threads of the) container
-        disconnect_error_ = error_condition("exception", e.what());
-        if (!stopping_) stop(disconnect_error_);
-        finished = true;
-      } catch (...) {
-        // If we caught an exception then shutdown the (other threads of the) container
-        disconnect_error_ = error_condition("exception", "container shut-down by unknown exception");
-        if (!stopping_) stop(disconnect_error_);
-        finished = true;
-      }
-      pn_proactor_done(proactor_, events);
-    } while(!finished);
+    }
     {
         GUARD(lock_);
         --threads_;
@@ -692,8 +699,9 @@ void container::impl::run(int threads) {
     if (last) CALL_ONCE(stop_once_, &impl::stop_event, this);
 
     // Throw an exception if we disconnected the proactor because of an exception
-    if (!disconnect_error_.empty()) {
-      throw proton::error(disconnect_error_.description());
+    {
+        GUARD(lock_);
+        if (!disconnect_error_.empty()) throw proton::error(disconnect_error_.description());
     };
 }
 
@@ -703,9 +711,12 @@ void container::impl::auto_stop(bool set) {
 }
 
 void container::impl::stop(const proton::error_condition& err) {
-    GUARD(lock_);
-    auto_stop_ = true;
-    stopping_ = true;
+    {
+        GUARD(lock_);
+        if (stopping_) return;  // Already stopping
+        auto_stop_ = true;
+        stopping_ = true;
+    }
     pn_condition_t* error_condition = pn_condition();
     set_error_condition(err, error_condition);
     pn_proactor_disconnect(proactor_, error_condition);


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


[2/2] qpid-proton git commit: PROTON-1622 Add coverage reporting to CMake build

Posted by ac...@apache.org.
PROTON-1622 Add coverage reporting to CMake build

    cmake -DCMAKE_BUILD_TYPE=Coverage && make && ctest && make coverage

Then browse ${CMAKE_BUILD_DIR}/coverage_results/html/index.html


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

Branch: refs/heads/master
Commit: bdfe982f5f2dd8b9735288623fbc8eabe4a5371f
Parents: e170889
Author: Jiri Danek <jd...@redhat.com>
Authored: Tue Oct 10 21:57:30 2017 +0200
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Oct 23 17:37:33 2017 +0100

----------------------------------------------------------------------
 .travis.yml             | 14 +++++++++++++-
 CMakeLists.txt          |  2 +-
 proton-c/CMakeLists.txt |  6 +++++-
 3 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bdfe982f/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index f7a8d77..f8694b0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -39,10 +39,11 @@ addons:
     - python3-dev
     - php5
     - golang
+    - lcov
 
 install:
 - pip install --user --upgrade pip
-- pip install --user tox
+- pip install --user coverage tox
 - gem install minitest
 
 before_script:
@@ -52,3 +53,14 @@ before_script:
 
 script:
 - cmake --build . --target install && ctest -V ${QPID_PROTON_CTEST_ARGS}
+
+after_success:
+- |
+    if [[ ${CC} = gcc ]]; then
+      mkdir ../build_coverage
+      cd ../build_coverage
+      cmake .. -DCMAKE_INSTALL_PREFIX=$PWD/install -DCMAKE_BUILD_TYPE=Coverage ${QPID_PROTON_CMAKE_ARGS}
+      cmake --build . --target install && ctest -V ${QPID_PROTON_CTEST_ARGS}
+      make coverage
+      bash <(curl -s https://codecov.io/bash)
+    fi

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bdfe982f/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 75310bd..9f81cbb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -78,7 +78,7 @@ if (CMAKE_BUILD_TYPE MATCHES "Coverage")
   make_directory(coverage_results)
   add_custom_target(coverage
     WORKING_DIRECTORY ./coverage_results
-    CgOMMAND ${CMAKE_SOURCE_DIR}/bin/record-coverage.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
+    COMMAND ${CMAKE_SOURCE_DIR}/bin/record-coverage.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
 endif()
 
 if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/bdfe982f/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index 4cd4bd5..c420649 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -744,13 +744,17 @@ if (BUILD_PYTHON)
   to_native_path ("${py_pythonpath}" py_pythonpath)
   to_native_path ("${py_path}" py_path)
 
+  if (CMAKE_BUILD_TYPE MATCHES "Coverage")
+    set (python_coverage_options -m coverage run)
+  endif(CMAKE_BUILD_TYPE MATCHES "Coverage")
+
   add_test (NAME python-test
             COMMAND ${env_py}
               "PATH=${py_path}" "PYTHONPATH=${py_pythonpath}"
               "CLASSPATH=${CMAKE_BINARY_DIR}/proton-j/proton-j.jar"
               "SASLPASSWD=${SASLPASSWD_EXE}"
               ${VALGRIND_ENV}
-              ${PYTHON_EXECUTABLE} "${py_root}/proton-test")
+              ${PYTHON_EXECUTABLE} -- ${python_coverage_options} "${py_root}/proton-test")
   set_tests_properties(python-test PROPERTIES PASS_REGULAR_EXPRESSION "Totals: .* 0 failed")
 
   # Eventually, we'll get rid of this check when other


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