>> my $fileno = $r->connection->fileno;
>>
>> $s = IO::Select->new($fileno);
>>
>> die "aborted" if grep { m/$fileno/ } $s->can_read(1);
>
>
>Hmm, does this actually work Geoff? What happens if mod_perl is running
>as a back-end? In this case $r->connection->aborted doesn't work even if
>you print.
yes, it worked for me. actually, I guess I should have been clearer - this
has nothing to do with $c->aborted or $r->print (well, on the outside
anyway). for $c->aborted you have to wait for Apache to flush the print
buffers. actually, in my tests $r->rflush didn't help things behave - only
$|=1 did.
$s->can_read should always work because Apache marks the client output file
descriptor with a zero-length packet for reading when the client dies. so,
when you can read from where you ought to be writing, you can assume a
broken connection.
at least this is my understanding. wish I could take credit, though - Eric
discovered/documented this one a while ago:)
at any rate, this worked for me just fine in some tests, but I never tested
it against a front-end/back-end setup. seems like you would never be able
to detect a broken client connection from in a proxy setup anyway, but
that's not my area to comment on...
--Geoff