httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From luca regini <>
Subject Caching a value for the lifetime of a module: CLUELESS
Date Tue, 08 Mar 2005 10:17:42 GMT
My understanding about per server conf is that any structure allocated
in the server config handler should have a lifetime that is the same
as the one of the module. So the server config structure should be an
ideal place for caching values. Anyway in the following simple module
the dbg counter is correctly incremented only for requests made within
the same connection. When i close the brower, reopen it and make
another request, dbg is set to 0. I am clueless and don't understand
what is wrong with this code.
Thanks in advance for your attention,

typedef struct
	//apr_hash_t *url_ht;
	#ifdef DBG_print_cache
	int dbg;

} server_config;

/* Declare the module name */
module AP_MODULE_DECLARE_DATA sds_debug_module;

static void log(char * log)


static void *create_server_config(apr_pool_t *p,server_rec *s)
	server_config *sconf = apr_palloc(p,sizeof(*sconf));
	//sconf->url_ht= apr_hash_make(p);
	#ifdef DBG_create_server_config
	fprintf(stderr,"calling create_server_config \n");
	return (void *) sconf;

static void print_cache(request_rec *r)
	#ifdef DBG_print_cache
	server_config *conf;
	fprintf(stderr,"DBG: %d\n",conf->dbg);

static int cache_url_handler(request_rec *r, int lookup)
	return DECLINED;

/* Register the filter function as a filter for modifying the HTTP
body (content) */
static void register_hooks(apr_pool_t *p)
    // cache initializer
    // cache handler
    ap_hook_quick_handler(cache_url_handler, NULL, NULL, APR_HOOK_FIRST);
    // cache filters
    // XXX The cache filters need to run right after the handlers and before
    // any other filters. Consider creating AP_FTYPE_CACHE for this purpose.
    // Make them AP_FTYPE_CONTENT for now.
    // XXX ianhH:they should run AFTER all the other content filters.


/* Define the module data */
module AP_MODULE_DECLARE_DATA sds_debug_module =
  NULL,                        /* dir config creater */
  NULL,                        /* dir merger --- default is to override */
  create_server_config,        /* server config */
  NULL,                        /* merge server config */
  NULL,                        /* command apr_table_t */
  register_hooks 	       /* register hook */

View raw message