svn commit: r109705 - /perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod

2004-12-03 Thread stas
Author: stas
Date: Fri Dec  3 09:10:12 2004
New Revision: 109705

URL: http://svn.apache.org/viewcvs?view=rev&rev=109705
Log:
document the compat level: $Apache::Server::Starting and 
$Apache::Server::ReStarting

Modified:
   perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod

Modified: perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod
Url: 
http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod?view=diff&rev=109705&p1=perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod&r1=109704&p2=perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod&r2=109705
==
--- perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod
(original)
+++ perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.podFri Dec 
 3 09:10:12 2004
@@ -776,6 +776,18 @@
 C<$Apache::Server::AddPerlVersion> is deprecated and exists only in
 C>.
 
+
+
+
+=head2 C<$Apache::Server::Starting> and C<$Apache::Server::ReStarting>
+
+C<$Apache::Server::Starting> and C<$Apache::Server::ReStarting> were
+replaced by
+C>.
+Though both exist in C>.
+
+
+
 =head2 Cwarn>
 
 Cwarn> has been removed and exists only in

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r109610 - /perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod

2004-12-03 Thread stas
Author: stas
Date: Thu Dec  2 16:52:21 2004
New Revision: 109610

URL: http://svn.apache.org/viewcvs?view=rev&rev=109610
Log:
cleanup

Modified:
   perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod

Modified: perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod
Url: 
http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod?view=diff&rev=109610&p1=perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod&r1=109609&p2=perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod&r2=109610
==
--- perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod (original)
+++ perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod Thu Dec  2 
16:52:21 2004
@@ -80,8 +80,6 @@
   $base_server_pool->cleanup_register(\&cleanup);
   sub cleanup { warn "server cleanup in $$\n" }
 
-C>.
-
 This is usually useful when some server-wide cleanup should be
 performed when the server is stopped or restarted.
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r109609 - /perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod

2004-12-03 Thread stas
Author: stas
Date: Thu Dec  2 16:51:28 2004
New Revision: 109609

URL: http://svn.apache.org/viewcvs?view=rev&rev=109609
Log:
signal handlers? not with apache2

Modified:
   perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod

Modified: perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod
Url: 
http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod?view=diff&rev=109609&p1=perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod&r1=109608&p2=perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod&r2=109609
==
--- perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod (original)
+++ perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod Thu Dec  2 
16:51:28 2004
@@ -441,6 +441,39 @@
 
 
 
+=head2 Using Signal Handlers
+
+3rd party Apache 2 modules should avoid using code relying on
+signals. This is because typical signal use is not thread-safe and
+modules which rely on signals may not work portably. Certain signals
+may still work for non-threaded mpms. For example C can be
+used under prefork MPM, but it won't work on any other MPM. Moreover
+the Apache developers don'tq guarantee that the signals that currently
+happen to work will continue to do so in the future Apache
+releases. So use them at your own risk.
+
+It should be possible to rework the code using signals to use an
+alternative solution, which works under threads. For example if you
+were using C to trap potentially long running I/O, you can
+modify the I/O logic for select/poll usage (or if you use APR I/O then
+set timeouts on the apr pipes or sockets). For example, Apache 1.3 on
+Unix made blocking I/O calls and relied on the parent process to send
+the SIGALRM signal to break it out of the I/O after a timeout expired.
+With Apache 2.0, APR support for timeouts on I/O operations is used so
+that signals or other thread-unsafe mechanisms are not necessary.
+
+CPU timeout handling is another example. It can be accomplished by
+modifying the computation logic to explicitly check for the timeout at
+intervals.
+
+
+
+
+
+
+
+
+
 =head1 Perl Specifics in the mod_perl Environment
 
 In the following sections we discuss the specifics of Perl behavior

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r109608 - /perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod

2004-12-03 Thread stas
Author: stas
Date: Thu Dec  2 16:48:15 2004
New Revision: 109608

URL: http://svn.apache.org/viewcvs?view=rev&rev=109608
Log:
add some white space

Modified:
   perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod

