httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <oh...@cox.net>
Subject Re: Module register_hooks and config seems to be called twice when Apache starts up?
Date Sun, 01 Jul 2012 16:38:24 GMT

---- Eric Covener <covener@gmail.com> wrote: 
> On Sun, Jul 1, 2012 at 11:48 AM,  <ohaya@cox.net> wrote:
> > Hi,
> >
> > I have the following in my module:
> >
> >
> > module AP_MODULE_DECLARE_DATA my_module =
> > {
> >     STANDARD20_MODULE_STUFF,
> >     NULL,                                              
   /* dir config creater */
> >     NULL,                                              
   /* dir merger --- default is to override */
> >     create_mymodule_config,                       /* server config
*/
> >     NULL,                       /* merge server configs */
> >     txt_cmds,                       /* command apr_table_t */
> >     register_hooks              /* register hooks */
> > };
> >
> >
> > I also have some printf statements at the beginning of the create_mymodule_config()
and register_hooks() function, and when I start Apache, it seems like it's calling both of
those functions twice.
> >
> > Can anyone tell why that might be, and is it possible to have Apache onlyh call
those functions once during startup?
> 
> Apache parses the config twice at startup (once as a dry run).  Some
> modules use apr_pool_userdata_set on s->process->pool  to recognize
> the first pass and avoid heavy lifting the first pass.


Hi Eric,

Right now, in the create_mymodule_config(), I allocation memory for the config struct, and
set a (single) default value.  As I said, I also currently have some printf's, so the msgs
show up twice.

Other than the msgs showing up twice, is there any harm is NOT trying to detect the 1st pass,
and just doing the allocation and setting the default, twice?  

I think that I read somewhere that after the 1st pass, everything is unloaded, so when the
2nd pass occurs, it's basically starting from scratch anyway.

Jim

Mime
View raw message