You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kg...@apache.org on 2021/09/08 15:02:34 UTC

[qpid-dispatch] branch main updated: DISPATCH-2248: fix the dereference of a deliverys link work item

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

kgiusti 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 12c524d  DISPATCH-2248: fix the dereference of a deliverys link work item
12c524d is described below

commit 12c524d2bbef45a5846dbe742c790d0907d93df2
Author: Kenneth Giusti <kg...@apache.org>
AuthorDate: Tue Sep 7 17:22:49 2021 -0400

    DISPATCH-2248: fix the dereference of a deliverys link work item
    
    This closes #1364
---
 src/router_core/forwarder.c |  7 +++----
 src/router_core/transfer.c  | 11 +++++------
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/router_core/forwarder.c b/src/router_core/forwarder.c
index 49099c3..642b4cd 100644
--- a/src/router_core/forwarder.c
+++ b/src/router_core/forwarder.c
@@ -229,13 +229,12 @@ static void qdr_forward_drop_presettled_CT_LH(qdr_core_t *core, qdr_link_t *link
             // has no other deliveries associated with it, it can be removed
             // from the work list.
             //
-            assert(dlv->link_work);
-            if (dlv->link_work && (--dlv->link_work->value == 0)) {
+            if (--dlv->link_work->value == 0) {
                 DEQ_REMOVE(link->work_list, dlv->link_work);
                 qdr_link_work_release(dlv->link_work); // for work_list
-                qdr_link_work_release(dlv->link_work); // for dlv ref
-                dlv->link_work = 0;
             }
+            qdr_link_work_release(dlv->link_work); // for dlv ref
+            dlv->link_work = 0;
             dlv->disposition = PN_RELEASED;
             qdr_delivery_decref_CT(core, dlv, "qdr_forward_drop_presettled_CT_LH - remove from link-work list");
 
diff --git a/src/router_core/transfer.c b/src/router_core/transfer.c
index 39f2d59..1996124 100644
--- a/src/router_core/transfer.c
+++ b/src/router_core/transfer.c
@@ -300,16 +300,15 @@ void qdr_link_complete_sent_message(qdr_core_t *core, qdr_link_t *link)
     if (!!dlv && qdr_delivery_send_complete(dlv)) {
         DEQ_REMOVE_HEAD(link->undelivered);
         if (dlv->link_work) {
-            assert(dlv->link_work == link->work_list.head);
+            // ensure deliveries are sent in order:
+            assert(dlv->link_work == DEQ_HEAD(link->work_list));
             assert(dlv->link_work->value > 0);
-            dlv->link_work->value -= 1;
-
-            if (dlv->link_work->value == 0) {
+            if (--dlv->link_work->value == 0) {
                 DEQ_REMOVE_HEAD(link->work_list);
                 qdr_link_work_release(dlv->link_work);  // for work_list ref
-                qdr_link_work_release(dlv->link_work);  // for dlv ref
-                dlv->link_work = 0;
             }
+            qdr_link_work_release(dlv->link_work);  // for dlv ref
+            dlv->link_work = 0;
         }
 
         if (!dlv->settled && !qdr_delivery_oversize(dlv) && !qdr_delivery_is_aborted(dlv)) {

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