Modified: perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod
Url: 
http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod?view=diff&rev=109608&p1=perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod&r1=109607&p2=perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod&r2=109608
==
--- perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod (original)
+++ perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod Thu Dec  2 
16:48:15 2004
@@ -121,6 +121,8 @@
 
 =head1 Goodies Toolkit
 
+
+
 =head2 Environment Variables
 
 mod_perl sets the following environment variables:
@@ -165,6 +167,11 @@
 
 Any of these environment variables can be accessed via C<%ENV>.
 
+
+
+
+
+
 =head2 Threaded MPM or not?
 
 If the code needs to behave differently depending on whether it's
@@ -184,6 +191,10 @@
 This code prints the current thread id if running under a threaded
 MPM, otherwise it prints the process id.
 
+
+
+
+
 =head2 Writing MPM-specific Code
 
 If you write a CPAN module it's a bad idea to write code that won't
@@ -210,8 +221,13 @@
   }
 
 
+
+
+
 =head1 Code Developing Nuances
 
+
+
 =head2 Auto-Reloading Modified Modules with Apache::Reload
 
 META: need to port Apache::Reload notes from the guide here. but the
@@ -266,13 +282,23 @@
 
 Refer to the I manpage for more information.
 
+
+
+
 =head1 Integration with Apache Issues
 
 In the following sections we discuss the specifics of Apache behavior
 relevant to mod_perl developers.
 
+
+
+
+
 =head2 HTTP Response Headers
 
+
+
+
 =head3 Generating HTTP Response Headers
 
 The best approach for generating HTTP response headers is by using the
@@ -362,6 +388,8 @@
 
 
 
+
+
 =head3 Forcing HTTP Response Headers Out
 
 Apache 2.0 doesn't provide a method to force HTTP response headers
@@ -398,6 +426,7 @@
 
 
 
+
 =head2 Sending HTTP Response Body
 
 In mod_perl 2.0 a response body can be sent only during the response
@@ -411,6 +440,7 @@
 
 
 
+
 =head1 Perl Specifics in the mod_perl Environment
 
 In the following sections we discuss the specifics of Perl behavior
@@ -524,6 +554,9 @@
 at arbitrary times.
 
 
+
+
+
 =head2 Request-localized Globals
 
 mod_perl 2.0 provides two types of C handlers:
@@ -551,6 +584,8 @@
 
 
 
+
+
 =head2 C
 
 In the normal Perl code exit() is used to stop the program flow and
@@ -583,6 +618,8 @@
 
 =head1 C Handlers Family
 
+
+
 =head2 A Look Behind the Scenes
 
 If you have a CGI script F:
@@ -619,6 +656,8 @@
 
 
 
+
+
 =head2 Getting the C<$r> Object
 
 As explained in L
@@ -665,6 +704,9 @@
 The following sections discuss threading issues when running mod_perl
 under a threaded MPM.
 
+
+
+
 =head2 Thread-environment Issues
 
 The "only" thing you have to worry about your code is that it's
@@ -696,6 +738,8 @@
 (I) manpage.
 
 
+
+
 =head2 Deploying Threads
 
 This is actually quite unrelated to mod_perl 2.0. You don't have to
@@ -715,6 +759,8 @@
 discussed.  I.
 
 
+
+
 =head2 Shared Variables
 
 Global variables are only global to the interpreter in which they are
@@ -725,6 +771,11 @@
 using the I attribute when creating them. This feature is
 documented in the I
 (I) manpage.
+
+
+
+
+
 
 =head1 Maintainers
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r109607 - /perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod

2004-12-03 Thread stas
Author: stas
Date: Thu Dec  2 16:47:16 2004
New Revision: 109607

URL: http://svn.apache.org/viewcvs?view=rev&rev=109607
Log:
fix the server restart cleanup example

Modified:
   perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod

Modified: perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod
Url: 
http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod?view=diff&rev=109607&p1=perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod&r1=109606&p2=perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod&r2=109607
==
--- perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod (original)
+++ perl/modperl/docs/trunk/src/docs/2.0/user/coding/coding.pod Thu Dec  2 
16:47:16 2004
@@ -66,18 +66,22 @@
 C>
 on the pool object of choice. Here are some examples of its usage:
 
