0

I am using apache 2.4.54 and mod_perl 2.000011 on AWS Linux 2 (kernel 4.14.290-217.505.amzn2.x86_64)

The mod_perl v1 documentation has a section on Detecting Aborted Connections [https://perl.apache.org/docs/1.0/guide/debug.html#Detecting_Aborted_Connections]

When I use this slightly modified version in mod_perl v2

  my $n=0;
  while(1){
    $r->print(++$n);
    warn "written";
    $r->rflush;
    warn "flushed";
  
    last if $r->connection->aborted;
  
    sleep 1;
  }
  warn "done";
  return;

I get this in the log:

written at ...
flushed at ...
written at ...
flushed at ...
written at ...
[Wed Sep 28 15:25:39.476006 2022] [perl:error] [pid 28914] [client 192.168.146.180:60528] Apache2::RequestIO::rflush: (32) Broken pipe at ...

And the process hangs at that point. So, the aborted connection is detected by mod_perl and the error appears in the logs, but rflush never returns. If rflush is omitted, print will hang instead of returning when the buffer fills up.

I have not been able to find a way to get my process to stop when the connection is aborted. Has anyone else had this problem on mod_perl v2?

Is this a bug? Is there a workaround?

0 Answers0