You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2004/12/01 02:31:25 UTC
Re: per-server cleanups core dump? geoff?
Geoffrey Young wrote:
>>So may be your orig patch from:
>>http://thread.gmane.org/gmane.comp.apache.mod-perl.devel/730
>>is the way to go,
>
>
> well, if you mean the patch that started the thread, I seem to say there
> that the patch keeps things from segfaulting, but that the callback isn't
> actually run. in other words, the patch didn't really work, but was
> probably meant to be a starting point to something better.
Actually your patch, Geoff, was perfectly fine. It wasn't supposed to work
for cleanups registered from the child processes, because child processes
don't run cleanup handlers, because server_pool is cleaned internally w/o
letting the parent pool destroy it (child_exit is a special case). But it
works perfectly fine for parent process cleanup, but you need to register
that in the parent process (i.e. at the server startup). See the
modperl_extra.pl addition in the patch below. it logs the date twice on
server start, i.e. every time server_pool is recreated.
So let me know where are we on this story.
Index: xs/maps/modperl_functions.map
===================================================================
--- xs/maps/modperl_functions.map (revision 109257)
+++ xs/maps/modperl_functions.map (working copy)
@@ -78,6 +78,7 @@
MODULE=Apache::ServerUtil PACKAGE=Apache::ServerRec
SV *:DEFINE_dir_config | | server_rec *:s, char *:key=NULL, SV
*:sv_val=Nullsv
+ apr_pool_t:DEFINE_pool
MODULE=Apache::ServerUtil PACKAGE=Apache::ServerUtil
mpxs_Apache__ServerUtil_server_root_relative | | p, fname=""
Index: xs/Apache/ServerUtil/Apache__ServerUtil.h
===================================================================
--- xs/Apache/ServerUtil/Apache__ServerUtil.h (revision 109257)
+++ xs/Apache/ServerUtil/Apache__ServerUtil.h (working copy)
@@ -13,6 +13,8 @@
* limitations under the License.
*/
+#define mpxs_Apache__ServerRec_pool modperl_server_pool
+
#define mpxs_Apache__ServerRec_method_register(s, methname) \
ap_method_register(s->process->pconf, methname);
Index: t/conf/modperl_extra.pl
===================================================================
--- t/conf/modperl_extra.pl (revision 109257)
+++ t/conf/modperl_extra.pl (working copy)
@@ -49,8 +49,14 @@
test_perl_ithreads();
+my $server_pool = Apache::ServerRec::pool();
+$server_pool->cleanup_register(
+ sub {
+ local %ENV;
+ qx[/bin/date >> /tmp/date];
+ Apache::OK;
+ });
-
### only subs below this line ###
sub reorg_INC {
Index: t/response/TestAPI/server_util.pm
===================================================================
--- t/response/TestAPI/server_util.pm (revision 109257)
+++ t/response/TestAPI/server_util.pm (working copy)
@@ -29,7 +29,7 @@
sub handler {
my $r = shift;
- plan $r, tests => 15;
+ plan $r, tests => 17;
{
my $s = $r->server;
@@ -48,6 +48,14 @@
server_root_relative_tests($r);
+ my $server_pool = Apache::ServerRec::pool();
+ ok $server_pool->isa('APR::Pool');
+
+ # this will never run since it's not registered in the parent
+ # process
+ $server_pool->cleanup_register(sub { Apache::OK });
+ ok 1;
+
Apache::OK;
}
--
__________________________________________________________________
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: per-server cleanups core dump? geoff?
Posted by Stas Bekman <st...@stason.org>.
>>But it works perfectly fine for parent process cleanup,
>>but you need to register that in the parent process (i.e. at the server
>>startup). See the modperl_extra.pl addition in the patch below. it logs
>>the date twice on server start, i.e. every time server_pool is recreated.
>
> I swear that it my patch didn't behave this way, but I just tried it and
> placing the cleanup at the module level and using PerlModule work just fine.
Great.
> so +1 on the patch, and sorry it took so long for me to get around to
> testing it.
OK, but it's going to be: Apache::ServerUtil::base_server_pool, so people
don't try to confuse it with a random vhost pool. (also moved from
ServerRec package, since it doesn't belong there, IMHO).
--
__________________________________________________________________
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: per-server cleanups core dump? geoff?
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> Actually your patch, Geoff, was perfectly fine. It wasn't supposed to
> work for cleanups registered from the child processes, because child
> processes don't run cleanup handlers, because server_pool is cleaned
> internally w/o letting the parent pool destroy it (child_exit is a
> special case).
ok
> But it works perfectly fine for parent process cleanup,
> but you need to register that in the parent process (i.e. at the server
> startup). See the modperl_extra.pl addition in the patch below. it logs
> the date twice on server start, i.e. every time server_pool is recreated.
I swear that it my patch didn't behave this way, but I just tried it and
placing the cleanup at the module level and using PerlModule work just fine.
so +1 on the patch, and sorry it took so long for me to get around to
testing it.
--Geoff
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org