Skip to content

Commit

Permalink
Fixes skupperproject#1679: cleanup auto-link detach logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kgiusti committed Nov 25, 2024
1 parent 171c488 commit 2f6033d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
16 changes: 5 additions & 11 deletions src/router_core/connections.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,9 @@ void qdr_link_cleanup_deliveries_CT(qdr_core_t *core, qdr_connection_t *conn, qd

static void qdr_link_cleanup_CT(qdr_core_t *core, qdr_connection_t *conn, qdr_link_t *link, const char *log_text)
{
// expect: If this link is owned by an auto_link it should have been released during link detach cleanup
assert(link->auto_link == 0);

//
// Remove the link from the overall list of links and possibly the streaming
// link pool
Expand Down Expand Up @@ -2322,19 +2325,10 @@ static void qdr_link_inbound_detach_CT(qdr_core_t *core, qdr_action_t *action, b
}

//
// For auto links, switch the auto link to failed state and record the error
// Notify the auto-link that the link is coming down so a new link will be initiated.
//
if (link->auto_link) {
link->auto_link->link = 0;
link->auto_link->state = QDR_AUTO_LINK_STATE_FAILED;
free(link->auto_link->last_error);
link->auto_link->last_error = qdr_error_description(error);

//
// The auto link has failed. Periodically retry setting up the auto link until
// it succeeds.
//
qdr_route_auto_link_detached_CT(core, link);
qdr_route_auto_link_detached_CT(core, link, error);
}


Expand Down
11 changes: 10 additions & 1 deletion src/router_core/route_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,19 @@ static void qdr_auto_link_deactivate_CT(qdr_core_t *core, qdr_auto_link_t *al, q
}


void qdr_route_auto_link_detached_CT(qdr_core_t *core, qdr_link_t *link)
void qdr_route_auto_link_detached_CT(qdr_core_t *core, qdr_link_t *link, const qdr_error_t *error)
{
if (!link->auto_link)
return;

link->auto_link->state = QDR_AUTO_LINK_STATE_FAILED;

if (!link->auto_link->retry_timer)
link->auto_link->retry_timer = qdr_core_timer_CT(core, qdr_route_attempt_auto_link_CT, (void *)link->auto_link);

static char *activation_failed = "Auto Link Activation Failed. ";
free(link->auto_link->last_error);
link->auto_link->last_error = qdr_error_description(error);
int error_length = link->auto_link->last_error ? strlen(link->auto_link->last_error) : 0;
int total_length = strlen(activation_failed) + error_length + 1;

Expand All @@ -231,6 +235,11 @@ void qdr_route_auto_link_detached_CT(qdr_core_t *core, qdr_link_t *link)
}

qdr_route_log_CT(core, error_msg, link->auto_link->name, link->auto_link->identity, link->conn);

// link has detached and will be freed so drop all references

link->auto_link->link = 0;
link->auto_link = 0;
free(error_msg);
}

Expand Down
3 changes: 2 additions & 1 deletion src/router_core/route_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ void qdr_route_check_id_for_deletion_CT(qdr_core_t *core, qdr_conn_identifier_t
*
* @param core Pointer to the core object returned by qd_core()
* @param link qdr_link_t reference. The attach on this link for an auto link was rejected.
* @param error (optional) error information from the link detach performative
*/
void qdr_route_auto_link_detached_CT(qdr_core_t *core, qdr_link_t *link);
void qdr_route_auto_link_detached_CT(qdr_core_t *core, qdr_link_t *link, const qdr_error_t *error);

/**
* Performs actions that need to be taken when an auto link is closed.
Expand Down

0 comments on commit 2f6033d

Please sign in to comment.