qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tr...@apache.org
Subject qpid-dispatch git commit: DISPATCH_179 - Reviewed the lifecycle of links and fixed a link-leak.
Date Fri, 01 Apr 2016 17:43:39 GMT
Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 20447d578 -> e0f6c6151


DISPATCH_179 - Reviewed the lifecycle of links and fixed a link-leak.


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

Branch: refs/heads/master
Commit: e0f6c6151a48271c381db0f9fa02e6521f6ffaf7
Parents: 20447d5
Author: Ted Ross <tross@redhat.com>
Authored: Fri Apr 1 13:42:54 2016 -0400
Committer: Ted Ross <tross@redhat.com>
Committed: Fri Apr 1 13:42:54 2016 -0400

----------------------------------------------------------------------
 include/qpid/dispatch/container.h   |  2 +-
 include/qpid/dispatch/router_core.h |  2 +-
 src/container.c                     | 10 +++++++---
 src/router_core/connections.c       |  9 ++++++---
 src/router_node.c                   | 20 +++++++++++++++++---
 tests/system_tests_qdstat.py        |  2 +-
 6 files changed, 33 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e0f6c615/include/qpid/dispatch/container.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/container.h b/include/qpid/dispatch/container.h
index 0dcbb95..a59d6e7 100644
--- a/include/qpid/dispatch/container.h
+++ b/include/qpid/dispatch/container.h
@@ -182,7 +182,7 @@ pn_terminus_t *qd_link_remote_target(qd_link_t *link);
 void qd_link_activate(qd_link_t *link);
 void qd_link_close(qd_link_t *link);
 bool qd_link_drain_changed(qd_link_t *link, bool *mode);
-void qd_link_free_LH(qd_link_t *link);
+void qd_link_free(qd_link_t *link);
 
 ///@}
 #endif

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e0f6c615/include/qpid/dispatch/router_core.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/router_core.h b/include/qpid/dispatch/router_core.h
index 3956b5c..9c77a08 100644
--- a/include/qpid/dispatch/router_core.h
+++ b/include/qpid/dispatch/router_core.h
@@ -515,7 +515,7 @@ typedef void (*qdr_link_first_attach_t)  (void *context, qdr_connection_t
*conn,
                                           qdr_terminus_t *source, qdr_terminus_t *target);
 typedef void (*qdr_link_second_attach_t) (void *context, qdr_link_t *link,
                                           qdr_terminus_t *source, qdr_terminus_t *target);
