prevent early free of qdr_address_t on link detach
This closes
@@ -1949,8 +1949,6 @@ static void qdr_link_inbound_detach_CT(qdr_core_t *core, qdr_action_t *action, b
return;
}
- qdr_address_t *addr = link->owning_addr;
-
if (link->detach_received)
return;
@@ -1960,8 +1958,7 @@ static void qdr_link_inbound_detach_CT(qdr_core_t *core, qdr_action_t *action, b
if (link->core_endpoint) {
qdrc_endpoint_do_detach_CT(core, link->core_endpoint, error, dt);
return;
-
- } else {
+ }
//
// ensure a pooled link is no longer available for use
@@ -2017,6 +2014,12 @@ static void qdr_link_inbound_detach_CT(qdr_core_t *core, qdr_action_t *action, b
qdr_route_auto_link_detached_CT(core, link);
}
+
+
+ qdr_address_t *addr = link->owning_addr;
+ if (addr)
+ addr->ref_count++;
+
if (link->link_direction == QD_INCOMING) {
qdrc_event_link_raise(core, QDRC_EVENT_LINK_IN_DETACHED, link);
//
@@ -2033,9 +2036,7 @@ static void qdr_link_inbound_detach_CT(qdr_core_t *core, qdr_action_t *action, b
//
// Unbind the address and the link.
//
- addr->ref_count++;
qdr_core_unbind_address_link_CT(core, addr, link);
- addr->ref_count--;
//
// If this is an edge data link, raise a link event to indicate its detachment.
@@ -2063,9 +2064,7 @@ static void qdr_link_inbound_detach_CT(qdr_core_t *core, qdr_action_t *action, b
case QD_LINK_ENDPOINT:
case QD_LINK_EDGE_DOWNLINK:
if (addr) {
- addr->ref_count++;
qdr_core_unbind_address_link_CT(core, addr, link);
- addr->ref_count--;
}
break;
@@ -2078,7 +2077,6 @@ static void qdr_link_inbound_detach_CT(qdr_core_t *core, qdr_action_t *action, b
break;
}
}
- }
link->owning_addr = 0;
@@ -2107,8 +2105,10 @@ static void qdr_link_inbound_detach_CT(qdr_core_t *core, qdr_action_t *action, b
// If there was an address associated with this link, check to see if any address-related
// cleanup has to be done.
//
- if (addr)
+ if (addr) {
+ addr->ref_count--;
qdr_check_addr_CT(core, addr);
+ }
if (error)
qdr_error_free(error);
