qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject qpid-dispatch git commit: DISPATCH-739: reorder link detach logic to avoid premature free
Date Thu, 20 Apr 2017 15:19:41 GMT
Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 0fb5b54d1 -> 2bbeefafe


DISPATCH-739: reorder link detach logic to avoid premature free


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

Branch: refs/heads/master
Commit: 2bbeefafeb5d35604832bfc6b8fbb09e3ec6162b
Parents: 0fb5b54
Author: Alan Conway <aconway@redhat.com>
Authored: Thu Apr 20 11:12:52 2017 -0400
Committer: Alan Conway <aconway@redhat.com>
Committed: Thu Apr 20 11:12:52 2017 -0400

----------------------------------------------------------------------
 src/container.c                       |  7 ++++---
 src/router_core/connections.c         | 14 +-------------
 src/router_core/router_core_private.h |  4 +---
 src/router_node.c                     |  6 +++---
 4 files changed, 9 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/2bbeefaf/src/container.c
----------------------------------------------------------------------
diff --git a/src/container.c b/src/container.c
index 3e60ee0..b86bbef 100644
--- a/src/container.c
+++ b/src/container.c
@@ -541,9 +541,7 @@ int pn_event_handler(void *handler_context, void *conn_context, pn_event_t
*even
                 pn_session_t *sess = qd_link->pn_sess;
                 qd_node_t *node = qd_link->node;
                 qd_detach_type_t dt = pn_event_type(event) == PN_LINK_REMOTE_CLOSE ? QD_CLOSED
: QD_DETACHED;
-                if (node)
-                    node->ntype->link_detach_handler(node->context, qd_link, dt);
-                else if (qd_link->pn_link == pn_link) {
+                if (!node && qd_link->pn_link == pn_link) {
                     pn_link_close(pn_link);
                 }
                 if (qd_conn->policy_counted && qd_conn->policy_settings) {
@@ -567,6 +565,9 @@ int pn_event_handler(void *handler_context, void *conn_context, pn_event_t
*even
                         pn_session_close(sess);
                     add_link_to_free_list(&qd_conn->free_link_session_list, pn_link);
                 }
+                if (node) {
+                    node->ntype->link_detach_handler(node->context, qd_link, dt);
+                }
             }
         }
         break;

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/2bbeefaf/src/router_core/connections.c
----------------------------------------------------------------------
diff --git a/src/router_core/connections.c b/src/router_core/connections.c
index 08791c2..c0c5b0c 100644
--- a/src/router_core/connections.c
+++ b/src/router_core/connections.c
@@ -89,7 +89,6 @@ qdr_connection_t *qdr_connection_opened(qdr_core_t            *core,
     DEQ_INIT(conn->work_list);
     conn->connection_info->role = conn->role;
     conn->work_lock = sys_mutex();
-    conn->context_lock = sys_mutex();
 
     if (vhost) {
         conn->tenant_space_len = strlen(vhost) + 1;
@@ -118,12 +117,7 @@ void qdr_connection_closed(qdr_connection_t *conn)
 void qdr_connection_set_context(qdr_connection_t *conn, void *context)
 {
     if (conn) {
-        /* TODO aconway 2017-04-20: note this could be an atomic pointer store,
-         * but it must provide a full memory barrier.
-         */
-        sys_mutex_lock(conn->context_lock);
         conn->user_context = context;
-        sys_mutex_unlock(conn->context_lock);
     }
 }
 
@@ -187,13 +181,7 @@ qdr_connection_info_t *qdr_connection_info(bool             is_encrypted,
 
 void *qdr_connection_get_context(const qdr_connection_t *conn)
 {
-    void *ret = NULL;
-    if (conn) {
-        sys_mutex_lock(conn->context_lock);
-        ret = conn->user_context;
-        sys_mutex_unlock(conn->context_lock);
-    }
-    return ret;
+    return conn ? conn->user_context : NULL;
 }
 
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/2bbeefaf/src/router_core/router_core_private.h
----------------------------------------------------------------------
diff --git a/src/router_core/router_core_private.h b/src/router_core/router_core_private.h
index c60cd9c..5e92326 100644
--- a/src/router_core/router_core_private.h
+++ b/src/router_core/router_core_private.h
@@ -534,9 +534,7 @@ struct qdr_connection_t {
     char                       *tenant_space;
     int                         tenant_space_len;
     qdr_connection_info_t      *connection_info;
-
-    sys_mutex_t                *context_lock;
-    void                       *user_context; /* Updated from IO thread on close */
+    void                       *user_context; /* Updated from IO thread, use work_lock */
 };
 
 ALLOC_DECLARE(qdr_connection_t);

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/2bbeefaf/src/router_node.c
----------------------------------------------------------------------
diff --git a/src/router_node.c b/src/router_node.c
index 9761468..12b6887 100644
--- a/src/router_node.c
+++ b/src/router_node.c
@@ -587,9 +587,6 @@ static int AMQP_link_detach_handler(void* context, qd_link_t *link, qd_detach_ty
     pn_condition_t *cond   = qd_link_pn(link) ? pn_link_remote_condition(qd_link_pn(link))
: 0;
 
     if (rlink) {
-        qdr_error_t *error = qdr_error_from_pn(cond);
-        qdr_link_detach(rlink, dt, error);
-
         //
         // This is the last event for this link that we will send into the core.  Remove
the
         // core linkage.  Note that the core->qd linkage is still in place.
@@ -605,6 +602,9 @@ static int AMQP_link_detach_handler(void* context, qd_link_t *link, qd_detach_ty
             qdr_link_set_context(rlink, 0);
             qd_link_free(link);
         }
+
+        qdr_error_t *error = qdr_error_from_pn(cond);
+        qdr_link_detach(rlink, dt, error);
     }
 
     return 0;


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


Mime
View raw message