perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [patch] Apache->server->pool
Date Wed, 16 Apr 2003 01:09:14 GMT
Geoffrey Young wrote:
> hi...
> 
> from compat.pod, the way to access per-server cleanups is
> 
>   $s->pool->cleanup_register(\&cleanup_callback, $data);
> 
> which is similar to per-request cleanups
> 
>   $r->pool->cleanup_register(\&cleanup_callback, $data);
> 
> all is cool so far.  the problem is that there is no pool() method in 
> Apache::Server or Apache::ServerUtil, so you can't actually use 
> cleanup_register() as documented for per-server cleanups.

Oops, that's a bad copy-n-paste, should be:

   $s->process->pool->cleanup_register(\&cleanup_callback, $data);

> anyway, here is a patch that seems to fit the bill.  well, almost.  it 
> implements Apache->server->pool(), which you can now use to register 
> cleanups via Apache->server->pool->cleanup_register().  all tests pass.

$s->process->pool is not good? (agreed that it's not very intuitive, but 
that's where it lives in the apache structs.)

> the only problem is one that is difficult to check via the test suite.  
> any registered per-server cleanups don't actually get run.  ever.  they 
> just vanish.  I verified this via some test debugging (using the cleanup 
> to touch a file), as well as using 
> Apache->server->pool->cleanup_register() in a module I'm developing.  hmph.
> 
> at any rate, any insight is appreciated - I really don't know how to 
> proceed from here to get this working.

The insights would be:

the comment in mod_perl.c:

/*
  * the "server_pool" is a subpool of the parent pool (aka "pconf")
  * this is where we register the cleanups that teardown the interpreter.
  * the parent process will run the cleanups since server_pool is a subpool
  * of pconf.  we manually clear the server_pool to run cleanups in the
  * child processes
  */

and the modperl_child_exit function in the same file. Notice how the 
child_exit is executed and that the pool is cleared only if destruct level is set.

I suppose what you should do instead is:

   $s->push_handlers(PerlChildExitHandler => 'my_cleanup');

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message