On Wed, 9 Aug 2000, Michael Peppler wrote:

> Hi,
> 
> We're seeing a number of requests where the write from apache to the
> client browser times out and the SIGALRM signal fires. Our
> Apache::Registry scripts in that case don't clean up correctly,
> leaving session lock files around, which of course causes that
> particular session to be screwed up for a while.
> 
> My question is would a Cleanup handler still be called in this case?

yes.  but, the proper solution is for mod_perl to change usage of
hard_timeout() to soft_timeout().  hard_timeout() does a longjmp out to
the accept loop, whereas soft_timeout() just sets $r->connection->aborted
to 1, so all apache i/o calls become noops, but the script continues to
run until finished.  i don't know why we used hard_timeout() in the first
place.  if a script wants to abort, they'll need to do it themselves,
something along the lines of:

$r->print('foo');
die if $r->connection->aborted;

Index: Apache/Apache.pm
===================================================================
RCS file: /home/cvs/modperl/Apache/Apache.pm,v
retrieving revision 1.52
diff -u -r1.52 Apache.pm
--- Apache/Apache.pm    2000/08/15 04:35:13     1.52
+++ Apache/Apache.pm    2000/08/31 05:38:36
@@ -68,7 +68,7 @@
     $_[1] ||= "";
     #$_[1] = " " x $bufsiz unless defined $_[1]; #XXX?
 
-    $r->hard_timeout("Apache->read");
+    $r->soft_timeout("Apache->read");
 
     while($bufsiz) {
        $nrd = $r->read_client_block($buf, $bufsiz) || 0;
@@ -113,7 +113,7 @@
        return 0;
     }
 
-    $r->hard_timeout("Apache->read");
+    $r->soft_timeout("Apache->read");
     
     while($bufsiz) {
        $nrd = $r->get_client_block($buf, $bufsiz) || 0;
@@ -425,7 +425,7 @@
 looping until it gets all of C<$bytes_to_read> or a timeout happens.
 
 In addition, this method sets a timeout before reading with
-C<$r-E<gt>hard_timeout>.
+C<$r-E<gt>soft_timeout>.
 
 =item $r->get_remote_host
 
@@ -909,7 +909,7 @@
 =item $r->print( @list )
 
 This method sends data to the client with C<$r-E<gt>write_client>, but first
-sets a timeout before sending with C<$r-E<gt>hard_timeout>. This method is
+sets a timeout before sending with C<$r-E<gt>soft_timeout>. This method is
 called instead of CORE::print when you use print() in your mod_perl programs.
 
 This method treats scalar references specially. If an item in @list is a
Index: src/modules/perl/Apache.xs
===================================================================
RCS file: /home/cvs/modperl/src/modules/perl/Apache.xs,v
retrieving revision 1.105
diff -u -r1.105 Apache.xs
--- src/modules/perl/Apache.xs  2000/08/31 03:39:45     1.105
+++ src/modules/perl/Apache.xs  2000/08/31 05:38:48
@@ -1033,7 +1033,7 @@
     }
     else {
        CV *cv = GvCV(gv_fetchpv("Apache::write_client", FALSE, SVt_PVCV));
-       hard_timeout("mod_perl: Apache->print", r);
+       soft_timeout("mod_perl: Apache->print", r);
        PUSHMARK(mark);
 #ifdef PERL_OBJECT
        (void)(*CvXSUB(cv))(cv, pPerl); /* &Apache::write_client; */

Reply via email to