Skip to content

Commit

Permalink
fixup: renames and cleanups from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
kgiusti committed Dec 19, 2024
1 parent ecf7305 commit bdd42ab
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 36 deletions.
27 changes: 15 additions & 12 deletions include/qpid/dispatch/protocol_adaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,18 @@ qdr_connection_t *qdr_connection_opened(qdr_core_t *core,
void *bind_token);

/**
* qdr_connection_closed
* qdr_connection_notify_closed
*
* This function must be called when a connection is closed, either cleanly by protocol
* or uncleanly by lost connectivity. Once this function is called, the caller must never
* again refer to or use the connection pointer.
* This function is invoked by the adaptor to notify the core that the given connection has been closed. This must be
* called when a connection is closed, either cleanly by protocol or uncleanly by lost connectivity.
*
* This must be the last core API call made by the adaptor for this connection. The core thread will free the
* qdr_connection_t as a result of this call therefore the adaptor MUST NOT reference the qdr_connection_t on return
* from this call.
*
* @param conn The pointer returned by qdr_connection_opened
*/
void qdr_connection_closed(qdr_connection_t *conn);
void qdr_connection_notify_closed(qdr_connection_t *conn);

/**
* qdr_connection_set_tracing
Expand Down Expand Up @@ -816,19 +819,19 @@ void qdr_link_detach_received(qdr_link_t *link, qdr_error_t *error);


/**
* qdr_link_closed
* qdr_link_notify_closed
*
* This function is invoked by the adaptor when the link has fully closed. This will be the last call made by the
* adaptor for this link. This may be called as a result of a successful detach handshake or due to link loss. This will
* also be called during adaptor shutdown on any outstanding links.
* This function is invoked by the adaptor to notify the core that the given link has been closed. This must be called
* when the link is closed, either cleanly by protocol or uncleanly by lost connectivity (e.g. parent connection
* drop). This will also be called during adaptor shutdown on any outstanding links.
*
* The core may free the qdr_link_t by this call. The adaptor MUST NOT reference the qdr_link_t on return from this
* call.
* This must be the last core API call made by the adaptor for this link. The core thread will free the qdr_link_t as a
* result of this call therefore the adaptor MUST NOT reference the qdr_link_t on return from this call.
*
* @param link The link pointer returned by qdr_link_first_attach or in a FIRST_ATTACH event.
* @param forced True if the link was closed due to failure or shutdown. False if closed by clean detach handshake.
*/
void qdr_link_closed(qdr_link_t *link, bool forced);
void qdr_link_notify_closed(qdr_link_t *link, bool forced);


/**
Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/amqp/amqp_adaptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ static void AMQP_link_closed_handler(qd_router_t *router, qd_link_t *qd_link, bo
// Notify core that this link no longer exists
qdr_link_set_context(qdr_link, 0);
qd_link_set_context(qd_link, 0);
qdr_link_closed(qdr_link, forced);
qdr_link_notify_closed(qdr_link, forced);
// This will cause the core to free qdr_link at some point so:
qdr_link = 0;
}
Expand Down Expand Up @@ -1772,7 +1772,7 @@ static int AMQP_closed_handler(qd_router_t *router, qd_connection_t *conn, void
if (!!conn->listener && qdrc->role != QDR_ROLE_INTER_ROUTER_DATA) {
qd_listener_remove_link(conn->listener);
}
qdr_connection_closed(qdrc);
qdr_connection_notify_closed(qdrc);
qd_connection_set_context(conn, 0);
}

Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/amqp/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ static qd_link_t *setup_outgoing_link(qd_container_t *container, pn_link_t *pn_l
qd_session_incref(link->qd_session);

pn_link_set_context(pn_link, link);
container->ntype->outgoing_handler(container->qd_router, link);
container->ntype->outgoing_link_handler(container->qd_router, link);
return link;
}

Expand Down Expand Up @@ -212,7 +212,7 @@ static qd_link_t *setup_incoming_link(qd_container_t *container, pn_link_t *pn_l
pn_link_set_max_message_size(pn_link, max_size);
}
pn_link_set_context(pn_link, link);
container->ntype->incoming_handler(container->qd_router, link);
container->ntype->incoming_link_handler(container->qd_router, link);
return link;
}

Expand Down
8 changes: 4 additions & 4 deletions src/adaptors/amqp/node_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ struct qd_node_type_t {
/** Invoked when an existing delivery changes disposition or settlement state. */
qd_container_disposition_handler_t disp_handler;

/** Invoked when an attach for a new incoming link is received. */
qd_container_link_handler_t incoming_handler;
/** Invoked when an attach for a new incoming (receiving) link is received. */
qd_container_link_handler_t incoming_link_handler;

/** Invoked when an attach for a new outgoing link is received. */
qd_container_link_handler_t outgoing_handler;
/** Invoked when an attach for a new outgoing (sending) link is received. */
qd_container_link_handler_t outgoing_link_handler;

/** Invoked when an activated connection is available for writing. */
qd_container_conn_handler_t writable_handler;
Expand Down
14 changes: 7 additions & 7 deletions src/adaptors/tcp/tcp_adaptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ static void close_connection_XSIDE_IO(qd_tcp_connection_t *conn)
}

if (!!conn->inbound_link) {
qdr_link_closed(conn->inbound_link, true);
qdr_link_notify_closed(conn->inbound_link, true);
}

if (!!conn->outbound_delivery) {
Expand All @@ -638,7 +638,7 @@ static void close_connection_XSIDE_IO(qd_tcp_connection_t *conn)
}

