You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2015/10/22 03:04:07 UTC

qpid-dispatch git commit: DISPATCH-179 - Filled in more missing function bodies.

Repository: qpid-dispatch
Updated Branches:
  refs/heads/tross-DISPATCH-179-1 946a9e69b -> 2552cacf2


DISPATCH-179 - Filled in more missing function bodies.


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

Branch: refs/heads/tross-DISPATCH-179-1
Commit: 2552cacf20ae35c5807e034ffd6603cdadd28d22
Parents: 946a9e6
Author: Ted Ross <tr...@redhat.com>
Authored: Wed Oct 21 21:04:52 2015 -0400
Committer: Ted Ross <tr...@redhat.com>
Committed: Wed Oct 21 21:04:52 2015 -0400

----------------------------------------------------------------------
 src/router_core/route_tables.c | 63 ++++++++++++++++++++++++++++++++++---
 src/router_core/router_core.c  | 21 +++++++++++++
 2 files changed, 80 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/2552cacf/src/router_core/route_tables.c
----------------------------------------------------------------------
diff --git a/src/router_core/route_tables.c b/src/router_core/route_tables.c
index 137d0e6..e1095fb 100644
--- a/src/router_core/route_tables.c
+++ b/src/router_core/route_tables.c
@@ -178,6 +178,64 @@ void qdr_route_table_setup(qdr_core_t *core)
 }
 
 
+/**
+ * Check an address to see if it no longer has any associated destinations.
+ * Depending on its policy, the address may be eligible for being closed out
+ * (i.e. Logging its terminal statistics and freeing its resources).
+ */
+static void qdr_check_addr(qdr_core_t *core, qdr_address_t *addr, bool was_local)
+{
+    if (addr == 0)
+        return;
+
+    bool         to_delete      = false;
+    bool         no_more_locals = false;
+    qdr_field_t *key_field      = 0;
+
+    //
+    // If the address has no in-process consumer or destinations, it should be
+    // deleted.
+    //
+    if (addr->on_message == 0 &&
+        DEQ_SIZE(addr->rlinks) == 0 && DEQ_SIZE(addr->rnodes) == 0 &&
+        !addr->waypoint && !addr->block_deletion)
+        to_delete = true;
+
+    //
+    // If we have just removed a local linkage and it was the last local linkage,
+    // we need to notify the router module that there is no longer a local
+    // presence of this address.
+    //
+    if (was_local && DEQ_SIZE(addr->rlinks) == 0) {
+        no_more_locals = true;
+        const unsigned char *key = qd_hash_key_by_handle(addr->hash_handle);
+        if (key && (key[0] == 'M' || key[0] == 'C' || key[0] == 'D'))
+            key_field = qdr_field((const char*) key);
+    }
+
+    if (to_delete) {
+        //
+        // Delete the address but grab the hash key so we can use it outside the
+        // critical section.
+        //
+        qd_hash_remove_by_handle(core->addr_hash, addr->hash_handle);
+        DEQ_REMOVE(core->addrs, addr);
+        qd_hash_handle_free(addr->hash_handle);
+        free_qdr_address_t(addr);
+    }
+
+    //
+    // If the address is mobile-class and it was just removed from a local link,
+    // tell the router module that it is no longer attached locally.
+    //
+    if (no_more_locals && key_field) {
+        //
+        // TODO - Defer-call mobile-removed
+        //
+    }
+}
+
+
 static void qdrh_add_router(qdr_core_t *core, qdr_action_t *action)
 {
     int          router_maskbit = action->args.route_table.router_maskbit;
@@ -504,10 +562,7 @@ static void qdrh_unmap_destination(qdr_core_t *core, qdr_action_t *action)
         // TODO - If this affects a waypoint, create the proper side effects
         //
 
-        //
-        // TODO - Port "check-addr" into this module
-        //
-        //qd_router_check_addr(router, addr, 0);
+        qdr_check_addr(core, addr, false);
     } while (false);
 
     qdr_field_free(address);

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/2552cacf/src/router_core/router_core.c
----------------------------------------------------------------------
diff --git a/src/router_core/router_core.c b/src/router_core/router_core.c
index 0b94b4e..8f31b7a 100644
--- a/src/router_core/router_core.c
+++ b/src/router_core/router_core.c
@@ -24,6 +24,7 @@
 ALLOC_DEFINE(qdr_address_t);
 ALLOC_DEFINE(qdr_node_t);
 ALLOC_DEFINE(qdr_link_t);
+ALLOC_DEFINE(qdr_router_ref_t);
 ALLOC_DEFINE(qdr_link_ref_t);
 
 
@@ -155,15 +156,35 @@ void qdr_add_link_ref(qdr_link_ref_list_t *ref_list, qdr_link_t *link)
 
 void qdr_del_link_ref(qdr_link_ref_list_t *ref_list, qdr_link_t *link)
 {
+    if (link->ref) {
+        DEQ_REMOVE(*ref_list, link->ref);
+        free_qdr_link_ref_t(link->ref);
+        link->ref = 0;
+    }
 }
 
 
 void qdr_add_node_ref(qdr_router_ref_list_t *ref_list, qdr_node_t *rnode)
 {
+    qdr_router_ref_t *ref = new_qdr_router_ref_t();
+    DEQ_ITEM_INIT(ref);
+    ref->router = rnode;
+    rnode->ref_count++;
+    DEQ_INSERT_TAIL(*ref_list, ref);
 }
 
 
 void qdr_del_node_ref(qdr_router_ref_list_t *ref_list, qdr_node_t *rnode)
 {
+    qdr_router_ref_t *ref = DEQ_HEAD(*ref_list);
+    while (ref) {
+        if (ref->router == rnode) {
+            DEQ_REMOVE(*ref_list, ref);
+            free_qdr_router_ref_t(ref);
+            rnode->ref_count--;
+            break;
+        }
+        ref = DEQ_NEXT(ref);
+    }
 }
 


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