Return-Path: Delivered-To: apmail-new-httpd-archive@apache.org Received: (qmail 96081 invoked by uid 500); 12 Jun 2001 02:49:31 -0000 Mailing-List: contact new-httpd-help@apache.org; run by ezmlm Precedence: bulk Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list new-httpd@apache.org Received: (qmail 96067 invoked from network); 12 Jun 2001 02:49:30 -0000 Message-ID: <3482305AF0F6CF469ED45C0D48FAFCF7091FF4CB@cnet48.cnet.com> From: Ian Holsman To: "'new-httpd@apache.org'" Subject: RE: [PATCH] mgmt_get_vars hook Date: Mon, 11 Jun 2001 19:49:28 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="WINDOWS-1252" X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N ok... stuff moved to const char*., changed 'module' to 'name' and put the patch inline. Index: include/http_core.h =================================================================== RCS file: /home/cvspublic/httpd-2.0/include/http_core.h,v retrieving revision 1.43 diff -u -r1.43 http_core.h --- include/http_core.h 2001/04/13 05:19:25 1.43 +++ include/http_core.h 2001/06/11 20:22:28 @@ -60,6 +60,7 @@ #define APACHE_HTTP_CORE_H #include "apr.h" +#include "apr_hash.h" #if APR_HAVE_STRUCT_RLIMIT #include @@ -497,6 +498,38 @@ AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy, const char *arg); #endif + +typedef enum { + mgmt_line_type_string, + mgmt_line_type_long, + mgmt_line_type_hash +} mgmt_line_type_e; + +typedef union { + const char* string; + long long; + apr_hash_t *ht; +} mgmt_line_value; + +typedef struct mgmt_line_t { + const char *description; + const char *name; + mgmt_line_type_e valType; + mgmt_line_value val; +} mgmt_line_t; + +/** + * Gives modules a method 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 (using mgmt_line_t) + * @ingroup hooks + */ + +AP_DECLARE_HOOK(int, mgmt_get_vars, + (apr_pool_t *p, const char*val,apr_hash_t *ht)) #ifdef __cplusplus } Index: server/core.c =================================================================== RCS file: /home/cvspublic/httpd-2.0/server/core.c,v retrieving revision 1.17 diff -u -r1.17 core.c --- server/core.c 2001/06/08 16:39:48 1.17 +++ server/core.c 2001/06/11 20:22:49 @@ -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 @@ -93,6 +94,13 @@ #define AP_DEFAULT_LIMIT_XML_BODY ((size_t)1000000) #define AP_MIN_SENDFILE_BYTES (256) + +APR_HOOK_STRUCT( + APR_HOOK_LINK(mgmt_get_vars) +) + +AP_IMPLEMENT_HOOK_RUN_FIRST(int,mgmt_get_vars, + (apr_pool_t *p,const char*val, apr_hash_t *ht),(p,val,ht),DECLINED) /* Server core module... This module provides support for really basic * server operations, including options and commands which control the > -----Original Message----- > From: Greg Stein [mailto:gstein@lyra.org] > Sent: Monday, June 11, 2001 6:00 PM > To: new-httpd@apache.org > Subject: Re: [PATCH] mgmt_get_vars hook > > > On Mon, Jun 11, 2001 at 03:32:22PM -0700, Ian Holsman wrote: > > > -----Original Message----- > > > From: William A. Rowe, Jr. [mailto:admin@rowe-clan.net] > >... > > > data, and that will not be heavily string intensive, so we > > > won't laden the server > > > with unnecessary cpu. Yes? > > > > I was thinking that there would be a 'description' and a > 'module' field with > > each number which would describe what the value represents. > > the 'scoreboard.requests.total' key would have a > description 'The Total # of requests served since > > apache was started' and a module 'scoreboard'. which would > be apr_pstrdup'ed in. > > There is absolutely no need to strdup those strings. They are constant > strings that survive forever. It is silly to copy them to the > heap. Just > say: > > item = apr_pcalloc(p, sizeof(*item)); > item->description = "Combat boot size"; > item->name = "mom.feet.boot-size"; > ... > > Just make sure to change the description/module to "const > char *", and you > should be set. The string value (in the union type) should be > const-ified, > too. > > I would also recommend changing "module" to "name". Each item > can specify > its name, rather than just the defining module. (and if we > use a dotted name > as the precedent, then "module" can also be extracted) > > Cheers, > -g > > -- > Greg Stein, http://www.lyra.org/ >