From e7d35ededf173062826f815016bfc6f256520798 Mon Sep 17 00:00:00 2001 From: Kenneth Giusti Date: Mon, 18 Nov 2024 13:26:03 -0500 Subject: [PATCH] fixup: remove response delay --- include/qpid/dispatch/ctools.h | 10 -------- src/observers/http1/http1_observer.c | 38 ++++++++-------------------- 2 files changed, 10 insertions(+), 38 deletions(-) diff --git a/include/qpid/dispatch/ctools.h b/include/qpid/dispatch/ctools.h index fc6cc1665..18d60d5c4 100644 --- a/include/qpid/dispatch/ctools.h +++ b/include/qpid/dispatch/ctools.h @@ -262,15 +262,5 @@ static inline char *qd_strdup(const char *s) return ptr; } -static inline char *qd_strndup(const char *s, size_t n) -{ - assert(s); - char *ptr = strndup(s, n); - if (!ptr) { - perror("qd_strndup"); - abort(); - } - return ptr; -} #endif diff --git a/src/observers/http1/http1_observer.c b/src/observers/http1/http1_observer.c index 42cf80634..64fc6a5fc 100644 --- a/src/observers/http1/http1_observer.c +++ b/src/observers/http1/http1_observer.c @@ -27,8 +27,6 @@ struct http1_request_state_t { DEQ_LINKS(http1_request_state_t); vflow_record_t *vflow; - char *response_phrase; // reason phrase in response msg - int response_status; // result code in response msg uint64_t client_body_octets; // total bytes received in client request msg body uint64_t server_body_octets; // total bytes received in server response msg body bool latency_done:1; // true: vflow latency timing complete @@ -37,18 +35,6 @@ ALLOC_DECLARE(http1_request_state_t); ALLOC_DEFINE(http1_request_state_t); -static void http1_request_state_free(http1_request_state_t *hreq) -{ - if (hreq) { - if (hreq->vflow) { - vflow_end_record(hreq->vflow); - } - free(hreq->response_phrase); - free_http1_request_state_t(hreq); - } -} - - /* * HTTP/1.x decoder callbacks */ @@ -102,11 +88,10 @@ static int rx_response(qd_http1_decoder_connection_t *hconn, uintptr_t request_c } if (status_code / 100 != 1) { // terminal response code - hreq->response_status = status_code; - if (reason_phrase) { - assert(!hreq->response_phrase); - hreq->response_phrase = qd_strndup(reason_phrase, 256); - } + char status_code_str[16]; + snprintf(status_code_str, sizeof(status_code_str), "%d", status_code); + vflow_set_string(hreq->vflow, VFLOW_ATTRIBUTE_RESULT, status_code_str); + vflow_set_string(hreq->vflow, VFLOW_ATTRIBUTE_REASON, reason_phrase); } return 0; @@ -132,7 +117,6 @@ static int rx_body(qd_http1_decoder_connection_t *hconn, uintptr_t request_conte static int transaction_complete(qd_http1_decoder_connection_t *hconn, uintptr_t request_context) { - char status_code_str[16]; qdpo_transport_handle_t *th = (qdpo_transport_handle_t *) qd_http1_decoder_connection_get_context(hconn); assert(th); @@ -141,14 +125,9 @@ static int transaction_complete(qd_http1_decoder_connection_t *hconn, uintptr_t http1_request_state_t *hreq = (http1_request_state_t *) request_context; assert(hreq); - snprintf(status_code_str, sizeof(status_code_str), "%d", hreq->response_status); - vflow_set_string(hreq->vflow, VFLOW_ATTRIBUTE_RESULT, status_code_str); - if (hreq->response_phrase) - vflow_set_string(hreq->vflow, VFLOW_ATTRIBUTE_REASON, hreq->response_phrase); - - DEQ_REMOVE(th->http1.requests, hreq); - http1_request_state_free(hreq); + vflow_end_record(hreq->vflow); + free_http1_request_state_t(hreq); return 0; } @@ -224,7 +203,10 @@ void qdpo_http1_final(qdpo_transport_handle_t *th) http1_request_state_t *hreq = DEQ_HEAD(th->http1.requests); while (hreq) { DEQ_REMOVE_HEAD(th->http1.requests); - http1_request_state_free(hreq); + if (hreq->vflow) { + vflow_end_record(hreq->vflow); + } + free_http1_request_state_t(hreq); hreq = DEQ_HEAD(th->http1.requests); }