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 2017/09/08 15:57:35 UTC

qpid-dispatch git commit: DISPATCH-779 - Issue credit for multicast address when no receiver is connected

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 9d0a684db -> ac9cd3d1c


DISPATCH-779 - Issue credit for multicast address when no receiver is connected

(cherry picked from commit 405229dcc8aecc87fbee94912405cd3852ac7f86)


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

Branch: refs/heads/master
Commit: ac9cd3d1ca45763c066c87fca15ee4481c9c1366
Parents: 9d0a684
Author: Ganesh Murthy <gm...@redhat.com>
Authored: Mon Jul 31 13:13:47 2017 -0400
Committer: Ganesh Murthy <gm...@redhat.com>
Committed: Fri Sep 8 11:54:00 2017 -0400

----------------------------------------------------------------------
 src/router_core/connections.c         |  8 +++-
 src/router_core/router_core_private.h |  2 +-
 src/router_core/transfer.c            | 18 ++++++--
 tests/system_tests_one_router.py      | 68 +++++++++++++++++++++++++++---
 4 files changed, 84 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ac9cd3d1/src/router_core/connections.c
----------------------------------------------------------------------
diff --git a/src/router_core/connections.c b/src/router_core/connections.c
index 42489bc..c3244dc 100644
--- a/src/router_core/connections.c
+++ b/src/router_core/connections.c
@@ -1414,10 +1414,14 @@ static void qdr_link_inbound_first_attach_CT(qdr_core_t *core, qdr_action_t *act
                     qdr_link_outbound_second_attach_CT(core, link, source, target);
 
                     //
-                    // Issue the initial credit only if there are destinations for the address.
+                    // Issue the initial credit only if there are destinations for the address or if the address treatment is multicast.
                     //
-                    if (DEQ_SIZE(addr->subscriptions) || DEQ_SIZE(addr->rlinks) || qd_bitmask_cardinality(addr->rnodes))
+                    if (DEQ_SIZE(addr->subscriptions)
+                            || DEQ_SIZE(addr->rlinks)
+                            || qd_bitmask_cardinality(addr->rnodes)
+                            || qdr_is_addr_treatment_multicast(addr)) {
                         qdr_link_issue_credit_CT(core, link, link->capacity, false);
+                    }
                 }
             }
             break;

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ac9cd3d1/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 b6fd6ea..3a4a9cb 100644
--- a/src/router_core/router_core_private.h
+++ b/src/router_core/router_core_private.h
@@ -734,7 +734,7 @@ void qdr_post_link_lost_CT(qdr_core_t *core, int link_maskbit);
 
 void qdr_post_general_work_CT(qdr_core_t *core, qdr_general_work_t *work);
 void qdr_check_addr_CT(qdr_core_t *core, qdr_address_t *addr, bool was_local);
