On Sun, 11 Feb 2001, Bill Moseley wrote:

> I don't know why I have to learn this fresh again each time -- it appears
> I'm confusing mod_perl and mod_cgi.
>
> Let's see if I have this right.  Under mod_perl and apache >= 1.3.5 if the
> client drops the connection Apache will ignore it (well it might print an
> info message to the log file about "broken pipe").  This means a running
> mod_perl script will continue to run to completion, but the $r->prints go
> nowhere.
>
> The old Apache behavior of killing your running script can be restored
> using Apache::SIG -- which is something you would not want to use if you
> were doing anything besides displaying content, I'd think.
>
> $r->connection->aborted can be used to detect the aborted connection (as
> Stas shows in the Guide).  That sounds like a better way to deal with
> broken connections.
>
> Does all that sound right?

Yeah, it's a bit confusing.

Apache 1.3.6 and up -- STOP pressed:

the code keeps on running until it tries to read from or write to the
socket. the moment this happens, the script will stop the execution, and
run cleanup phase.

I think it's the same under mod_perl and mod_cgi. Am I right?

> Are there still issues with doing this?
>
>    local $SIG{PIPE} = sub { $aborted++ };

you do this because you want it to be mod_cgi back compatible? If not this
would be better:

END {
    $aborted++ if $r->connection->aborted;
}

And if you catch the signal you should do something about it other than
incrementing the count, right? like exit()

> Then mod_cgi I'm still unclear on.
>
> The cgi application does receive the SIGPIPE... well it did 1/2 hour ago
> before I rebooted my machine.  Now I can't seem to catch it.
> But, printing again after the SIGPIPE will kill the CGI script.

Well, it doesn't know that it was aborted before you try print something.

I guess the explanation in the guide is not clear enough and should be
revised, especially per Doug's reply... any volunteers?

_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://logilune.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


Reply via email to