At the moment Child(Init|Exit) phases are of type VOID, i.e. any failures
are ignored, which sucks, since you now can't do any reliable
initialization in the child init phase (e.g. let's say Apache::DBI's
child_init phase fails). How about making it RUN_ALL instead? The
immediate gain is that errors are now logged. I don't see any problems
with backwards compatibility, besides ChildInit phases needing to return
OK or DECLINED, but most likely there were all doing so anyway.
The only problem I have is how to prevent from Apache to continue on
failure. Any ideas?
The patch for the first part is below including a basic test (docs will
follow if there are no objections to this one).
Index: t/conf/post_config_startup.pl
===================================================================
--- t/conf/post_config_startup.pl (revision 267234)
+++ t/conf/post_config_startup.pl (working copy)
@@ -41,8 +41,8 @@
test_method_obj();
+test_child_init();
-
### only subs below this line ###
sub test_apache_resource {
@@ -144,6 +144,19 @@
$TestModperl::MethodObj = TestModperl::methodobj->new;
}
+# test startup loglevel setting (under threaded mpms loglevel can be
+# changed only before threads are started) so here we test whether we
+# can still set it after restart
+sub test_child_init {
+ my $s = Apache2::ServerUtil->server;
+ $s->push_handlers(PerlChildInitHandler => \&child_init);
+}
+
+sub child_init {
+ $TestModperl::ChildInit = "Initialised";
+ return Apache2::Const::OK;
+}
+
sub ModPerl::Test::add_config {
my $r = shift;
Index: lib/ModPerl/Code.pm
===================================================================
--- lib/ModPerl/Code.pm (revision 267234)
+++ lib/ModPerl/Code.pm (working copy)
@@ -55,7 +55,7 @@
ret => 'void',
args => [{type => 'apr_pool_t', name => 'p'},
{type => 'server_rec', name => 's'},
- {type => 'dummy', name => 'MP_HOOK_VOID'}],
+ {type => 'dummy', name => 'MP_HOOK_RUN_ALL'}],
},
Files => {
ret => 'int',
--- /dev/null 2005-09-07 13:08:05.178257784 -0700
+++ t/response/TestModperl/child_init.pm 2005-09-07 15:50:48.000000000
-0700
@@ -0,0 +1,28 @@
+package TestModperl::child_init;
+
+# Modperl::child_init tests
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestUtil;
+
+use Apache2::Const -compile => 'OK';
+
+sub handler {
+ my $r = shift;
+
+ plan $r, tests => 1;
+
+ # should get set in child_init() registered by test_child_init, in
+ # post_config_startup.pl
+ ok t_cmp $TestModperl::ChildInit,
+ "Initialised",
+ "checking that child_init was run";
+
+ Apache2::Const::OK;
+}
+
+1;
+__END__
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://mailchannels.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]