From 78cf8c9212e1fec6d168dd5345c3949d2e3935e4 Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Tue, 26 Jan 2010 00:05:37 +0000 Subject: [PATCH] Refactor mod_status out of the ExtendedStatus toggle picture, as other modules can and should be able to use this scoreboard information. Rename suggestions for such a directive are welcomed. Note that mod_status toggles the default, to present the ExtendedStatus for server operators, whenever it is loaded. Docs changes to follow. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@903020 13f79535-47bb-0310-9956-ffa450edef68 --- include/mpm_common.h | 6 ----- include/scoreboard.h | 8 ++++++ modules/generators/mod_status.c | 47 ++++++++------------------------- server/core.c | 11 ++++++-- server/mpm_common.c | 12 --------- server/scoreboard.c | 35 ++++++++++++++++++++++++ 6 files changed, 63 insertions(+), 56 deletions(-) diff --git a/include/mpm_common.h b/include/mpm_common.h index 40c96ce7b2..a12d6d0233 100644 --- a/include/mpm_common.h +++ b/include/mpm_common.h @@ -264,12 +264,6 @@ extern const char *ap_pid_fname; const char *ap_mpm_set_pidfile(cmd_parms *cmd, void *dummy, const char *arg); -/* - * Set the scorboard file. - */ -const char *ap_mpm_set_scoreboard(cmd_parms *cmd, void *dummy, - const char *arg); - /* * The directory that the server changes directory to dump core. */ diff --git a/include/scoreboard.h b/include/scoreboard.h index 7cc735fe7f..989027e37d 100644 --- a/include/scoreboard.h +++ b/include/scoreboard.h @@ -32,6 +32,7 @@ extern "C" { #endif #include "ap_config.h" +#include "http_config.h" #include "apr_hooks.h" #include "apr_thread_proc.h" #include "apr_portable.h" @@ -188,6 +189,13 @@ AP_DECLARE_DATA extern const char *ap_scoreboard_fname; AP_DECLARE_DATA extern int ap_extended_status; AP_DECLARE_DATA extern int ap_mod_status_reqtail; +/* + * Command handlers [internal] + */ +const char *ap_set_scoreboard(cmd_parms *cmd, void *dummy, const char *arg); +const char *ap_set_extended_status(cmd_parms *cmd, void *dummy, int arg); +const char *ap_set_reqtail(cmd_parms *cmd, void *dummy, int arg); + /* Hooks */ /** * Hook for post scoreboard creation, pre mpm. diff --git a/modules/generators/mod_status.c b/modules/generators/mod_status.c index 8d10e437e2..1e5fe550f4 100644 --- a/modules/generators/mod_status.c +++ b/modules/generators/mod_status.c @@ -102,41 +102,6 @@ APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap, STATUS, int, status_hook, static pid_t child_pid; #endif -/* - * command-related code. This is here to prevent use of ExtendedStatus - * without status_module included. - */ -static const char *set_extended_status(cmd_parms *cmd, void *dummy, int arg) -{ - const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) { - return err; - } - ap_extended_status = arg; - return NULL; -} - -static const char *set_reqtail(cmd_parms *cmd, void *dummy, int arg) -{ - const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) { - return err; - } - ap_mod_status_reqtail = arg; - return NULL; -} - - -static const command_rec status_module_cmds[] = -{ - AP_INIT_FLAG("ExtendedStatus", set_extended_status, NULL, RSRC_CONF, - "\"On\" to enable extended status information, \"Off\" to disable"), - AP_INIT_FLAG("SeeRequestTail", set_reqtail, NULL, RSRC_CONF, - "For verbose requests, \"On\" to see the last 63 chars of the request, " - "\"Off\" (default) to see the first 63 in extended status display"), - {NULL} -}; - /* Format the number of bytes nicely */ static void format_byte_out(request_rec *r, apr_off_t bytes) { @@ -815,6 +780,15 @@ static int status_handler(request_rec *r) return 0; } +static void status_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) +{ + /* When mod_status is loaded, default our ExtendedStatus to 'on' + * other modules which prefer verbose scoreboards may play a similar game. + * If left to their own requirements, mpm modules can make do with simple + * scoreboard entries. + */ + ap_extended_status = 1; +} static int status_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) @@ -845,6 +819,7 @@ static void status_child_init(apr_pool_t *p, server_rec *s) static void register_hooks(apr_pool_t *p) { ap_hook_handler(status_handler, NULL, NULL, APR_HOOK_MIDDLE); + ap_hook_pre_config(status_pre_config, NULL, NULL, APR_HOOK_LAST); ap_hook_post_config(status_init, NULL, NULL, APR_HOOK_MIDDLE); #ifdef HAVE_TIMES ap_hook_child_init(status_child_init, NULL, NULL, APR_HOOK_MIDDLE); @@ -858,7 +833,7 @@ module AP_MODULE_DECLARE_DATA status_module = NULL, /* dir merger --- default is to override */ NULL, /* server config */ NULL, /* merge server config */ - status_module_cmds, /* command table */ + NULL, /* command table */ register_hooks /* register_hooks */ }; diff --git a/server/core.c b/server/core.c index 5f041a266c..7edc0fe0b3 100644 --- a/server/core.c +++ b/server/core.c @@ -3379,6 +3379,15 @@ AP_INIT_ITERATE2("AddOutputFilterByType", add_ct_output_filters, AP_INIT_FLAG("AllowEncodedSlashes", set_allow2f, NULL, RSRC_CONF, "Allow URLs containing '/' encoded as '%2F'"), +/* scoreboard.c directives */ +AP_INIT_TAKE1("ScoreboardFile", ap_set_scoreboard, NULL, RSRC_CONF, + "A file for Apache to maintain runtime process management information"), +AP_INIT_FLAG("ExtendedStatus", ap_set_extended_status, NULL, RSRC_CONF, + "\"On\" to track extended status information, \"Off\" to disable"), +AP_INIT_FLAG("SeeRequestTail", ap_set_reqtail, NULL, RSRC_CONF, + "For extended status, \"On\" to see the last 63 chars of " + "the request line, \"Off\" (default) to see the first 63"), + /* * These are default configuration directives that mpms can/should * pay attention to. @@ -3387,8 +3396,6 @@ AP_INIT_FLAG("AllowEncodedSlashes", set_allow2f, NULL, RSRC_CONF, */ AP_INIT_TAKE1("PidFile", ap_mpm_set_pidfile, NULL, RSRC_CONF, "A file for logging the server process ID"), -AP_INIT_TAKE1("ScoreBoardFile", ap_mpm_set_scoreboard, NULL, RSRC_CONF, - "A file for Apache to maintain runtime process management information"), AP_INIT_TAKE1("MaxRequestsPerChild", ap_mpm_set_max_requests, NULL, RSRC_CONF, "Maximum number of requests a particular child serves before dying."), AP_INIT_TAKE1("CoreDumpDirectory", ap_mpm_set_coredumpdir, NULL, RSRC_CONF, diff --git a/server/mpm_common.c b/server/mpm_common.c index 005e90936b..fee23f66de 100644 --- a/server/mpm_common.c +++ b/server/mpm_common.c @@ -241,18 +241,6 @@ const char *ap_mpm_set_pidfile(cmd_parms *cmd, void *dummy, return NULL; } -const char * ap_mpm_set_scoreboard(cmd_parms *cmd, void *dummy, - const char *arg) -{ - const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - if (err != NULL) { - return err; - } - - ap_scoreboard_fname = arg; - return NULL; -} - int ap_max_requests_per_child = 0; const char *ap_mpm_set_max_requests(cmd_parms *cmd, void *dummy, diff --git a/server/scoreboard.c b/server/scoreboard.c index d2fe9527ea..6b0ee1c4f6 100644 --- a/server/scoreboard.c +++ b/server/scoreboard.c @@ -38,9 +38,44 @@ AP_DECLARE_DATA scoreboard *ap_scoreboard_image = NULL; AP_DECLARE_DATA const char *ap_scoreboard_fname = NULL; + +const char * ap_set_scoreboard(cmd_parms *cmd, void *dummy, + const char *arg) +{ + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); + if (err != NULL) { + return err; + } + + ap_scoreboard_fname = arg; + return NULL; +} + +/* Default to false when mod_status is not loaded */ AP_DECLARE_DATA int ap_extended_status = 0; + +const char *ap_set_extended_status(cmd_parms *cmd, void *dummy, int arg) +{ + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); + if (err != NULL) { + return err; + } + ap_extended_status = arg; + return NULL; +} + AP_DECLARE_DATA int ap_mod_status_reqtail = 0; +const char *ap_set_reqtail(cmd_parms *cmd, void *dummy, int arg) +{ + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); + if (err != NULL) { + return err; + } + ap_mod_status_reqtail = arg; + return NULL; +} + #if APR_HAS_SHARED_MEMORY #include "apr_shm.h" -- 2.40.0