Return-Path: Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: (qmail 6493 invoked from network); 8 Mar 2005 16:41:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 8 Mar 2005 16:41:40 -0000 Received: (qmail 23750 invoked by uid 500); 8 Mar 2005 16:41:35 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 23709 invoked by uid 500); 8 Mar 2005 16:41:35 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: Delivered-To: mailing list dev@httpd.apache.org Delivered-To: moderator for dev@httpd.apache.org Received: (qmail 71336 invoked by uid 99); 8 Mar 2005 11:47:14 -0000 X-ASF-Spam-Status: No, hits=1.9 required=10.0 tests=DNS_FROM_RFC_POST,DNS_FROM_RFC_WHOIS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Message-Id: <1110282424.971972040@as03.coolgoose.com> From: "P. Asokan" To: luca.regini@gmail.com Cc: apache-modules@covalent.net, dev@httpd.apache.org Subject: Re: [apache-modules] Caching a value for the lifetime of a module: CLUELESS Date: Tue, 8 Mar 2005 17:17:04 +0550 X-Originating-IP: [61.246.216.98] X-Abuse-to: abuse@coolgoose.com X-Mailer: mcDesktop v1.0.3; Copyright (c) 2001-2003 Multiboard Communications Inc. X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Which operating system you are using? If you are using unix os, this problem may be due to the prefork process which will be created to serve for each connection. In that case you may have to use shared memory... Regards, Asok > 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, > Luca > > > typedef struct > { > //apr_hash_t *url_ht; > #ifdef DBG_print_cache > int dbg; > #endif > > } server_config; > > > > /* Declare the module name */ > module AP_MODULE_DECLARE_DATA sds_debug_module; > > > static void log(char * log) > { > fprintf(stderr,log); > fflush(stderr); > > } > > 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"); > fflush(stderr); > sconf->dbg=0; > #endif > return (void *) sconf; > } > > > static void print_cache(request_rec *r) > { > #ifdef DBG_print_cache > server_config *conf; > conf=(server_config*) > ap_get_module_config(r->server->module_config,&sds_debug_module); > fprintf(stderr,"DBG: %d\n",conf->dbg); > fflush(stderr); > conf->dbg++; > #endif > } > > > > static int cache_url_handler(request_rec *r, int lookup) > { > print_cache(r); > 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 = > { > STANDARD20_MODULE_STUFF, > 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 */ > }; > > --------------------------------------------------------------------- > To unsubscribe, e-mail: apache-modules-unsubscribe@covalent.net > For additional commands, e-mail: apache-modules-help@covalent.net