Ensure that the delivery pointer isn't dereferenced after it is dec-ref'ed in case the dec-ref results in the freeing of the delivery.
@@ -1249,15 +1249,10 @@ static void qdr_deliver_continue_CT(qdr_core_t *core, qdr_action_t *action, bool
qdr_delivery_t *in_dlv = action->args.connection.delivery;
bool more = action->args.connection.more;
- // This decref is for the action reference
- qdr_delivery_decref_CT(core, in_dlv, "qdr_deliver_continue_CT - remove from action");
-
//
// If it is already in the undelivered list, don't try to deliver this again.
//
- if (in_dlv->where == QDR_DELIVERY_IN_UNDELIVERED)
- return;
-
+ if (in_dlv->where != QDR_DELIVERY_IN_UNDELIVERED) {
qdr_deliver_continue_peers_CT(core, in_dlv);
qd_message_t *msg = qdr_delivery_message(in_dlv);
@@ -1281,8 +1276,10 @@ static void qdr_deliver_continue_CT(qdr_core_t *core, qdr_action_t *action, bool
// If a delivery is settled but did not go into one of the lists, that means that it is going nowhere.
// We dont want to deal with such deliveries.
//
- if (in_dlv->settled && in_dlv->where == QDR_DELIVERY_NOWHERE)
+ if (in_dlv->settled && in_dlv->where == QDR_DELIVERY_NOWHERE) {
+ qdr_delivery_decref_CT(core, in_dlv, "qdr_deliver_continue_CT - remove from action 1");
return;
+ }
assert(in_dlv->where == QDR_DELIVERY_IN_SETTLED);
//
@@ -1311,6 +1308,10 @@ static void qdr_deliver_continue_CT(qdr_core_t *core, qdr_action_t *action, bool
}
}
+ // This decref is for the action reference
+ qdr_delivery_decref_CT(core, in_dlv, "qdr_deliver_continue_CT - remove from action 2");
+}
+
/**
* Add link-work to provide credit to the link in an IO thread
