]> granicus.if.org Git - apache/commitdiff
Refactor mod_status out of the ExtendedStatus toggle picture, as other
authorWilliam A. Rowe Jr <wrowe@apache.org>
Tue, 26 Jan 2010 00:05:37 +0000 (00:05 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Tue, 26 Jan 2010 00:05:37 +0000 (00:05 +0000)
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
include/scoreboard.h
modules/generators/mod_status.c
server/core.c
server/mpm_common.c
server/scoreboard.c

index 40c96ce7b26ad6c4e6a727896071db621f1d2cd5..a12d6d0233938aba9f70ca8df2d5106361cb37c3 100644 (file)
@@ -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.
  */
index 7cc735fe7f2d91ce456e7528477af9c04c430afe..989027e37d45eaa8dba039f25b8d2c62e92aaff2 100644 (file)
@@ -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.
index 8d10e437e2ba60b71f0e5db913954207a6dcffbe..1e5fe550f488188ebe52066f4498d9e1cb498a2f 100644 (file)
@@ -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 */
 };
 
index 5f041a266c3795fe7254c2560d5b3894439e6c5f..7edc0fe0b3f8eeea5f13e1c4e931e77d2be24f66 100644 (file)
@@ -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,
index 005e90936b8f778c7a1d2b8e91d6496232315438..fee23f66de511035998a1a96a241482fab7ce45c 100644 (file)
@@ -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,
index d2fe9527ea2a3635055dd34091ac9bb2c4bff0c5..6b0ee1c4f6aa92025368a7b1e09a2a283f50d042 100644 (file)
 
 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"