-To run something at the server shutdown and restart use
-C<$s-Epool-Ecleanup_register()> in F:
+To run something at the server shutdown and restart use a cleanup
+handler registered on
+C>
+in F:
 
   #PerlRequire startup.pl
   use Apache::ServerUtil ();
   use APR::Pool ();
   
   warn "parent pid is $$\n";
-  my $pool = Apache->server->pool;
-  $pool->cleanup_register(\&cleanup);
+  $base_server_pool = Apache::ServerUtil::base_server_pool();
+  $base_server_pool->cleanup_register(\&cleanup);
   sub cleanup { warn "server cleanup in $$\n" }
 
+C>.
+
 This is usually useful when some server-wide cleanup should be
 performed when the server is stopped or restarted.
 
@@ -110,6 +114,9 @@
 In this example the cleanup callback gets called, when C<$pool> goes
 out of scope and gets destroyed. This is very similar to OO C
 method.
+
+
+
 
 
 =head1 Goodies Toolkit

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r109606 - /perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod

2004-12-03 Thread stas
Author: stas
Date: Thu Dec  2 16:46:50 2004
New Revision: 109606

URL: http://svn.apache.org/viewcvs?view=rev&rev=109606
Log:
fix the example

Modified:
   perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod

Modified: perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod
Url: 
http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod?view=diff&rev=109606&p1=perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod&r1=109605&p2=perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod&r2=109606
==
--- perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod  
(original)
+++ perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod  Thu Dec 
 2 16:46:50 2004
@@ -213,7 +213,7 @@
 code at the server startup:
 
   $base_server_pool = Apache::ServerUtil::base_server_pool();
-  $base_server_pool->cleanup_register(do_my_cleanups());
+  $base_server_pool->cleanup_register(\&do_my_cleanups);
 
 It's necessary to run this code at the server startup (normally
 F. Cleanup handlers registered after the

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r109605 - /perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod

2004-12-03 Thread stas
Author: stas
Date: Thu Dec  2 16:43:09 2004
New Revision: 109605

URL: http://svn.apache.org/viewcvs?view=rev&rev=109605
Log:
fix the incorrect $s->register_cleanup entry


Modified:
   perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod

Modified: perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod
Url: 
http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod?view=diff&rev=109605&p1=perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod&r1=109604&p2=perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod&r2=109605
==
--- perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.pod
(original)
+++ perl/modperl/docs/trunk/src/docs/2.0/user/porting/compat.podThu Dec 
 2 16:43:09 2004
@@ -788,19 +788,31 @@
 
 =head1 Server Object Methods
 
+
+
 =head2 C<$s-Eregister_cleanup>
 
 C<$s-Eregister_cleanup> has been replaced with
 C which accepts the pool object as the
 first argument instead of the server object. e.g.:
 
-  sub cleanup_callback { my $data = shift; ... }
-  $s->pool->cleanup_register(\&cleanup_callback, $data);
+  use Apache::ServerUtil ();
+  sub cleanup_callback {
+  my($pool, $s) = @_;
+  # your code comes here
+  Apache::OK;
+  }
+  $s->push_handlers(PerlChildExitHandler => \&my_access);
+
+where the arguments are the pool and server objects.
 
-where the last argument C<$data> is optional, and if supplied will be
-passed as the first argument to the callback function.
+See also
+C>.
 
-See the C> manpage.
+In order to register a cleanup handler to be run only once when the
+main server (not each child process) shutsdown, you can register a
+cleanup handler on the
+C>.
 
 
 =head2 C<$s-Euid>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r109601 - /perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod

2004-12-03 Thread stas
Author: stas
Date: Thu Dec  2 16:29:02 2004
New Revision: 109601

URL: http://svn.apache.org/viewcvs?view=rev&rev=109601
Log:
typos

Modified:
   perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod

Modified: perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod
Url: 
http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod?view=diff&rev=109601&p1=perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod&r1=109600&p2=perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod&r2=109601
==
--- perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod   
(original)
+++ perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod   Thu Dec 
 2 16:29:02 2004