-
+bool qdr_is_addr_treatment_multicast(qdr_address_t *addr);
 qdr_delivery_t *qdr_forward_new_delivery_CT(qdr_core_t *core, qdr_delivery_t *peer, qdr_link_t *link, qd_message_t *msg);
 void qdr_forward_deliver_CT(qdr_core_t *core, qdr_link_t *link, qdr_delivery_t *dlv);
 void qdr_connection_activate_CT(qdr_core_t *core, qdr_connection_t *conn);

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ac9cd3d1/src/router_core/transfer.c
----------------------------------------------------------------------
diff --git a/src/router_core/transfer.c b/src/router_core/transfer.c
index 4198262..ac8044d 100644
--- a/src/router_core/transfer.c
+++ b/src/router_core/transfer.c
@@ -729,16 +729,26 @@ static void qdr_link_forward_CT(qdr_core_t *core, qdr_link_t *link, qdr_delivery
     if (addr && addr == link->owning_addr && qdr_addr_path_count_CT(addr) == 0) {
         //
         // We are trying to forward a delivery on an address that has no outbound paths
-        // AND the incoming link is targeted (not anonymous).  In this case, we must put
-        // the delivery on the incoming link's undelivered list.  Note that it is safe
+        // AND the incoming link is targeted (not anonymous).
+
+        // If the owning_addr is a multicast addr and there are no outbound paths, we will release this delivery
+        // and replenish the credit.
+
+        // For non multicast addresses, put the delivery on the incoming link's undelivered list.  Note that it is safe
         // to do this because the undelivered list will be flushed once the number of
         // paths transitions from zero to one.
         //
         // Use the action-reference as the reference for undelivered rather
         // than decrementing and incrementing the delivery ref_count.
         //
-        DEQ_INSERT_TAIL(link->undelivered, dlv);
-        dlv->where = QDR_DELIVERY_IN_UNDELIVERED;
+        if (qdr_is_addr_treatment_multicast(link->owning_addr)) {
+            qdr_delivery_release_CT(core, dlv);
+            qdr_link_issue_credit_CT(core, link, 1, false);
+        }
+        else {
+            DEQ_INSERT_TAIL(link->undelivered, dlv);
+            dlv->where = QDR_DELIVERY_IN_UNDELIVERED;
+        }
         return;
     }
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/ac9cd3d1/tests/system_tests_one_router.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_one_router.py b/tests/system_tests_one_router.py
index 7ff5656..ba9ddbf 100644
--- a/tests/system_tests_one_router.py
+++ b/tests/system_tests_one_router.py
@@ -27,21 +27,21 @@ from qpid_dispatch.management.client import Node
 
 CONNECTION_PROPERTIES = {u'connection': u'properties', u'int_property': 6451}
 
-class RouterTest(TestCase):
+class OneRouterTest(TestCase):
     """System tests involving a single router"""
     @classmethod
     def setUpClass(cls):
         """Start a router and a messenger"""
-        super(RouterTest, cls).setUpClass()
+        super(OneRouterTest, cls).setUpClass()
         name = "test-router"
-        RouterTest.listen_port = cls.tester.get_port()
+        OneRouterTest.listen_port = cls.tester.get_port()
         config = Qdrouterd.Config([
             ('router', {'mode': 'standalone', 'id': 'QDR', 'allowUnsettledMulticast': 'yes'}),
 
             # Setting the stripAnnotations to 'no' so that the existing tests will work.
             # Setting stripAnnotations to no will not strip the annotations and any tests that were already in this file
             # that were expecting the annotations to not be stripped will continue working.
-            ('listener', {'port': RouterTest.listen_port, 'maxFrameSize': '2048', 'stripAnnotations': 'no'}),
+            ('listener', {'port': OneRouterTest.listen_port, 'maxFrameSize': '2048', 'stripAnnotations': 'no'}),
 
             # The following listeners were exclusively added to test the stripAnnotations attribute in qdrouterd.conf file
             # Different listeners will be used to test all allowed values of stripAnnotations ('no', 'both', 'out', 'in')
@@ -63,7 +63,7 @@ class RouterTest(TestCase):
         """Make sure a router exits if a initial listener fails, doesn't hang"""
         config = Qdrouterd.Config([
             ('router', {'mode': 'standalone', 'id': 'bad'}),
-            ('listener', {'port': RouterTest.listen_port})])
+            ('listener', {'port': OneRouterTest.listen_port})])
         r = Qdrouterd(name="expect_fail", config=config, wait=False)
         self.assertEqual(1, r.wait())
 
@@ -1106,6 +1106,11 @@ class RouterTest(TestCase):
     #    test.run()
     #    self.assertEqual(None, test.error)
 
+    def test_16a_multicast_no_receivcer(self):
+        test = MulticastUnsettledNoReceiverTest(self.address)
+        test.run()
+        self.assertEqual(None, test.error)
+
     def test_18_released_vs_modified(self):
         test = ReleasedVsModifiedTest(self.address)
         test.run()
@@ -1457,6 +1462,59 @@ class MultiframePresettledTest(MessagingHandler):
     def run(self):
         Container(self).run()
 
+class MulticastUnsettledNoReceiverTest(MessagingHandler):
+    """
+    Creates a sender to a multicast address. Router provides a credit of 'linkCapacity' to this sender even
+    if there are no receivers (The sender should be able to send messages to multicast addresses even when no receiver
+    is connected). The router will send a disposition of released back to the sender and will end up dropping
+    these messages since there is no receiver.
+    """
+    def __init__(self, address):
+        super(MulticastUnsettledNoReceiverTest, self).__init__(prefetch=0)
+        self.address = address
+        self.dest = "multicast.MulticastNoReceiverTest"
+        self.error = "Some error"
+        self.n_sent = 0
+        self.max_send = 250
+        self.n_released = 0
+        self.n_accepted = 0
+        self.timer = None
+        self.conn = None
+        self.sender = None
+
+    def check_if_done(self):
+        if self.n_accepted > 0:
+            self.error = "Messages should not be accepted as there are no receivers"
+            self.timer.cancel()
+            self.conn.close()
+        elif self.n_sent == self.n_released:
+            self.error = None
+            self.timer.cancel()
+            self.conn.close()
+
+    def on_start(self, event):
+        self.timer = event.reactor.schedule(TIMEOUT, Timeout(self))
+        self.conn = event.container.connect(self.address)
+        self.sender = event.container.create_sender(self.conn, self.dest)
+
+    def on_sendable(self, event):
+        if self.n_sent >= self.max_send:
+            return
+        self.n_sent += 1
+        msg = Message(body=self.n_sent)
+        event.sender.send(msg)
+
+    def on_accepted(self, event):
+        self.n_accepted += 1
+        self.check_if_done()
+
+    def on_released(self, event):
+        self.n_released += 1
+        self.check_if_done()
+
+    def run(self):
+        Container(self).run()
+
 
 class ReleasedVsModifiedTest(MessagingHandler):
     def __init__(self, address):


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