Re: mod_perl, mod_gzip and connection->fileno

[prev] [thread] [next] [Date index for 2005/02/24]

From: Geoffrey Young
Subject: Re: mod_perl, mod_gzip and connection->fileno
Date: 14:43 on 24 Feb 2005

>> =head1 Detecting a Client Abort
>>
>>  # IsClientConnected? Might already be disconnected for busy
>>  # site, if a user hits stop/reload
>>
>>  my $conn = $r->connection;
>>  my $is_connected = $conn->aborted ? 0 : 1;
>>  if($is_connected) {
>>      if (defined(my $fileno = $conn->fileno(0))) {
>>          my $s = IO::Select->new($fileno);
>>          $is_connected = $s->can_read(0) ? 0 : 1;
>>      } else { $is_connected = 0 }
>>  }
>>
>> You may also implement this without using the IO::Select module
>>
>>  my $is_connected = 1;
>>  my $conn = $r->connection;
>>  # check Apache::Connection abort status
>>  if($conn->aborted) { $is_connected = 0 }
>>  else {
>>      if (defined(my $fileno = $conn->fileno(0))) {
>>          vec(my $rbit = '', $fileno, 1) = 1; # enable fd in vector table
>>          select($rbit, undef, undef, 0); # select for readable handles
>>          $is_connected = vec($rbit, $fileno, 1) ? 0 : 1; # check fd in
>> vector table
>>      } else { $is_connected = 0 }
>>  }
> 
> 
> looks good.

I think this is a more elegant solution

  http://www.modperlcookbook.org/code/ch04/Cookbook/CheckConnection.pm

--Geoff

(message missing)

mod_perl, mod_gzip and connection->fileno
Marcel Greter 22:11 on 18 Feb 2005

Re: mod_perl, mod_gzip and connection->fileno
Stas Bekman 00:58 on 19 Feb 2005

Re: mod_perl, mod_gzip and connection->fileno
Marcel Greter 04:14 on 19 Feb 2005

Re: mod_perl, mod_gzip and connection->fileno
Stas Bekman 04:18 on 19 Feb 2005

Re: mod_perl, mod_gzip and connection->fileno
Marcel Greter 04:41 on 19 Feb 2005

Re: mod_perl, mod_gzip and connection->fileno
Stas Bekman 05:12 on 19 Feb 2005

Re: mod_perl, mod_gzip and connection->fileno
Geoffrey Young 20:13 on 24 Feb 2005

Re: mod_perl, mod_gzip and connection->fileno
Geoffrey Young 14:43 on 24 Feb 2005

Generated at 22:43 on 24 Feb 2005 by mariachi v0.52