Author: stas
Date: Fri Dec 10 16:01:39 2004
New Revision: 111555

URL: http://svn.apache.org/viewcvs?view=rev&rev=111555
Log:
- move the startup code that doesn't have to run from the config phase to 
  the post config phase (after the modperl internal fix to run its own 
  post_config phase last)
- add comments explaining the lack of logging
- add comments explaining why some chunks of code run at the config phase

Modified:
   perl/modperl/trunk/t/conf/modperl_extra.pl
   perl/modperl/trunk/t/conf/post_config_startup.pl

Modified: perl/modperl/trunk/t/conf/modperl_extra.pl
Url: 
http://svn.apache.org/viewcvs/perl/modperl/trunk/t/conf/modperl_extra.pl?view=diff&rev=111555&p1=perl/modperl/trunk/t/conf/modperl_extra.pl&r1=111554&p2=perl/modperl/trunk/t/conf/modperl_extra.pl&r2=111555
==============================================================================
--- perl/modperl/trunk/t/conf/modperl_extra.pl  (original)
+++ perl/modperl/trunk/t/conf/modperl_extra.pl  Fri Dec 10 16:01:39 2004
@@ -2,6 +2,18 @@
 ### IMPORTANT: only things that must be run absolutely ###
 ### during the config phase should be in this file     ###
 ##########################################################
+#
+# On the 2nd pass, during server-internal restart, none of the code
+# running from this file (config phase) will be able to log any STDERR
+# messages. This is because Apache redirects STDERR to /dev/null until
+# the open_logs phase. That means that any of the code fails, the
+# error message will be lost (but it should have failed on the 1st
+# pass, when STDERR goes to the console and any error messages are
+# properly logged). Therefore avoid putting any code here (unless
+# there is no other way) and instead put all the code to be run at the
+# server startup into post_config_startup.pl. when the latter is run,
+# STDERR is sent to $ErrorLog.
+#
 
 use strict;
 use warnings FATAL => 'all';
@@ -29,18 +41,16 @@
 
 test_add_version_component();
 
-test_apache_status();
-
 test_hooks_startup();
 
 test_modperl_env();
 
-test_method_obj();
-
 
 
 ### only subs below this line ###
 
+# need to run from config phase, since we want to adjust @INC as early
+# as possible
 sub reorg_INC {
     # after Apache2 has pushed blib and core dirs including Apache2 on
     # top reorg @INC to have first devel libs, then blib libs, and
@@ -60,6 +70,7 @@
     @INC = (@a, @b, @c);
 }
 
+# need to run from config phase, since it registers PerlPostConfigHandler
 sub register_post_config_startup {
     # most of the startup code needs to be run at the post_config
     # phase
@@ -72,6 +83,10 @@
     });
 }
 
+# this can be run from post_config_startup.pl, but then it'll do the
+# logging twice, so in this case it's actually good to have this code
+# run during config phase, so it's logged only once (even though it's
+# run the second time, but STDERR == /dev/null)
 sub startup_info {
     my $ap_mods  = scalar grep { /^Apache/ } keys %INC;
     my $apr_mods = scalar grep { /^APR/    } keys %INC;
@@ -88,6 +103,7 @@
     $server->log->info("base server + $vhosts vhosts ready to run tests");
 }
 
+# need to run from config phase, since it changes server config
 sub test_add_config {
     # testing $s->add_config()
     my $conf = <<'EOC';
@@ -105,6 +121,7 @@
     Apache->server->add_config(['<Perl >', '1;', '</Perl>']);
 }
 
+# need to run from config phase, since it registers PerlPostConfigHandler
 sub test_add_version_component {
     Apache->server->push_handlers(
         PerlPostConfigHandler => \&add_my_version);
@@ -116,22 +133,12 @@
     }
 }
 
-sub test_apache_status {
-    ### Apache::Status tests
-    require Apache::Status;
-    require Apache::Module;
-    Apache::Status->menu_item(
-       'test_menu' => "Test Menu Entry",
-       sub {
-           my($r, $q) = @_; #request and CGI objects
-           return ["This is just a test entry"];
-       }
-    ) if Apache::Module::loaded('Apache::Status');
-}
-
 # cleanup files for TestHooks::startup which can't be done from the
 # test itself because the files are created at the server startup and
 # the test needing these files may run more than once (t/SMOKE)
+#
+# we need to run it at config phase since we need to cleanup before
+# the open_logs phase
 sub test_hooks_startup {
     require Apache::Test;
     my $dir = catdir Apache::Test::vars('documentroot'), qw(hooks startup);
@@ -144,22 +151,6 @@
 sub test_modperl_env {
     # see t/response/TestModperl/env.pm
     $ENV{MODPERL_EXTRA_PL} = __FILE__;
-}
-
-sub test_method_obj {
-    # see t/modperl/methodobj
-    require TestModperl::methodobj;
-    $TestModperl::MethodObj = TestModperl::methodobj->new;
-}
-
-
-sub ModPerl::Test::add_config {
-    my $r = shift;
-
-    #test adding config at request time
-    $r->add_config(['require valid-user']);
-
-    Apache::OK;
 }
 
 1;

Modified: perl/modperl/trunk/t/conf/post_config_startup.pl
Url: 
http://svn.apache.org/viewcvs/perl/modperl/trunk/t/conf/post_config_startup.pl?view=diff&rev=111555&p1=perl/modperl/trunk/t/conf/post_config_startup.pl&r1=111554&p2=perl/modperl/trunk/t/conf/post_config_startup.pl&r2=111555
==============================================================================
--- perl/modperl/trunk/t/conf/post_config_startup.pl    (original)
+++ perl/modperl/trunk/t/conf/post_config_startup.pl    Fri Dec 10 16:01:39 2004
@@ -31,12 +31,16 @@
 
 test_apache_size_limit();
 
+test_apache_status();
+
 test_loglevel();
 
 test_perl_ithreads();
 
 test_server_shutdown_cleanup_register();
 
+test_method_obj();
+
 
 
 ### only subs below this line ###
@@ -64,6 +68,19 @@
     require Apache::SizeLimit unless Apache::MPM->is_threaded;
 }
 
+sub test_apache_status {
+    ### Apache::Status tests
+    require Apache::Status;
+    require Apache::Module;
+    Apache::Status->menu_item(
+       'test_menu' => "Test Menu Entry",
+       sub {
+           my($r, $q) = @_; #request and CGI objects
+           return ["This is just a test entry"];
+       }
+    ) if Apache::Module::loaded('Apache::Status');
+}
+
 # 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
@@ -115,5 +132,19 @@
 
 }
 
+sub test_method_obj {
+    # see t/modperl/methodobj
+    require TestModperl::methodobj;
+    $TestModperl::MethodObj = TestModperl::methodobj->new;
+}
+
+sub ModPerl::Test::add_config {
+    my $r = shift;
+
+    #test adding config at request time
+    $r->add_config(['require valid-user']);
+
+    Apache::OK;
+}
 
 1;

Reply via email to