This is an automated email from the ASF dual-hosted git repository. kgiusti 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 fc9c438 DISPATCH-1418: use proper outcome for deliveries to unavailable addresses fc9c438 is described below commit fc9c4380d796656ad964e04bb389d3223d94b1c5 Author: Kenneth Giusti <kgiu...@apache.org> AuthorDate: Wed Oct 2 15:06:23 2019 -0400 DISPATCH-1418: use proper outcome for deliveries to unavailable addresses Use the configured address treatment if available. Otherwise use the router default treatment. This closes #579 --- src/router_core/transfer.c | 74 +++++++++++++++++++++++---------------- tests/system_tests_router_mesh.py | 5 ++- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/src/router_core/transfer.c b/src/router_core/transfer.c index 17067c4..6ee2624 100644 --- a/src/router_core/transfer.c +++ b/src/router_core/transfer.c @@ -477,43 +477,55 @@ static void qdr_link_forward_CT(qdr_core_t *core, qdr_link_t *link, qdr_delivery } link->total_deliveries++; - } - // - // There is no address that we can send this delivery to, which means the addr was not found in our hash table. This - // can be because there were no receivers or because the address was not defined in the config file. - // - else if (core->qd->default_treatment == QD_TREATMENT_UNAVAILABLE) { + } else { // - // If the treatment for these addresses is set to be unavailable, we - // stop trying to forward it. If the link is a locally attached client - // we reject the message if the link is not anonymous as per the - // documentation of the router's defaultTreatment=unavailable. We - // simply release it for other link types as the message did have a - // destination at some point (it was forwarded to this router after - // all) - the loss of the destination may be temporary. + // There is no address that we can send this delivery to, which means + // the addr was not found in our hash table. This can be because there + // were no receivers or because the address was not defined in the + // config file. // - if (link->link_type == QD_LINK_ENDPOINT) { - dlv->error = qdr_error(QD_AMQP_COND_NOT_FOUND, "Deliveries cannot be sent to an unavailable address"); - qdr_delivery_reject_CT(core, dlv); - if (qdr_link_is_anonymous(link)) { - qdr_link_issue_credit_CT(core, link, 1, false); + + qd_address_treatment_t trt = core->qd->default_treatment; + if (dlv->to_addr) { + qdr_address_config_t *ignore = 0; + trt = qdr_treatment_for_address_hash_with_default_CT(core, + dlv->to_addr, + trt, + &ignore); + } + + if (trt == QD_TREATMENT_UNAVAILABLE) { + // + // The treatment for these addresses is set to be unavailable, we + // stop trying to forward it. If the link is a locally attached client + // we reject the message if the link is not anonymous as per the + // documentation of the router's defaultTreatment=unavailable. We + // simply release it for other link types as the message did have a + // destination at some point (it was forwarded to this router after + // all) - the loss of the destination may be temporary. + // + if (link->link_type == QD_LINK_ENDPOINT) { + dlv->error = qdr_error(QD_AMQP_COND_NOT_FOUND, "Deliveries cannot be sent to an unavailable address"); + qdr_delivery_reject_CT(core, dlv); + if (qdr_link_is_anonymous(link)) { + qdr_link_issue_credit_CT(core, link, 1, false); + } else { + // cannot forward on this targeted link. withhold credit and drain + qdr_link_issue_credit_CT(core, link, 0, true); + } } else { - // cannot forward on this targeted link. withhold credit and drain - qdr_link_issue_credit_CT(core, link, 0, true); + qdr_delivery_release_CT(core, dlv); + qdr_link_issue_credit_CT(core, link, 1, false); } - } else { - qdr_delivery_release_CT(core, dlv); - qdr_link_issue_credit_CT(core, link, 1, false); + // + // We will not detach this link because this could be anonymous sender. We don't know + // which address the sender will be sending to next + // If this was not an anonymous sender, the initial attach would have been rejected if the target address was unavailable. + // + qdr_delivery_decref_CT(core, dlv, "qdr_link_forward_CT - removed from action (treatment unavailable)"); + return; } - - // - // We will not detach this link because this could be anonymous sender. We don't know - // which address the sender will be sending to next - // If this was not an anonymous sender, the initial attach would have been rejected if the target address was unavailable. - // - qdr_delivery_decref_CT(core, dlv, "qdr_link_forward_CT - removed from action (treatment unavailable)"); - return; } // diff --git a/tests/system_tests_router_mesh.py b/tests/system_tests_router_mesh.py index fad0600..60b2408 100644 --- a/tests/system_tests_router_mesh.py +++ b/tests/system_tests_router_mesh.py @@ -206,9 +206,8 @@ class ThreeRouterTest(TestCase): message=message) ats.wait() self.assertEqual(0, ats.accepted) - # BUG DISPATCH-1418: shold be released! - # self.assertEqual(1, ats.released) - self.assertEqual(1, ats.rejected) + self.assertEqual(1, ats.released) + self.assertEqual(0, ats.rejected) if __name__ == '__main__': --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org