From e5640cedcc6fc8ca4d9d3e1951c02aa0fd92db7e Mon Sep 17 00:00:00 2001 From: Greg Stein Date: Wed, 13 Jun 2001 20:11:45 +0000 Subject: [PATCH] Define a hook for fetching management/status items. This patch was submitted by Ian Holsman. Greg revised some names, applied the Apache style, and namespace-prefixed the public symbols. Minor bugfix in the use of the hook implementation macro. Submitted by: Ian Holsman Reviewed by: Greg Stein git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89364 13f79535-47bb-0310-9956-ffa450edef68 --- include/http_core.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ server/core.c | 10 ++++++++++ 2 files changed, 54 insertions(+) diff --git a/include/http_core.h b/include/http_core.h index ccfdca1afe..8fbe554cc2 100644 --- a/include/http_core.h +++ b/include/http_core.h @@ -60,6 +60,7 @@ #define APACHE_HTTP_CORE_H #include "apr.h" +#include "apr_hash.h" #if APR_HAVE_STRUCT_RLIMIT #include @@ -498,6 +499,49 @@ AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dumm #endif + +/* ---------------------------------------------------------------------- + * + * Runtime status/management + */ + +typedef enum { + ap_mgmt_type_string, + ap_mgmt_type_long, + ap_mgmt_type_hash +} ap_mgmt_type_e; + +typedef union { + const char *s_value; + long i_value; + apr_hash_t *h_value; +} ap_mgmt_value; + +typedef struct { + const char *description; + const char *name; + ap_mgmt_type_e vtype; + ap_mgmt_value v; +} ap_mgmt_item_t; + +/** + * This hook provdes a way for modules to provide metrics/statistics about + * their operational status. + * + * @param p A pool to use to create entries in the hash table + * @param val The name of the parameter(s) that is wanted. This is + * tree-structured would be in the form ('*' is all the tree, + * 'module.*' all of the module , 'module.foo.*', or + * 'module.foo.bar' ) + * @param ht The hash table to store the results. Keys are item names, and + * the values point to ap_mgmt_item_t structures. + * @ingroup hooks + */ +AP_DECLARE_HOOK(int, get_mgmt_items, + (apr_pool_t *p, const char * val, apr_hash_t *ht)) + +/* ---------------------------------------------------------------------- */ + #ifdef __cplusplus } #endif diff --git a/server/core.c b/server/core.c index c1bc54dc44..b5f7aa5a59 100644 --- a/server/core.c +++ b/server/core.c @@ -60,6 +60,7 @@ #include "apr_strings.h" #include "apr_lib.h" #include "apr_fnmatch.h" +#include "apr_hash.h" #include "apr_thread_proc.h" /* for RLIMIT stuff */ #define APR_WANT_IOVEC @@ -94,6 +95,15 @@ #define AP_MIN_SENDFILE_BYTES (256) +APR_HOOK_STRUCT( + APR_HOOK_LINK(get_mgmt_items) +) + +AP_IMPLEMENT_HOOK_RUN_ALL(int, get_mgmt_items, + (apr_pool_t *p, const char *val, apr_hash_t *ht), + (p, val, ht), OK, DECLINED) + + /* Server core module... This module provides support for really basic * server operations, including options and commands which control the * operation of other modules. Consider this the bureaucracy module. -- 2.40.0