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

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


The following commit(s) were added to refs/heads/main by this push:
     new 4746fb3  DISPATCH-2168: Added addr incref and decref for no_route 
links. This will make sure that the address object will not be freed 
prematurely. This closes #1304
4746fb3 is described below

commit 4746fb351b5f54a12328d9c2f165549aa1131e70
Author: Ganesh Murthy <gmur...@apache.org>
AuthorDate: Mon Jul 19 16:55:19 2021 -0400

    DISPATCH-2168: Added addr incref and decref for no_route links. This will 
make sure that the address object will not be freed prematurely. This closes 
#1304
---
 src/router_core/connections.c         | 7 +++++++
 src/router_core/router_core.c         | 6 +++++-
 src/router_core/router_core_private.h | 1 +
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/router_core/connections.c b/src/router_core/connections.c
index bf462f3..c6e8c26 100644
--- a/src/router_core/connections.c
+++ b/src/router_core/connections.c
@@ -2103,6 +2103,13 @@ static void qdr_link_inbound_detach_CT(qdr_core_t *core, 
qdr_action_t *action, b
         }
     }
 
+    //
+    // We had increased the ref_count if the link->no_route was true. Now 
reduce the ref_count
+    //
+    if (link->no_route && link->no_route_bound) {
+        addr->ref_count--;
+    }
+
     link->owning_addr = 0;
 
     if (link->detach_count == 1) {
diff --git a/src/router_core/router_core.c b/src/router_core/router_core.c
index 1af9e73..812c50f 100644
--- a/src/router_core/router_core.c
+++ b/src/router_core/router_core.c
@@ -679,8 +679,12 @@ void qdr_core_bind_address_link_CT(qdr_core_t *core, 
qdr_address_t *addr, qdr_li
     // If this link is configured as no-route, don't create any functional 
linkage between the
     // link and the address beyond the owning_addr.
     //
-    if (link->no_route)
+    if (link->no_route) {
+        link->owning_addr->ref_count++;
+        // The no_route link's address has been bound. Set no_route_bound to 
true.
+        link->no_route_bound = true;
         return;
+    }
 
     if (link->link_direction == QD_OUTGOING) {
         qdr_add_link_ref(&addr->rlinks, link, QDR_LINK_LIST_CLASS_ADDRESS);
diff --git a/src/router_core/router_core_private.h 
b/src/router_core/router_core_private.h
index e33941f..c08753a 100644
--- a/src/router_core/router_core_private.h
+++ b/src/router_core/router_core_private.h
@@ -473,6 +473,7 @@ struct qdr_link_t {
     bool                     in_streaming_pool; ///< True if this link is in 
the connections standby pool STREAMING_POOL
     bool                     terminus_survives_disconnect;
     bool                     no_route;          ///< True if this link is to 
not receive routed deliveries
+    bool                     no_route_bound;    // Has the no_route link been 
bound ? Has the link's owning address been set for no_route links ?
     char                    *strip_prefix;
     char                    *insert_prefix;
 

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

Reply via email to