@@ -429,6 +429,10 @@
 
 
 
+
+
+
+
 =head1 Startup Apache Commands
 
 Some notes on how Apache start/restart Apache commands affect
@@ -437,7 +441,7 @@
 META: not sure this is the best place for this section, but start some
 notes here.
 
-Apache reparses F at least once for B of the
+Apache re-parses F at least once for B of the
 following commands (and will run any mod_perl code found in it).
 
 
@@ -478,10 +482,13 @@
 
 =item httpd -k stop
 
-Similarly to C you may encounter all kind of issue
+Similarly to C you may encounter all kind of issues
 here, due to the C signal.
 
 =back
+
+
+
 
 
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r109600 - /perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod

2004-12-03 Thread stas
Author: stas
Date: Thu Dec  2 16:27:02 2004
New Revision: 109600

URL: http://svn.apache.org/viewcvs?view=rev&rev=109600
Log:
document the various issues with httpd -k (...)

Modified:
   perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod

Modified: perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod
Url: 
http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod?view=diff&rev=109600&p1=perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod&r1=109599&p2=perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod&r2=109600
==
--- perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod   
(original)
+++ perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod   Thu Dec 
 2 16:27:02 2004
@@ -428,6 +428,64 @@
   PerlChildExitHandler  MyApache::StartupLog::child_exit
 
 
+
+=head1 Startup Apache Commands
+
+Some notes on how Apache start/restart Apache commands affect
+mod_perl.
+
+META: not sure this is the best place for this section, but start some
+notes here.
+
+Apache reparses F at least once for B of the
+following commands (and will run any mod_perl code found in it).
+
+
+=over
+
+=item httpd -k start
+
+No special issues here.
+
+Apache start and immediately restarts itself.
+
+
+
+=item httpd -k restart
+
+This will abort any processed requests and restart the server.
+
+All kind of problems could be encountered here, including segfaults
+and other kind of crashes. This is because when the C signal
+is sent, things in process will be aborted.
+
+Avoid using this method.
+
+Alternatively C can be executed C.
+
+
+
+=item httpd -k graceful
+
+No issues here. Apache starts and restarts itself just like with
+C, but it waits for the existing requests to finish before
+killing them.
+
+Alternatively C can be executed C.
+
+
+=item httpd -k stop
+
+Similarly to C you may encounter all kind of issue
+here, due to the C signal.
+
+=back
+
+
+
+
 =head1 Maintainers
 
 Maintainer is the person(s) you should contact with updates,

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r109599 - /perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod

2004-12-03 Thread stas
Author: stas
Date: Thu Dec  2 16:16:32 2004
New Revision: 109599

URL: http://svn.apache.org/viewcvs?view=rev&rev=109599
Log:
fix pod

Modified:
   perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod

Modified: perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod
Url: 
http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod?view=diff&rev=109599&p1=perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod&r1=109598&p2=perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod&r2=109599
==
--- perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod   
(original)
+++ perl/modperl/docs/trunk/src/docs/2.0/user/handlers/server.pod   Thu Dec 
 2 16:16:32 2004
@@ -303,7 +303,7 @@
 
 
 
-=head2 PerlPostConfigHandler
+=head2 C
 
 The I phase happens right after Apache has processed the
 configuration files, before any child processes were spawned (which
@@ -331,7 +331,7 @@
   }
 
 As you can see, its arguments are identical to the
-L> phase's handler. In this
+I> phase's handler. In this
 example handler we don't do much, but logging that the configuration
 was completed and returning right away.
 
@@ -356,7 +356,7 @@
 
 
 
-=head2 PerlChildInitHandler
+=head2 C
 
 The I phase happens immediately after the child process is
 spawned. Each child process (not a thread!) will run the hooks of this
@@ -396,7 +396,7 @@
 
 
 
-=head2 PerlChildExitHandler
+=head2 C
 
 Opposite to the I phase, the I phase is
 executed before the child process exits. Notice that it happens only

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



svn commit: r109598 - /perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod

2004-12-03 Thread stas
Author: stas
Date: Thu Dec  2 16:13:01 2004
New Revision: 109598

