You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gm...@apache.org on 2019/01/04 15:31:48 UTC

[qpid-dispatch] branch master updated: DISPATCH-1234 - Zero out the edge context on the link before the edge context is freed. This closes #433.

This is an automated email from the ASF dual-hosted git repository.

gmurthy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git


The following commit(s) were added to refs/heads/master by this push:
     new 94bbe16  DISPATCH-1234 - Zero out the edge context on the link before the edge context is freed. This closes #433.
94bbe16 is described below

commit 94bbe1603322e0a686533410d740a9b72740b852
Author: Ganesh Murthy <gm...@redhat.com>
AuthorDate: Thu Jan 3 12:22:21 2019 -0500

    DISPATCH-1234 - Zero out the edge context on the link before the edge context is freed. This closes #433.
---
 .../edge_addr_tracking/edge_addr_tracking.c        | 27 +++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/router_core/modules/edge_addr_tracking/edge_addr_tracking.c b/src/router_core/modules/edge_addr_tracking/edge_addr_tracking.c
index a7ea0a7..e161963 100644
--- a/src/router_core/modules/edge_addr_tracking/edge_addr_tracking.c
+++ b/src/router_core/modules/edge_addr_tracking/edge_addr_tracking.c
@@ -31,6 +31,7 @@ struct qdr_addr_endpoint_state_t {
     qdrc_endpoint_t                    *endpoint;
     qdr_connection_t                   *conn;    // The connection associated with the endpoint.
     qdr_addr_tracking_module_context_t *mc;
+    qdr_link_t                         *link;
 };
 
 DEQ_DECLARE(qdr_addr_endpoint_state_t, qdr_addr_endpoint_state_list_t);
@@ -134,6 +135,12 @@ static void qdrc_address_endpoint_on_first_detach(void *link_context,
     qdrc_endpoint_detach_CT(endpoint_state->mc->core, endpoint_state->endpoint, 0);
     qdr_addr_tracking_module_context_t *mc = endpoint_state->mc;
     DEQ_REMOVE(mc->endpoint_state_list, endpoint_state);
+    endpoint_state->conn = 0;
+    endpoint_state->endpoint = 0;
+    if (endpoint_state->link) {
+        endpoint_state->link->edge_context = 0;
+        endpoint_state->link = 0;
+    }
     free_qdr_addr_endpoint_state_t(endpoint_state);
     qdr_error_free(error);
 }
@@ -217,7 +224,8 @@ static void on_addr_event(void *context, qdrc_event_t event, qdr_address_t *addr
                     qdr_addr_endpoint_state_t *endpoint_state = (qdr_addr_endpoint_state_t *)inlink->link->edge_context;
                     if (qdrc_can_send_address(addr, endpoint_state->conn) ) {
                         qdrc_endpoint_t *endpoint = endpoint_state->endpoint;
-                        qdrc_send_message(addr_tracking->core, addr, endpoint, true);
+                        if (endpoint)
+                            qdrc_send_message(addr_tracking->core, addr, endpoint, true);
                     }
                 }
                 inlink = DEQ_NEXT(inlink);
@@ -237,7 +245,8 @@ static void on_addr_event(void *context, qdrc_event_t event, qdr_address_t *addr
                     if(inlink->link->edge_context != 0) {
                         qdr_addr_endpoint_state_t *endpoint_state = (qdr_addr_endpoint_state_t *)inlink->link->edge_context;
                         qdrc_endpoint_t *endpoint = endpoint_state->endpoint;
-                        qdrc_send_message(addr_tracking->core, addr, endpoint, false);
+                        if (endpoint)
+                            qdrc_send_message(addr_tracking->core, addr, endpoint, false);
                     }
                     inlink = DEQ_NEXT(inlink);
                 }
@@ -308,6 +317,7 @@ static void on_link_event(void *context, qdrc_event_t event, qdr_link_t *link)
             if (addr && qdr_address_is_mobile_CT(addr)) {
                 qdr_addr_endpoint_state_t *endpoint_state = qdrc_get_endpoint_state_for_connection(mc->endpoint_state_list, link->conn, link);
                 link->edge_context = endpoint_state;
+                endpoint_state->link = link;
 
                 if (qdrc_can_send_address(addr, link->conn) && endpoint_state) {
                     qdrc_send_message(mc->core, addr, endpoint_state->endpoint, true);
@@ -315,6 +325,17 @@ static void on_link_event(void *context, qdrc_event_t event, qdr_link_t *link)
             }
             break;
         }
+        case QDRC_EVENT_LINK_EDGE_DATA_DETACHED :
+        {
+            if (link->edge_context) {
+                qdr_addr_endpoint_state_t *endpoint_state = (qdr_addr_endpoint_state_t *)link->edge_context;
+                endpoint_state->link = 0;
+                link->edge_context = 0;
+            }
+
+            break;
+        }
+
         default:
             break;
     }
@@ -348,7 +369,7 @@ static void qdrc_edge_address_tracking_init_CT(qdr_core_t *core, void **module_c
     context->event_sub = qdrc_event_subscribe_CT(core,
             QDRC_EVENT_ADDR_BECAME_LOCAL_DEST | QDRC_EVENT_ADDR_ONE_LOCAL_DEST |
             QDRC_EVENT_ADDR_NO_LONGER_LOCAL_DEST | QDRC_EVENT_ADDR_BECAME_DEST | QDRC_EVENT_ADDR_TWO_DEST |
-            QDRC_EVENT_LINK_EDGE_DATA_ATTACHED,
+            QDRC_EVENT_LINK_EDGE_DATA_ATTACHED | QDRC_EVENT_LINK_EDGE_DATA_DETACHED,
             0,
             on_link_event,
             on_addr_event,


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