if (!!conn->outbound_link) {
qdr_link_closed(conn->outbound_link, true);
qdr_link_notify_closed(conn->outbound_link, true);
}

if (conn->observer_handle) {
Expand All @@ -653,7 +653,7 @@ static void close_connection_XSIDE_IO(qd_tcp_connection_t *conn)
}

if (!!conn->core_conn) {
qdr_connection_closed(conn->core_conn);
qdr_connection_notify_closed(conn->core_conn);
conn->core_conn = 0;
qd_connection_counter_dec(QD_PROTOCOL_TCP);
}
Expand Down Expand Up @@ -2340,8 +2340,8 @@ static void CORE_connection_close(void *context, qdr_connection_t *conn, qdr_err
"[C%" PRIu64 "] qdr_tcp_conn_close: closing raw connection", tcp_conn->conn_id);
//
// Closing the raw connection (calling pn_raw_connection_close()) will generate a PN_RAW_CONNECTION_DISCONNECTED
// event which will call the handle_disconnected() which in turn calls qdr_connection_closed() which removes the
// connection from the list of connections.
// event which will call the handle_disconnected() which in turn calls qdr_connection_notify_closed() which
// removes the connection from the list of connections.
//
pn_raw_connection_close(tcp_conn->raw_conn);
}
Expand Down Expand Up @@ -2501,11 +2501,11 @@ QD_EXPORT void qd_dispatch_delete_tcp_connector(qd_dispatch_t *qd, void *impl)
//
if (!!connector->out_link) {
qdr_link_set_context(connector->out_link, 0);
qdr_link_closed(connector->out_link, true);
qdr_link_notify_closed(connector->out_link, true);
connector->out_link = 0;
}

qdr_connection_closed(connector->core_conn);
qdr_connection_notify_closed(connector->core_conn);
connector->core_conn = 0;
qd_connection_counter_dec(QD_PROTOCOL_TCP);
//
Expand Down
18 changes: 9 additions & 9 deletions src/router_core/connections.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
#include <strings.h>

static void qdr_connection_opened_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
static void qdr_connection_closed_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
static void qdr_connection_notify_closed_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
static void qdr_link_inbound_first_attach_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
static void qdr_link_inbound_second_attach_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
static void qdr_link_inbound_detach_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
static void qdr_link_closed_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
static void qdr_link_notify_closed_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
static void qdr_link_processing_complete_CT(qdr_core_t *core, qdr_action_t *action, bool discard);
static void qdr_link_processing_complete(qdr_core_t *core, qdr_link_t *link);
static void qdr_connection_group_cleanup_CT(qdr_core_t *core, qdr_connection_t *conn);
Expand Down Expand Up @@ -159,9 +159,9 @@ void qdr_connection_set_tracing(qdr_connection_t *conn, bool enable_protocol_tra
qdr_action_enqueue(conn->core, action);
}

void qdr_connection_closed(qdr_connection_t *conn)
void qdr_connection_notify_closed(qdr_connection_t *conn)
{
qdr_action_t *action = qdr_action(qdr_connection_closed_CT, "connection_closed");
qdr_action_t *action = qdr_action(qdr_connection_notify_closed_CT, "connection_notify_closed");
set_safe_ptr_qdr_connection_t(conn, &action->args.connection.conn);
qdr_action_enqueue(conn->core, action);
}
Expand Down Expand Up @@ -773,9 +773,9 @@ void qdr_link_detach_received(qdr_link_t *link, qdr_error_t *error)
}


void qdr_link_closed(qdr_link_t *link, bool forced)
void qdr_link_notify_closed(qdr_link_t *link, bool forced)
{
qdr_action_t *action = qdr_action(qdr_link_closed_CT, "link_closed");
qdr_action_t *action = qdr_action(qdr_link_notify_closed_CT, "link_notify_closed");

set_safe_ptr_qdr_link_t(link, &action->args.connection.link);
action->args.connection.forced_close = forced;
Expand Down Expand Up @@ -1770,7 +1770,7 @@ static void qdr_connection_set_tracing_CT(qdr_core_t *core, qdr_action_t *action
}


static void qdr_connection_closed_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
static void qdr_connection_notify_closed_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
{
qdr_connection_t *conn = safe_deref_qdr_connection_t(action->args.connection.conn);
if (discard || !conn)
Expand Down Expand Up @@ -2447,7 +2447,7 @@ static void qdr_link_inbound_detach_CT(qdr_core_t *core, qdr_action_t *action, b
}


static void qdr_link_closed_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
static void qdr_link_notify_closed_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
{
qdr_link_t *link = safe_deref_qdr_link_t(action->args.connection.link);
bool forced_close = action->args.connection.forced_close;
Expand All @@ -2466,7 +2466,7 @@ static void qdr_link_closed_CT(qdr_core_t *core, qdr_action_t *action, bool disc
}

qd_log(LOG_ROUTER_CORE, QD_LOG_DEBUG,
"[C%"PRIu64"][L%"PRIu64"] qdr_link_closed_CT(forced=%s) handle %s detach",
"[C%"PRIu64"][L%"PRIu64"] qdr_link_notify_closed_CT(forced=%s) handle %s detach",
link->conn->identity, link->identity, forced_close ? "YES" : "NO",
(link->state & QDR_LINK_STATE_DETACH_SENT) == 0 ? "first" : "second");

Expand Down

0 comments on commit bdd42ab

Please sign in to comment.