You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Geoffrey Young <ge...@modperlcookbook.org> on 2003/04/15 22:16:10 UTC
[patch] Apache->server->pool
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.
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.
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.
--Geoff
Re: [patch] Apache->server->pool
Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>
>
> Stas Bekman wrote:
>
>>> any ideas where to start?
>>
>>
>>
>> mod_perl.c, probably needs similar work as for child_exit.
>>
>> /me here commits a few new cool ModPerl::MethodLookup functions,
>> finish off the FilterPreHandler perl stuff and wants to release
>> 1.99_09 first...
>
>
> yup, 1.99_09 is important - just trying to get some other useful
> features in under the wire :)
trying to get the FilterPreHandler in so you can release a new Clean module ;)
> keep up the good work!
;)
__________________________________________________________________
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
Re: [patch] Apache->server->pool
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Stas Bekman wrote:
>> any ideas where to start?
>
>
> mod_perl.c, probably needs similar work as for child_exit.
>
> /me here commits a few new cool ModPerl::MethodLookup functions, finish
> off the FilterPreHandler perl stuff and wants to release 1.99_09 first...
yup, 1.99_09 is important - just trying to get some other useful
features in under the wire :)
keep up the good work!
--Geoff
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [patch] Apache->server->pool
Posted by Stas Bekman <st...@stason.org>.
> any ideas where to start?
mod_perl.c, probably needs similar work as for child_exit.
/me here commits a few new cool ModPerl::MethodLookup functions, finish off
the FilterPreHandler perl stuff and wants to release 1.99_09 first...
__________________________________________________________________
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
Re: [patch] Apache->server->pool
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>> ok, that works. well, sort of. I can make the call but the code
>> (again) never runs. have you tried it?
>
>
> I meant to use $s->process->pool to get the pool. I didn't do any claims
> about cleanup_register() on server working ;)
:)
>> outside of its not working, that's fine. a little less intuitive,
>> yes, but no biggie.
>
>
> $s->process->pool is working. The cleanup registration is not. It's not
> the same.
right. I am a bit confused, though - there's a test that shows that
pools randomly created get run when the pool is destroyed and it works
ok, so why it doesn't work when the process pools are destroyed I dunno.
> My question was whether we need to have an alias so we can get
> $s->pool do $s->process->pool.
nah. actually, I like the $s->process->pool() meme - it lets you know
exactly which pool you're talking about. and if we did alias one we'd
need to alias $s->pconf as well, which just starts to get confusing.
>>
>> at any rate, it looks like process->pool() and process->pconf() will
>> fit the bill... if only they actually worked :)
>
>
> So this part probably needs work.
yup :)
any ideas where to start?
--Geoff
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [patch] Apache->server->pool
Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>
>> Oops, that's a bad copy-n-paste, should be:
>>
>> $s->process->pool->cleanup_register(\&cleanup_callback, $data);
>
>
> ok, that works. well, sort of. I can make the call but the code
> (again) never runs. have you tried it?
I meant to use $s->process->pool to get the pool. I didn't do any claims about
cleanup_register() on server working ;)
>>> 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.)
>
>
> outside of its not working, that's fine. a little less intuitive, yes,
> but no biggie.
$s->process->pool is working. The cleanup registration is not. It's not the
same. My question was whether we need to have an alias so we can get $s->pool
do $s->process->pool.
> actually, now that I know this,
>
> $s->process->pconf->cleanup_register()
yup, the main pool.
> is really what I was after, since I want to capture configuration -HUP
> changes. it's nice that process_rec gives you that kind of
> granularity. cool.
Cool.
>> 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.
>
>
> cool :)
>
>>
>> I suppose what you should do instead is:
>>
>> $s->push_handlers(PerlChildExitHandler => 'my_cleanup');
>
>
> well, that's not exactly the same. in 1.0 $s->register_cleanup() called
> the sub on server exits or restarts - that's what I'm looking to
> duplicate here.
>
> at any rate, it looks like process->pool() and process->pconf() will fit
> the bill... if only they actually worked :)
So this part probably needs work.
__________________________________________________________________
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
Re: [patch] Apache->server->pool
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> Oops, that's a bad copy-n-paste, should be:
>
> $s->process->pool->cleanup_register(\&cleanup_callback, $data);
ok, that works. well, sort of. I can make the call but the code (again)
never runs. have you tried it?
>
>> 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.)
outside of its not working, that's fine. a little less intuitive, yes, but
no biggie. actually, now that I know this,
$s->process->pconf->cleanup_register()
is really what I was after, since I want to capture configuration -HUP
changes. it's nice that process_rec gives you that kind of granularity. cool.
>> 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
> */
yeah, I saw that. I actually tried using modperl_global_get_pconf() instead
of modperl_server_pool() when I was implementing the patch. I didn't see
the process_rec stuff, though :)
>
> 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.
cool :)
>
> I suppose what you should do instead is:
>
> $s->push_handlers(PerlChildExitHandler => 'my_cleanup');
well, that's not exactly the same. in 1.0 $s->register_cleanup() called the
sub on server exits or restarts - that's what I'm looking to duplicate here.
at any rate, it looks like process->pool() and process->pconf() will fit the
bill... if only they actually worked :)
--Geoff
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [patch] Apache->server->pool
Posted by Stas Bekman <st...@stason.org>.
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