Index: server/config.c =================================================================== --- server/config.c (revision 155552) +++ server/config.c (working copy) @@ -366,7 +366,9 @@ r->handler = handler; } + AP_SET_REQUEST_PHASE(r, AP_REQUEST_HANDLER_PHASE); result = ap_run_handler(r); + AP_CLEAR_REQUEST_PHASE(r); r->handler = old_handler; Index: server/protocol.c =================================================================== --- server/protocol.c (revision 155552) +++ server/protocol.c (working copy) @@ -855,7 +855,9 @@ r->output_filters = r->proto_output_filters; r->proto_input_filters = conn->input_filters; r->input_filters = r->proto_input_filters; + AP_SET_REQUEST_PHASE(r, AP_CREATE_REQUEST_PHASE); ap_run_create_request(r); + AP_CLEAR_REQUEST_PHASE(r); r->per_dir_config = r->server->lookup_defaults; r->sent_bodyct = 0; /* bytect isn't for body */ @@ -951,7 +953,10 @@ return r; } - if ((access_status = ap_run_post_read_request(r))) { + AP_SET_REQUEST_PHASE(r, AP_POST_READ_REQUEST_PHASE); + access_status = ap_run_post_read_request(r); + AP_CLEAR_REQUEST_PHASE(r); + if (access_status) { ap_die(access_status, r); ap_update_child_status(conn->sbh, SERVER_BUSY_LOG, r); ap_run_log_transaction(r); Index: server/scoreboard.c =================================================================== --- server/scoreboard.c (revision 155552) +++ server/scoreboard.c (working copy) @@ -449,6 +449,21 @@ status, r); } +#ifdef AP_TRACK_REQUEST_PHASE +AP_DECLARE(void) ap_set_request_phase(request_rec *r, int phase) +{ + ap_sb_handle_t *sbh = (ap_sb_handle_t *)r->connection->sbh; + worker_score *ws = &ap_scoreboard_image->servers[sbh->child_num][sbh->thread_num]; + + ws->request_phase = phase; +} + +AP_DECLARE(void) ap_clear_request_phase(request_rec *r) +{ + ap_set_request_phase(r, 0); +} +#endif + void ap_time_process_request(ap_sb_handle_t *sbh, int status) { worker_score *ws; Index: server/request.c =================================================================== --- server/request.c (revision 155552) +++ server/request.c (working copy) @@ -43,6 +43,7 @@ #include "util_filter.h" #include "util_charset.h" #include "util_script.h" +#include "scoreboard.h" #include "mod_core.h" @@ -137,7 +138,10 @@ return access_status; } - if ((access_status = ap_run_translate_name(r))) { + AP_SET_REQUEST_PHASE(r, AP_TRANSLATE_NAME_PHASE); + access_status = ap_run_translate_name(r); + AP_CLEAR_REQUEST_PHASE(r); + if (access_status) { return decl_die(access_status, "translate", r); } } @@ -146,7 +150,10 @@ */ r->per_dir_config = r->server->lookup_defaults; - if ((access_status = ap_run_map_to_storage(r))) { + AP_SET_REQUEST_PHASE(r, AP_MAP_TO_STORAGE_PHASE); + access_status = ap_run_map_to_storage(r); + AP_CLEAR_REQUEST_PHASE(r); + if (access_status) { /* This request wasn't in storage (e.g. TRACE) */ return access_status; } @@ -163,7 +170,10 @@ /* Only on the main request! */ if (r->main == NULL) { - if ((access_status = ap_run_header_parser(r))) { + AP_SET_REQUEST_PHASE(r, AP_HEADER_PARSER_PHASE); + access_status = ap_run_header_parser(r); + AP_CLEAR_REQUEST_PHASE(r); + if (access_status) { return access_status; } } @@ -185,12 +195,18 @@ switch (ap_satisfies(r)) { case SATISFY_ALL: case SATISFY_NOSPEC: - if ((access_status = ap_run_access_checker(r)) != 0) { + AP_SET_REQUEST_PHASE(r, AP_ACCESS_CHECKER_PHASE); + access_status = ap_run_access_checker(r); + AP_CLEAR_REQUEST_PHASE(r); + if (access_status != 0) { return decl_die(access_status, "check access", r); } if (ap_some_auth_required(r)) { - if (((access_status = ap_run_check_user_id(r)) != 0) + AP_SET_REQUEST_PHASE(r, AP_CHECK_USER_ID_PHASE); + access_status = ap_run_check_user_id(r); + AP_CLEAR_REQUEST_PHASE(r); + if ((access_status != 0) || !ap_auth_type(r)) { return decl_die(access_status, ap_auth_type(r) ? "check user. No user file?" @@ -198,7 +214,10 @@ r); } - if (((access_status = ap_run_auth_checker(r)) != 0) + AP_SET_REQUEST_PHASE(r, AP_AUTH_CHECKER_PHASE); + access_status = ap_run_auth_checker(r); + AP_CLEAR_REQUEST_PHASE(r); + if ((access_status != 0) || !ap_auth_type(r)) { return decl_die(access_status, ap_auth_type(r) ? "check access. No groups file?" @@ -209,12 +228,18 @@ break; case SATISFY_ANY: - if (((access_status = ap_run_access_checker(r)) != 0)) { + AP_SET_REQUEST_PHASE(r, AP_ACCESS_CHECKER_PHASE); + access_status = ap_run_access_checker(r); + AP_CLEAR_REQUEST_PHASE(r); + if ((access_status != 0)) { if (!ap_some_auth_required(r)) { return decl_die(access_status, "check access", r); } - if (((access_status = ap_run_check_user_id(r)) != 0) + AP_SET_REQUEST_PHASE(r, AP_CHECK_USER_ID_PHASE); + access_status = ap_run_check_user_id(r); + AP_CLEAR_REQUEST_PHASE(r); + if ((access_status != 0) || !ap_auth_type(r)) { return decl_die(access_status, ap_auth_type(r) ? "check user. No user file?" @@ -222,7 +247,10 @@ r); } - if (((access_status = ap_run_auth_checker(r)) != 0) + AP_SET_REQUEST_PHASE(r, AP_AUTH_CHECKER_PHASE); + access_status = ap_run_auth_checker(r); + AP_CLEAR_REQUEST_PHASE(r); + if ((access_status != 0) || !ap_auth_type(r)) { return decl_die(access_status, ap_auth_type(r) ? "check access. No groups file?" @@ -237,11 +265,17 @@ * in mod-proxy for r->proxyreq && r->parsed_uri.scheme * && !strcmp(r->parsed_uri.scheme, "http") */ - if ((access_status = ap_run_type_checker(r)) != 0) { + AP_SET_REQUEST_PHASE(r, AP_TYPE_CHECKER_PHASE); + access_status = ap_run_type_checker(r); + AP_CLEAR_REQUEST_PHASE(r); + if (access_status != 0) { return decl_die(access_status, "find types", r); } - if ((access_status = ap_run_fixups(r)) != 0) { + AP_SET_REQUEST_PHASE(r, AP_FIXUPS_PHASE); + access_status = ap_run_fixups(r); + AP_CLEAR_REQUEST_PHASE(r); + if (access_status != 0) { return access_status; } @@ -1529,7 +1563,9 @@ /* We have to run this after we fill in sub req vars, * or the r->main pointer won't be setup */ + AP_SET_REQUEST_PHASE(rnew, AP_CREATE_REQUEST_PHASE); ap_run_create_request(rnew); + AP_CLEAR_REQUEST_PHASE(rnew); return rnew; } @@ -1610,7 +1646,9 @@ * If the content can be served by the quick_handler, we can * safely bypass request_internal processing. */ + AP_SET_REQUEST_PHASE(rnew, AP_QUICK_HANDLER_PHASE); res = ap_run_quick_handler(rnew, 1); + AP_CLEAR_REQUEST_PHASE(rnew); if (res != OK) { if ((res = ap_process_request_internal(rnew))) { Index: modules/http/http_protocol.c =================================================================== --- modules/http/http_protocol.c (revision 155552) +++ modules/http/http_protocol.c (working copy) @@ -48,6 +48,7 @@ #include "util_charset.h" #include "util_ebcdic.h" #include "util_time.h" +#include "scoreboard.h" #include "mod_core.h" @@ -1109,7 +1110,9 @@ r->output_filters = r->proto_output_filters; + AP_SET_REQUEST_PHASE(r, AP_INSERT_ERROR_FILTER_PHASE); ap_run_insert_error_filter(r); + AP_CLEAR_REQUEST_PHASE(r); /* * It's possible that the Location field might be in r->err_headers_out Index: modules/http/http_request.c =================================================================== --- modules/http/http_request.c (revision 155552) +++ modules/http/http_request.c (working copy) @@ -251,7 +251,9 @@ */ if (ap_extended_status) ap_time_process_request(r->connection->sbh, START_PREQUEST); + AP_SET_REQUEST_PHASE(r, AP_QUICK_HANDLER_PHASE); access_status = ap_run_quick_handler(r, 0); /* Not a look-up request */ + AP_CLEAR_REQUEST_PHASE(r); if (access_status == DECLINED) { access_status = ap_process_request_internal(r); if (access_status == OK) { @@ -339,7 +341,9 @@ /* Must have prev and next pointers set before calling create_request * hook. */ + AP_SET_REQUEST_PHASE(new, AP_CREATE_REQUEST_PHASE); ap_run_create_request(new); + AP_CLEAR_REQUEST_PHASE(new); /* Inherit the rest of the protocol info... */ @@ -396,7 +400,10 @@ * to do their thing on internal redirects as well. Perhaps this is a * misnamed function. */ - if ((access_status = ap_run_post_read_request(new))) { + AP_SET_REQUEST_PHASE(new, AP_POST_READ_REQUEST_PHASE); + access_status = ap_run_post_read_request(new); + AP_CLEAR_REQUEST_PHASE(new); + if (access_status) { ap_die(access_status, new); return NULL; } @@ -469,7 +476,9 @@ return; } + AP_SET_REQUEST_PHASE(new, AP_QUICK_HANDLER_PHASE); access_status = ap_run_quick_handler(new, 0); /* Not a look-up request */ + AP_CLEAR_REQUEST_PHASE(new); if (access_status == DECLINED) { access_status = ap_process_request_internal(new); if (access_status == OK) { Index: modules/generators/mod_status.c =================================================================== --- modules/generators/mod_status.c (revision 155552) +++ modules/generators/mod_status.c (working copy) @@ -206,6 +206,25 @@ }; static char status_flags[SERVER_NUM_STATUS]; +#ifdef AP_TRACK_REQUEST_PHASE +static const char *phase_names[] = +{ + "-", + "handler", + "create_req", + "post_read", + "translate", + "map", + "parser", + "access_checker", + "check_user", + "auth_checker", + "type_checker", + "fixups", + "quick_handler", + "insert_err" +}; +#endif static int status_handler(request_rec *r) { @@ -549,6 +568,9 @@ ap_rputs("\n\n
| Srv | PID | Acc | " "M | " +#ifdef AP_TRACK_REQUEST_PHASE + "Phase | " +#endif #ifdef HAVE_TIMES "CPU\n | " #endif @@ -721,7 +743,14 @@ ap_rputs("?", r); break; } - + +#ifdef AP_TRACK_REQUEST_PHASE + ap_rprintf(r, " | %s | ", + ws_record->status == SERVER_BUSY_WRITE ? + phase_names[ws_record->request_phase] + : "-"); +#endif + ap_rprintf(r, "\n" #ifdef HAVE_TIMES Index: include/httpd.h =================================================================== --- include/httpd.h (revision 155552) +++ include/httpd.h (working copy) @@ -1,3 +1,4 @@ +#define AP_TRACK_REQUEST_PHASE /* Copyright 1999-2005 The Apache Software Foundation or its licensors, as * applicable. * Index: include/scoreboard.h =================================================================== --- include/scoreboard.h (revision 155552) +++ include/scoreboard.h (working copy) @@ -100,6 +100,7 @@ apr_os_thread_t tid; #endif unsigned char status; + unsigned char request_phase; /* used if defined(AP_TRACK_REQUEST_PHASE) */ unsigned long access_count; apr_off_t bytes_served; unsigned long my_access_count; @@ -209,6 +210,44 @@ #define START_PREQUEST 1 #define STOP_PREQUEST 2 +#ifdef AP_TRACK_REQUEST_PHASE + +/* + * values for request_phase field in worker score + */ +#define AP_REQUEST_HANDLER_PHASE 1 +#define AP_CREATE_REQUEST_PHASE 2 +#define AP_POST_READ_REQUEST_PHASE 3 +#define AP_TRANSLATE_NAME_PHASE 4 +#define AP_MAP_TO_STORAGE_PHASE 5 +#define AP_HEADER_PARSER_PHASE 6 +#define AP_ACCESS_CHECKER_PHASE 7 +#define AP_CHECK_USER_ID_PHASE 8 +#define AP_AUTH_CHECKER_PHASE 9 +#define AP_TYPE_CHECKER_PHASE 10 +#define AP_FIXUPS_PHASE 11 +#define AP_QUICK_HANDLER_PHASE 12 +#define AP_INSERT_ERROR_FILTER_PHASE 13 + +/* + * macros to set or clear the request phase + */ +#define AP_SET_REQUEST_PHASE(r, p) do { \ + if (ap_extended_status) { \ + ap_set_request_phase((r), (p)); \ + } \ + } while (0) + +#define AP_CLEAR_REQUEST_PHASE(r) do { \ + if (ap_extended_status) { \ + ap_clear_request_phase((r)); \ + } \ + } while (0) + +AP_DECLARE(void) ap_set_request_phase(request_rec *r, int phase); +AP_DECLARE(void) ap_clear_request_phase(request_rec *r); +#endif + #ifdef __cplusplus } #endif
|---|