-typedef void (*qdr_link_detach_t)        (void *context, qdr_link_t *link, qdr_error_t *error);
+typedef void (*qdr_link_detach_t)        (void *context, qdr_link_t *link, qdr_error_t *error,
bool first);
 typedef void (*qdr_link_flow_t)          (void *context, qdr_link_t *link, int credit);
 typedef void (*qdr_link_offer_t)         (void *context, qdr_link_t *link, int delivery_count);
 typedef void (*qdr_link_drained_t)       (void *context, qdr_link_t *link);

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e0f6c615/src/container.c
----------------------------------------------------------------------
diff --git a/src/container.c b/src/container.c
index c97b5a4..fa2f306 100644
--- a/src/container.c
+++ b/src/container.c
@@ -451,8 +451,8 @@ int pn_event_handler(void *handler_context, void *conn_context, pn_event_t
*even
         pn_link = pn_event_link(event);
         if (pn_link_state(pn_link) & PN_LOCAL_UNINIT) {
             if (pn_link_is_sender(pn_link)) {
-               if (qd_conn->policy_settings) {
-                   if (!qd_policy_approve_amqp_receiver_link(pn_link, qd_conn)) {
+                if (qd_conn->policy_settings) {
+                    if (!qd_policy_approve_amqp_receiver_link(pn_link, qd_conn)) {
                         break;
                     }
                     qd_conn->n_senders++;
@@ -481,6 +481,10 @@ int pn_event_handler(void *handler_context, void *conn_context, pn_event_t
*even
             if (node)
                 node->ntype->link_detach_handler(node->context, qd_link, dt);
             else if (qd_link->pn_link == pn_link) {
+
+                //
+                // This policy stuff is in the wrong place.  This else clause typically does
not run.
+                //
                 if (qd_conn->policy_settings) {
                     if (pn_link_is_sender(pn_link)) {
                         qd_conn->n_senders--;
@@ -794,7 +798,7 @@ qd_link_t *qd_link(qd_node_t *node, qd_connection_t *conn, qd_direction_t
dir, c
 }
 
 
-void qd_link_free_LH(qd_link_t *link)
+void qd_link_free(qd_link_t *link)
 {
     if (!link) return;
     if (link->pn_link) pn_decref(link->pn_link);

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e0f6c615/src/router_core/connections.c
----------------------------------------------------------------------
diff --git a/src/router_core/connections.c b/src/router_core/connections.c
index 9b6e63b..1920b89 100644
--- a/src/router_core/connections.c
+++ b/src/router_core/connections.c
@@ -132,13 +132,13 @@ int qdr_connection_process(qdr_connection_t *conn)
             break;
 
         case QDR_CONNECTION_WORK_FIRST_DETACH :
-            core->detach_handler(core->user_context, work->link, work->error);
+            core->detach_handler(core->user_context, work->link, work->error,
true);
             if (work->error)
                 qdr_error_free(work->error);
             break;
 
         case QDR_CONNECTION_WORK_SECOND_DETACH :
-            core->detach_handler(core->user_context, work->link, work->error);
+            core->detach_handler(core->user_context, work->link, work->error,
false);
             if (work->error)
                 qdr_error_free(work->error);
             free_qdr_link_t(work->link);
@@ -1231,7 +1231,7 @@ static void qdr_link_inbound_detach_CT(qdr_core_t *core, qdr_action_t
*action, b
         // If the detach occurred via protocol, send a detach back.
         //
         if (dt != QD_LOST)
-            qdr_link_outbound_detach_CT(core, link, 0, QDR_CONDITION_NONE);  // TODO - Fix
error arg
+            qdr_link_outbound_detach_CT(core, link, 0, QDR_CONDITION_NONE);
     } else {
         qdr_link_cleanup_CT(core, conn, link);
         free_qdr_link_t(link);
@@ -1243,6 +1243,9 @@ static void qdr_link_inbound_detach_CT(qdr_core_t *core, qdr_action_t
*action, b
     //
     if (addr)
         qdr_check_addr_CT(core, addr, was_local);
+
+    if (error)
+        qdr_error_free(error);
 }
 
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e0f6c615/src/router_node.c
----------------------------------------------------------------------
diff --git a/src/router_node.c b/src/router_node.c
index e6527b0..23b2602 100644
--- a/src/router_node.c
+++ b/src/router_node.c
@@ -468,8 +468,6 @@ static int AMQP_link_detach_handler(void* context, qd_link_t *link, qd_detach_ty
 
     if (rlink) {
         qdr_error_t *error = qdr_error_from_pn(cond);
-        if (!error && dt == QD_LOST)
-            error = qdr_error("qd:routed-link-lost", "Connectivity to the peer container
was lost");
         qdr_link_detach(rlink, dt, error);
 
         //
@@ -477,6 +475,16 @@ static int AMQP_link_detach_handler(void* context, qd_link_t *link, qd_detach_ty
         // core linkage.  Note that the core->qd linkage is still in place.
         //
         qd_link_set_context(link, 0);
+
+        //
+        // If the link was lost (due to connection drop), or the linkage from the core
+        // object is already gone, finish disconnecting the linkage and free the qd_link
+        // because the core will silently free its own resources.
+        //
+        if (dt == QD_LOST || qdr_link_get_context(rlink) == 0) {
+            qdr_link_set_context(rlink, 0);
+            qd_link_free(link);
+        }
     }
 
     return 0;
@@ -673,7 +681,7 @@ static void CORE_link_second_attach(void *context, qdr_link_t *link, qdr_terminu
 }
 
 
-static void CORE_link_detach(void *context, qdr_link_t *link, qdr_error_t *error)
+static void CORE_link_detach(void *context, qdr_link_t *link, qdr_error_t *error, bool first)
 {
     qd_link_t *qlink = (qd_link_t*) qdr_link_get_context(link);
     if (!qlink)
@@ -688,6 +696,12 @@ static void CORE_link_detach(void *context, qdr_link_t *link, qdr_error_t
*error
         qdr_error_copy(error, cond);
     }
     qd_link_close(qlink);
+
+    //
+    // If this is the second detach, free the qd_link
+    //
+    if (!first)
+        qd_link_free(qlink);
 }
 
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e0f6c615/tests/system_tests_qdstat.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_qdstat.py b/tests/system_tests_qdstat.py
index adb2731..8a88000 100644
--- a/tests/system_tests_qdstat.py
+++ b/tests/system_tests_qdstat.py
@@ -54,7 +54,7 @@ class QdstatTest(system_test.TestCase):
         self.run_qdstat(['--connections'], r'host.*container.*role')
 
     def test_links(self):
-        self.run_qdstat(['--links'], r'endpoint.*out.*L:temp.')
+        self.run_qdstat(['--links'], r'endpoint.*out.*local.*temp.')
 
     def test_nodes(self):
         self.run_qdstat(['--nodes'], r'No Router List')


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


Mime
View raw message