Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1709: Removed unused code from terminus.c to improve code cove… #1710

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions include/qpid/dispatch/protocol_adaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,16 +636,6 @@ void qdr_terminus_strip_address_prefix(qdr_terminus_t *term, const char *prefix)
*/
qd_iterator_t *qdr_terminus_dnp_address(qdr_terminus_t *term);

/**
* qdr_terminus_set_dnp_address_iterator
*
* Overwrite the dynamic-node-properties.address in the terminus
*
* @param term A qdr_terminus pointer returned by qdr_terminus()
* @param iter An iterator whose view shall be placed in the dnp.address
*/
void qdr_terminus_set_dnp_address_iterator(qdr_terminus_t *term, qd_iterator_t *iter);


/**
******************************************************************************
Expand Down
1 change: 0 additions & 1 deletion src/router_core/connections.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ qdr_link_t *qdr_link_first_attach(qdr_connection_t *conn,
link->oper_status = QDR_LINK_OPER_DOWN;
link->core_ticks = qdr_core_uptime_ticks(conn->core);
link->zero_credit_time = link->core_ticks;
link->terminus_survives_disconnect = qdr_terminus_survives_disconnect(local_terminus);
SET_ATOMIC_BOOL(&link->streaming_deliveries, dir == QD_INCOMING && qdr_terminus_has_capability(target, QD_CAPABILITY_STREAMING_DELIVERIES));
link->resend_released_deliveries = dir == QD_INCOMING && qdr_terminus_has_capability(target, QD_CAPABILITY_RESEND_RELEASED);
link->no_route = no_route;
Expand Down
1 change: 0 additions & 1 deletion src/router_core/router_core_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ struct qdr_link_t {
bool streaming; ///< True if this link can be reused for streaming msgs
bool in_streaming_pool; ///< True if this link is in the connections standby pool STREAMING_POOL
bool user_streaming; ///< True if this link can be used to transfer a stream (requested by the in-process attacher)
bool terminus_survives_disconnect;
bool resend_released_deliveries;
bool no_route; ///< True if this link is to not receive routed deliveries
bool no_route_bound; ///< Has the no_route link been bound ? Has the link's owning address been set for no_route links ?
Expand Down
90 changes: 0 additions & 90 deletions src/router_core/terminus.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,6 @@ bool qdr_terminus_is_dynamic(qdr_terminus_t *term)
return term->dynamic;
}

bool qdr_terminus_survives_disconnect(qdr_terminus_t *term)
{
return term->timeout > 0 || term->expiry_policy == PN_EXPIRE_NEVER;
}

void qdr_terminus_set_address(qdr_terminus_t *term, const char *addr)
{
Expand All @@ -303,89 +299,3 @@ qd_iterator_t *qdr_terminus_get_address(qdr_terminus_t *term)

return term->address->iterator;
}

void qdr_terminus_insert_address_prefix(qdr_terminus_t *term, const char *prefix)
{
qd_iterator_t *orig = qdr_terminus_get_address(term);
char *rewrite_addr = 0;

size_t prefix_len = strlen(prefix);
size_t orig_len = qd_iterator_length(orig);
rewrite_addr = malloc(prefix_len + orig_len + 1);
strcpy(rewrite_addr, prefix);
qd_iterator_strncpy(orig, rewrite_addr+prefix_len, orig_len + 1);

qdr_terminus_set_address(term, rewrite_addr);
free(rewrite_addr);
}

void qdr_terminus_strip_address_prefix(qdr_terminus_t *term, const char *prefix)
{
qd_iterator_t *orig = qdr_terminus_get_address(term);
size_t prefix_len = strlen(prefix);
size_t orig_len = qd_iterator_length(orig);
if (orig_len > prefix_len && qd_iterator_prefix(orig, prefix)) {
char *rewrite_addr = malloc(orig_len + 1);
qd_iterator_strncpy(orig, rewrite_addr, orig_len + 1);
qdr_terminus_set_address(term, rewrite_addr + prefix_len);
free(rewrite_addr);
}
}


qd_iterator_t *qdr_terminus_dnp_address(qdr_terminus_t *term)
{
pn_data_t *props = term->properties;
if (!props)
return 0;

pn_data_rewind(props);
if (pn_data_next(props) && pn_data_enter(props) && pn_data_next(props)) {
pn_bytes_t sym = pn_data_get_symbol(props);
if (sym.start && strcmp(QD_DYNAMIC_NODE_PROPERTY_ADDRESS, sym.start) == 0) {
if (pn_data_next(props)) {
pn_bytes_t val = pn_data_get_string(props);
if (val.start && *val.start != '\0')
return qd_iterator_binary(val.start, val.size, ITER_VIEW_ALL);
}
}
}

return 0;
}


void qdr_terminus_set_dnp_address_iterator(qdr_terminus_t *term, qd_iterator_t *iter)
{
char buffer[1001];
char *text = buffer;
bool on_heap = false;
pn_data_t *old = term->properties;
size_t len;

if (!old)
return;

if (qd_iterator_length(iter) < 1000) {
len = qd_iterator_ncopy(iter, (unsigned char*) text, 1000);
text[len] = '\0';
} else {
text = (char*) qd_iterator_copy(iter);
on_heap = true;
len = strlen(text);
}

pn_data_t *new = pn_data(pn_data_size(old));
pn_data_put_map(new);
pn_data_enter(new);
pn_data_put_symbol(new, pn_bytes(strlen(QD_DYNAMIC_NODE_PROPERTY_ADDRESS), QD_DYNAMIC_NODE_PROPERTY_ADDRESS));
pn_data_put_string(new, pn_bytes(len, text));
pn_data_exit(new);

term->properties = new;
pn_data_free(old);

if (on_heap)
free(text);
}

Loading