Skip to content

Commit

Permalink
fixup: remove response delay
Browse files Browse the repository at this point in the history
  • Loading branch information
kgiusti committed Nov 18, 2024
1 parent ce15355 commit e7d35ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 38 deletions.
10 changes: 0 additions & 10 deletions include/qpid/dispatch/ctools.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
38 changes: 10 additions & 28 deletions src/observers/http1/http1_observer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
*/
Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit e7d35ed

Please sign in to comment.