I'm trying to determine how to have my mod_perl apache server properly catch a SIGPIPE signal in a timely manner.

My environment is Apache/2.0.49 (Fedora) and mod_perl 2.

In my conf.d/perl.conf file I have the following:
PerlFixupHandler Apache::SIG2

I have created Apache::SIG2.pm as follows:
----------
package Apache::SIG2;

use strict;
use Apache::RequestRec;
use Apache::Const;

sub handler {
    my $r = shift;
    if (!$r->main) {
        print STDERR ("In handler\n");
        $SIG{PIPE} = \&PIPE;
    }
    return OK;
}

sub PIPE {
     my($signal) = @_;
     print STDERR ("signal caught = $signal\n");
}

1;
----------

For ease of tracing, I have set up my apache environment so as to have only one mod_perled httpd child running.

When an httpd request is made, I see "In handler" so I know that a SIGPIPE signal should be caught.

However, when I cause a condition that generates a SIGPIPE, such as pressing the browser stop button, my SIGPIPE handler, PIPE, is not immediately called. Strangely, PIPE is called the next time a new httpd request is handled by this same httpd child. I ran my httpd server with strace and I do see the following at the time the connection is broken:
--- SIGPIPE (Broken pipe) @ 0 (0) ---
so the SIGPIPE is being generated at the appropriate time, but the mod_perled httpd child is not detecting it (or at least not executing my signal handler routine) until the next httpd request.


The http request I make to test this is a non_modperl CGI generating lots of output with autoflush turned on ($|=1) so that there is plenty of output being sent over the pipe that will be broken by me clicking the browser stop button.

Under Apache/1.3.27 and mod_perl/1.27 I had a very similar PerlFixupHandler in place (a slightly modified Apache::SIG.pm) to catch a SIGPIPE and the SIGPIPE was caught and my signal handler executed at the correct time... when the connection was broken by the browser. I would like to be able to continue to catch a SIGPIPE like this under Apache2/modperl2. Can anyone offer any suggestions as to how to get my signal handler, PIPE, executed as soon as the SIGPIPE is generated?

Thanks
Jim Albert



--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Reply via email to