This is an automated email from the ASF dual-hosted git repository. tross pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/main by this push: new 5dfa37b DISPATCH-2301 - Added facility for annotating new messages. Invoked this facility from the TCP, HTTP1, and HTTP2 adaptors. 5dfa37b is described below commit 5dfa37b47717caac1f66862d8f9b07b0398c5f28 Author: Ted Ross <tr...@apache.org> AuthorDate: Wed Dec 22 14:08:07 2021 -0500 DISPATCH-2301 - Added facility for annotating new messages. Invoked this facility from the TCP, HTTP1, and HTTP2 adaptors. --- include/qpid/dispatch/protocol_adaptor.h | 11 +++++++++++ src/adaptors/http1/http1_client.c | 1 + src/adaptors/http2/http2_adaptor.c | 1 + src/adaptors/tcp_adaptor.c | 1 + src/router_core/transfer.c | 17 +++++++++++++++++ 5 files changed, 31 insertions(+) diff --git a/include/qpid/dispatch/protocol_adaptor.h b/include/qpid/dispatch/protocol_adaptor.h index 00551c2..a384d3e 100644 --- a/include/qpid/dispatch/protocol_adaptor.h +++ b/include/qpid/dispatch/protocol_adaptor.h @@ -835,6 +835,17 @@ void qdr_link_detach(qdr_link_t *link, qd_detach_type_t dt, qdr_error_t *error); void qdr_link_delete(qdr_link_t *link); /** + * qdr_new_message_annotate + * + * Annotate a newly originated message prior to transmission. This function adds the annotations + * for ORIGIN and TRACE as well as any other needed pre-send annotations. + * + * @param core Pointer to the core object. + * @param msg Pointer to the message to be annotated. + */ +void qdr_new_message_annotate(qdr_core_t *core, qd_message_t *msg); + +/** * qdr_link_deliver * * Deliver a message to the router core for forwarding. This function is used in cases where diff --git a/src/adaptors/http1/http1_client.c b/src/adaptors/http1/http1_client.c index 938b63f..33d75c0 100644 --- a/src/adaptors/http1/http1_client.c +++ b/src/adaptors/http1/http1_client.c @@ -880,6 +880,7 @@ static int _client_rx_headers_done_cb(h1_codec_request_state_t *hrs, bool has_bo hreq->request_msg = qd_message(); qd_message_set_stream_annotation(hreq->request_msg, hreq->expect_continue); + qdr_new_message_annotate(hreq->base.hconn->adaptor->core, hreq->request_msg); qd_composed_field_t *hdrs = qd_compose(QD_PERFORMATIVE_HEADER, 0); qd_compose_start_list(hdrs); diff --git a/src/adaptors/http2/http2_adaptor.c b/src/adaptors/http2/http2_adaptor.c index 4906e95..cdcbbc7 100644 --- a/src/adaptors/http2/http2_adaptor.c +++ b/src/adaptors/http2/http2_adaptor.c @@ -477,6 +477,7 @@ static qdr_http2_stream_data_t *create_http2_stream_data(qdr_http2_connection_t stream_data->message = qd_message(); qd_message_set_stream_annotation(stream_data->message, true); + qdr_new_message_annotate(http2_adaptor->core, stream_data->message); stream_data->conn = conn; stream_data->app_properties = qd_compose(QD_PERFORMATIVE_APPLICATION_PROPERTIES, 0); stream_data->status = QD_STREAM_OPEN; diff --git a/src/adaptors/tcp_adaptor.c b/src/adaptors/tcp_adaptor.c index 214586b..2b8d109 100644 --- a/src/adaptors/tcp_adaptor.c +++ b/src/adaptors/tcp_adaptor.c @@ -329,6 +329,7 @@ static int handle_incoming(qdr_tcp_connection_t *conn, const char *msg) qd_message_t *msg = qd_message(); qd_message_set_stream_annotation(msg, true); + qdr_new_message_annotate(tcp_adaptor->core, msg); qd_composed_field_t *props = qd_compose(QD_PERFORMATIVE_PROPERTIES, 0); qd_compose_start_list(props); diff --git a/src/router_core/transfer.c b/src/router_core/transfer.c index 1996124..d3edd38 100644 --- a/src/router_core/transfer.c +++ b/src/router_core/transfer.c @@ -38,6 +38,23 @@ static void qdr_send_to_CT(qdr_core_t *core, qdr_action_t *action, bool discard) // Interface Functions //================================================================================== +void qdr_new_message_annotate(qdr_core_t *core, qd_message_t *msg) +{ + if (core->router_mode != QD_ROUTER_MODE_EDGE) { + qd_composed_field_t *ingress = qd_compose_subfield(0); + qd_compose_insert_string(ingress, qd_router_id(core->qd)); + + qd_composed_field_t *trace = qd_compose_subfield(0); + qd_compose_start_list(trace); + qd_compose_insert_string(trace, qd_router_id(core->qd)); + qd_compose_end_list(trace); + + qd_message_set_ingress_annotation(msg, ingress); + qd_message_set_trace_annotation(msg, trace); + } +} + + qdr_delivery_t *qdr_link_deliver(qdr_link_t *link, qd_message_t *msg, qd_iterator_t *ingress, bool settled, qd_bitmask_t *link_exclusion, int ingress_index, uint64_t remote_disposition, --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org