From e3d014c009553f8837be297c5ce446c3e9f5e254 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Wed, 12 Feb 2025 09:43:40 +0000 Subject: [PATCH] *) scoreboard/mod_http2: record durations of HTTP/2 requests. PR 69579 [Pierre Brochard ] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1923754 13f79535-47bb-0310-9956-ffa450edef68 --- changes-entries/pr69579.txt | 2 ++ include/ap_mmn.h | 3 ++- include/scoreboard.h | 4 +++- modules/http2/h2_mplx.c | 5 ++++- server/scoreboard.c | 16 ++++++++++++++++ 5 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 changes-entries/pr69579.txt diff --git a/changes-entries/pr69579.txt b/changes-entries/pr69579.txt new file mode 100644 index 00000000000..0b91a0da748 --- /dev/null +++ b/changes-entries/pr69579.txt @@ -0,0 +1,2 @@ + *) scoreboard/mod_http2: record durations of HTTP/2 requests. + PR 69579 [Pierre Brochard ] diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 18e5597e140..c9a0d2642ac 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -734,6 +734,7 @@ * 20211221.26 (2.5.1-dev) Add is_host_matchable to proxy_worker_shared * 20211221.27 (2.5.1-dev) Add sock_proto to proxy_worker_shared, and AP_LISTEN_MPTCP * 20211221.28 (2.5.1-dev) Add dav_get_base_path() to mod_dav + * 20211221.29 (2.5.1-dev) Add ap_set_time_process_request() to scoreboard.h */ #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */ @@ -741,7 +742,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20211221 #endif -#define MODULE_MAGIC_NUMBER_MINOR 28 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 29 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/scoreboard.h b/include/scoreboard.h index 25d19f03538..5870edfb920 100644 --- a/include/scoreboard.h +++ b/include/scoreboard.h @@ -197,7 +197,9 @@ AP_DECLARE(int) ap_update_child_status_from_server(ap_sb_handle_t *sbh, int stat AP_DECLARE(int) ap_update_child_status_descr(ap_sb_handle_t *sbh, int status, const char *descr); AP_DECLARE(void) ap_time_process_request(ap_sb_handle_t *sbh, int status); - +AP_DECLARE(void) ap_set_time_process_request(ap_sb_handle_t* const sbh, + const apr_time_t timebeg,const apr_time_t timeend); + AP_DECLARE(int) ap_update_global_status(void); AP_DECLARE(worker_score *) ap_get_scoreboard_worker(ap_sb_handle_t *sbh); diff --git a/modules/http2/h2_mplx.c b/modules/http2/h2_mplx.c index 39e9b1b001a..ddfe0473889 100644 --- a/modules/http2/h2_mplx.c +++ b/modules/http2/h2_mplx.c @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -975,7 +976,9 @@ static void s_c2_done(h2_mplx *m, conn_rec *c2, h2_conn_ctx_t *conn_ctx) /* From here on, the final handling of c2 is done by c1 processing. * Which means we can give it c1's scoreboard handle for updates. */ c2->sbh = m->c1->sbh; - +#if AP_MODULE_MAGIC_AT_LEAST(20211221, 29) + ap_set_time_process_request(c2->sbh,conn_ctx->started_at,conn_ctx->done_at); +#endif ap_log_cerror(APLOG_MARK, APLOG_TRACE2, 0, c2, "h2_mplx(%s-%d): request done, %f ms elapsed", conn_ctx->id, conn_ctx->stream_id, diff --git a/server/scoreboard.c b/server/scoreboard.c index a203e98f7bf..b4522fd9d08 100644 --- a/server/scoreboard.c +++ b/server/scoreboard.c @@ -654,6 +654,22 @@ AP_DECLARE(void) ap_time_process_request(ap_sb_handle_t *sbh, int status) } } +AP_DECLARE(void) ap_set_time_process_request(ap_sb_handle_t* const sbh, + const apr_time_t timebeg,const apr_time_t timeend) +{ + if (!sbh || sbh->child_num < 0) + return; + + worker_score* const ws = + &ap_scoreboard_image->servers[sbh->child_num][sbh->thread_num]; + + ws->start_time = timebeg; + ws->stop_time = ws->last_used = timeend; + + if (ap_extended_status) + ws->duration += timeend - timebeg; +} + AP_DECLARE(int) ap_update_global_status(void) { #ifdef HAVE_TIMES -- 2.47.3