Re: multiple processes: but one module init needed
On Sun, Jan 25, 2009 at 11:31 AM, Sander Temme wrote: > > http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/examples/mod_example_ipc.c?view=co > > for an example. The post_config hook is where you want to put your stuff, > but yes it does get called twice so you may want to use the construction in > the example module to avoid reallocating certain items. Buy two, get two free on Windows! -- Eric Covener cove...@gmail.com
Re: multiple processes: but one module init needed
On Jan 25, 2009, at 12:35 AM, fka...@googlemail.com wrote: some of the initialization tasks of my module must not be done repeatedly with each spawned server process. Currently I init my module by ap_hook_child_init() and do cleaning up by apr_pool_cleanup_register(), so each spawned server process inits my module again. See: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/examples/mod_example_ipc.c?view=co for an example. The post_config hook is where you want to put your stuff, but yes it does get called twice so you may want to use the construction in the example module to avoid reallocating certain items. Do I have to do IPC between my modules (to figure out if the currently loaded module is in the *first* of the spawend processes)? No, just put your init code in the right hook. S. -- Sander Temme scte...@apache.org PGP FP: 51B4 8727 466A 0BC3 69F4 B7B8 B2BE BC40 1529 24AF
Re: multiple processes: but one module init needed
Saju Pillai: > Look at http://wiki.apache.org/httpd/ModuleLife to see > how to make init code run only once from post_config How cool. That explains everything... Thank You!! Felix
Re: multiple processes: but one module init needed
fka...@googlemail.com wrote: fka...@googlemail.com: some of the initialization tasks of my module must not be done repeatedly with each spawned server process. To be more precise: There is only *one* vhost/configuration here, however, due to the mpm settings (see below) apache launches *several* processes to serve it -- and this is the issue I am addressing to: StartServers2 #StartServers 1 ... When I start just one server my module gets loaded with the process once only, of course. However, when several processes are launched, then the module gets called for all (?) hooks several times. The post_config hook is called twice in the parent for a unix mpm. Maybe you are confusing the double post_config hook invocation with "StartServers 2". Look at http://wiki.apache.org/httpd/ModuleLife to see how to make init code run only once from post_config srp -- http://saju.net.in
Re: multiple processes: but one module init needed
fka...@googlemail.com: > some of the initialization tasks of my module must not be > done repeatedly with each spawned server process. To be more precise: There is only *one* vhost/configuration here, however, due to the mpm settings (see below) apache launches *several* processes to serve it -- and this is the issue I am addressing to: StartServers2 #StartServers 1 ... When I start just one server my module gets loaded with the process once only, of course. However, when several processes are launched, then the module gets called for all (?) hooks several times. I am trying to find a solution to distinguish between these invocations of my module (to not do some of my module's initialization tasks more than once). Felix
Re: multiple processes: but one module init needed
Saju Pillai: > fka...@googlemail.com wrote: > > Hi all, > > > > some of the initialization tasks of my module must not be > > done repeatedly with each spawned server process. > > > The post_config hook may help you. Thanks -- but in what way? Even with this hook my module gets called for *each* spawned server/process... Felix
Re: multiple processes: but one module init needed
fka...@googlemail.com wrote: Hi all, some of the initialization tasks of my module must not be done repeatedly with each spawned server process. The post_config hook may help you. Currently I init my module by ap_hook_child_init() and do cleaning up by apr_pool_cleanup_register(), so each spawned server process inits my module again. Do I have to do IPC between my modules (to figure out if the currently loaded module is in the *first* of the spawend processes)? Or are there any hints from apache's framework (like a numbering for spawned processes my module is in) ? Querying the child's pids does not help to be unique. Best would be something like am extra hook for a module's initialization/clean up once-per-apache-start resp. stop. Thank You for any pointers... Felix -srp -- http://saju.net.in
multiple processes: but one module init needed
Hi all, some of the initialization tasks of my module must not be done repeatedly with each spawned server process. Currently I init my module by ap_hook_child_init() and do cleaning up by apr_pool_cleanup_register(), so each spawned server process inits my module again. Do I have to do IPC between my modules (to figure out if the currently loaded module is in the *first* of the spawend processes)? Or are there any hints from apache's framework (like a numbering for spawned processes my module is in) ? Querying the child's pids does not help to be unique. Best would be something like am extra hook for a module's initialization/clean up once-per-apache-start resp. stop. Thank You for any pointers... Felix