I'm using a "check_connection" subroutine to check if a user has hit the stop button in his browser to abort the mod_perl handler. I actually found the solution for the problem while writing this email, but wanted to inform the list anyway, as the examples on the net all contain an error under this condition. For completeness, I also include the "check_connection" subroutine :
sub check_connection() { my $connection = Apache->request->connection; abort("connection aborted") if($connection->aborted); my $fileno = $connection->fileno(0); vec(my $rin = '', $fileno, 1) = 1; select(my $rout = $rin, undef, undef, 0);
Is this better that IO::Select in [2]?
abort("connection aborted") if(vec($rout, $fileno, 1) eq 1); return 1 }
The problem is that under mod_gzip, the output socket points to a "spool" file, used by mod_gzip. The examples on the net simply use $c->fileno, which will return the output file-descriptor (as written in the docs). When using mod_gzip, the check_function will not behave correctly. So for the "connection_check" function you must pass 0 to fileno to get the input file-descriptor.
Interesting.
But I guess this technique still want work in the proxied front-end <-> back-end setup, since the front end doesn't abort the connection to the back-end, even if the client did abort it.
Maybe someone could add a small note to the documentation, that for checking "disconnects" you need to check the input file-descriptor and not the output fd, as suggested by (nearly?) all examples. I'm not 100% sure if it makes any difference by using the input fd rather than the output fd, but under normal conditions they are both the same, right!?
Feel free to grab the source pod (right top corner of the page) and send the patch as you see it fit. You could also annotate the whole snippet while you are at it :) Thanks.
Also take a look at: http://perl.apache.org/docs/1.0/guide/debug.html#Handling_the__User_pressed_Stop_button__case
It's directly related and should probably be merged into one item. or at least xref each other.
[1] http://perl.apache.org/docs/1.0/api/Apache.html#_c_E_gt_fileno____direction___
-
[2] http://perl.apache.org/docs/1.0/guide/snippets.html#Detecting_a_Client_Abort
-- __________________________________________________________________ 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://ticketmaster.com