URL: http://svn.apache.org/viewcvs?view=rev&rev=109598
Log:
document new API:
- base_server_pool
- restart_count

Modified:
   perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod

Modified: perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod
Url: 
http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod?view=diff&rev=109598&p1=perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod&r1=109597&p2=perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod&r2=109598
==
--- perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod  
(original)
+++ perl/modperl/docs/trunk/src/docs/2.0/api/Apache/ServerUtil.pod  Thu Dec 
 2 16:13:01 2004
@@ -45,6 +45,14 @@
   
   # extend HTTP to support a new method
   $s->method_register('NEWGET');
+  
+  # register server shutdown callback
+  $base_server_pool = Apache::ServerUtil::base_server_pool();
+  $base_server_pool->cleanup_register(sub { Apache::OK });
+  
+  # do something only when the server restarts
+  my $cnt = Apache::ServerUtil::restart_count();
+  do_something_once() if $cnt > 1;
 
 
 
@@ -179,6 +187,44 @@
 
 
 
+
+=head2 C
+
+Get the base server pool object:
+
+  $base_server_pool = Apache::ServerUtil::base_server_pool();
+
+=over 4
+
+=item ret: C
+( C> )
+
+=item since: 1.99_18
+
+=back
+
+This pool can be used to register a callback to be run once at the
+server shutdown (compared to
+C>
+which will execute the callback for each exiting child process).
+
+For example in order to arrange the function C to be
+run every time the server shuts down (or restarts), run the following
+code at the server startup:
+
+  $base_server_pool = Apache::ServerUtil::base_server_pool();
+  $base_server_pool->cleanup_register(do_my_cleanups());
+
+It's necessary to run this code at the server startup (normally
+F. Cleanup handlers registered after the
+C>
+phase will be silently ignored.
+
+
+
+
+
+
 =head2 C
 
 C<$s-Edir_config()> provides an interface for the per-server
@@ -500,6 +546,92 @@
 Anonymous functions:
 
   $s->push_handlers(PerlLogHandler => sub { return Apache::OK });
+
+
+
+
+
+
+
+=head2 C
+
+How many times the server was restarted.
+
+  $restart_count = Apache::ServerUtil::restart_count();
+
+=over 4
+
+=item ret: C ( number )
+
+=item since: 1.99_18
+
+=back
+
+The following demonstration should make it clear what values to expect
+from this function. Let's add the following code to F, so
+it's run every time F is parsed:
+
+  use Apache::ServerUtil ();
+  my $cnt = Apache::ServerUtil::restart_count();
+  open my $fh, ">>/tmp/out" or die "$!";
+  print $fh "cnt: $cnt\n";
+  close $fh;
+
+Now let's run a series of server starts and restarts and look at what
+is logged into F:
+
+  % httpd -k start
+  cnt: 1
+  cnt: 2
+  
+  % httpd -k graceful
+  cnt: 1
+  cnt: 3
+  
+  % httpd -k graceful
+  cnt: 1
+  cnt: 4
+  
+  % httpd -k stop
+  cnt: 1
+
+Remembering that L, we can
+see that the C goes from 1 to 2 during the server
+start. Moreover we can see that every operation forces the parsing of
+F and therefore reinitialization of mod_perl (and running
+all the code found in F). This happens even when the
+server is shutdown via C.
+
+What conclusions can be drawn from this demonstration:
+
+=over
+
+=item *
+
+C returns 1 every time some C<-k>
+command is passed to Apache (or C or some alternative
+signal is received).
+
+=item *
+
+At all other times the count will be 2 or higher. So for example on
+graceful restart the count will be 3 or higher.
+
+=back
+
+For example if you want to run something every time C is run
+you just need to check whether C returns 1:
+
+  my $cnt = Apache::ServerUtil::restart_count();
+  do_something() if $cnt == 1;
+
+To do something only when server restarts (C or
+C, check whether C is bigger than
+1:
+
+  my $cnt = Apache::ServerUtil::restart_count();
+  do_something() if $cnt > 1;
 
 
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]