#include <httpd.h> #include <http_protocol.h> #include <http_config.h> #include <http_log.h> #include <sys/stat.h> #include <apr_shm.h> typedef struct { apr_size_t counter; /* my counter */ } kcache_config_stat; typedef struct { int enabled; apr_shm_t *counters_shm; /* the APR shared segment object*/ kcache_config_stat *s;/*my stats*/ } kcache_config; void *create_server_conf(apr_pool_t *p, server_rec *s); static void register_hooks(apr_pool_t *pool); const char *kcache_set_enabled(cmd_parms *cmd, void *cfg, const char *arg); static const command_rec kcache_directives[] = { AP_INIT_TAKE1("KcacheEnabled", kcache_set_enabled, NULL, RSRC_CONF, "KcacheEnabled must have Off or On value"), { NULL } }; module AP_MODULE_DECLARE_DATA kcache_module = { STANDARD20_MODULE_STUFF, NULL, NULL, create_server_conf, NULL, kcache_directives, register_hooks }; /* * creating the server cfg */ void *create_server_conf(apr_pool_t *pool, server_rec *s) { kcache_config *cfg = apr_pcalloc(pool, sizeof(kcache_config)); return cfg; } ; const char *kcache_set_enabled(cmd_parms *cmd, void *cfg, const char *arg) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ kcache_config *conf = (kcache_config *) ap_get_module_config( cmd->server->module_config, &kcache_module); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ if (conf) { if (!strcasecmp(arg, "on")) conf->enabled = 1; else conf->enabled = 0; } return NULL; } /* * init child */ static void kcache_child_init(apr_pool_t *p, server_rec *s) { kcache_config *scfg = ap_get_module_config(s->module_config, &kcache_module); scfg->s = apr_shm_baseaddr_get(scfg->counters_shm); } /* * create the shm */ static int kcache_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { kcache_config *scfg = ap_get_module_config(s->module_config, &kcache_module); apr_shm_create(&scfg->counters_shm, sizeof(*scfg->s), NULL, pconf); scfg->s = apr_shm_baseaddr_get(scfg->counters_shm); scfg->s->counter = 0; return DECLINED; } static int kcache_handler_translate_files(request_rec* r) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ kcache_config *config = (kcache_config *) ap_get_module_config( r->server->module_config, &kcache_module); /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ if (!config->s) { ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r, "kcache_return_result invalid config->s"); return DECLINED; } config->s->counter++; ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "config->s->counter=%"APR_SIZE_T_FMT,config->s->counter); return DECLINED; } static void register_hooks(apr_pool_t* pool) { static const char *succ[] = { "mod_proxy.c", "mod_alias.c", "mod_userdir.c", NULL }; ap_hook_child_init(kcache_child_init, NULL, NULL, APR_HOOK_REALLY_FIRST); ap_hook_post_config(kcache_post_config, NULL, NULL, APR_HOOK_REALLY_FIRST); ap_hook_translate_name(kcache_handler_translate_files, NULL, succ, APR_HOOK_REALLY_FIRST); }
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx