httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Holsman <I...@cnet.com>
Subject RE: [PATCH] mgmt_get_vars hook
Date Tue, 12 Jun 2001 02:49:28 GMT
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 <sys/time.h>
@@ -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/
> 

Mime
View raw message