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.
|