httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Victor Ronin <victor.ro...@gmail.com>
Subject Re: module configuration kill
Date Thu, 13 Jan 2011 17:09:11 GMT
Generally, this depends on what MPM module is used. MPM module can 
implement some specific logic regarding childs.
You can take a look here: http://httpd.apache.org/docs/2.0/mpm.html

As I know most of MPM modules create a new process for a child, so each 
child will have it's own global variables.
However, as example mpm_winnt has only one child, so you can disregard 
all worries regarding keeping instances of variables in sync between
childs.

Regards,
Victor Ronin

There are three
> this is turning out to be exactly what i was searching for.  quick question
> regarding variable initialization.  if i declare a global variable and assign it
> a value within the child_init hook it appears that each child contains a
> separate instance of the variable.  is this correct?
>
> i have tested this theory using the following
>
> int pid = 0;
>
> // registered handler for children
> static void child_handler(apr_pool_t *p, server_rec *s) {
>      pid = (int)getpid();
>      apr_pool_cleanup_register(p, (void *)s, pool_cleanup, child_cleanup);
> }
>
> // registered handler for HTTP methods
> static int method_handler(request_rec *r) {
>      fprintf(stderr, "method_handler called for pid (%d)\n", (int)getpid());
>      fprintf(stderr, "pid initialized within child_handler (%d)\n", pid);
>      fflush(stderr);
> }
>
> // cleans up pool resources
> apr_status_t pool_cleanup(void *data) {
>      fprintf(stderr, "pool_cleanup called for pid (%d)\n", (int)getpid());
>      fflush(stderr);
> }
>
> // cleans up child resources
> apr_status_t authenticator_child_cleanup(void *data) {
>      fprintf(stderr, "child_cleanup called for pid (%d)\n", (int)getpid());
>      fflush(stderr);
> }
>
> // declares the handlers for other events
> static void register_hooks (apr_pool_t *p) {
>      ap_hook_handler(method_handler, NULL, NULL, APR_HOOK_MIDDLE);
>      ap_hook_child_init(child_handler, NULL, NULL, APR_HOOK_MIDDLE);
> }
>
>
>
> ________________________________
> From: Ben Noordhuis<info@bnoordhuis.nl>
> To: modules-dev@httpd.apache.org
> Sent: Wed, January 12, 2011 5:11:32 PM
> Subject: Re: module configuration kill
>
> On Wed, Jan 12, 2011 at 22:56, Peter Janovsky<peterjanovsky@yahoo.com>  wrote:
>> that is definitely of use.  thank you.  where would i call
>> apr_pool_register_cleanup?  originally i thought it would be in register_hooks
>  From your child_init hook. Register it with ap_hook_child_init() from
> your register_hooks function.
>
>
>
>


Mime
View raw message