You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Stas Bekman <st...@stason.org> on 2004/06/30 03:14:34 UTC

what's the condition to stop reading input in connection handlers?

The doc for ap_get_brigade goes:

/**
  * Get the current bucket brigade from the next filter on the filter
  * stack.  The filter returns an apr_status_t value.  If the bottom-most
  * filter doesn't read from the network, then ::AP_NOBODY_READ is returned.
  * The bucket brigade will be empty when there is nothing left to get.

However I see a situation where, the client went away long time ago and the 
connection handler continues getting APR::EOF and the returned brigade is not 
empty (some empty IMMORTAL bucket) when calling ap_get_brigade and a custom 
output filter is installed.

What's the right condition to abort the loop? e.g in the pseudo code:

     while (1) {
         my $rc = $c->input_filters->get_brigade($bb, Apache::MODE_GETLINE);

         last if $bb->is_empty;
         # process $bb...
         last if $rc == APR::EOF;
    }

should I just check for EOF and not check whether the brigade is empty? If so, 
can EOF come and the brigade not being empty? It looks like I need to check both.

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: what's the condition to stop reading input in connection handlers?

Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:
> The doc for ap_get_brigade goes:
> 
> /**
>  * Get the current bucket brigade from the next filter on the filter
>  * stack.  The filter returns an apr_status_t value.  If the bottom-most
>  * filter doesn't read from the network, then ::AP_NOBODY_READ is returned.
>  * The bucket brigade will be empty when there is nothing left to get.
> 
> However I see a situation where, the client went away long time ago and 
> the connection handler continues getting APR::EOF and the returned 
> brigade is not empty (some empty IMMORTAL bucket) when calling 
> ap_get_brigade and a custom output filter is installed.
> 
> What's the right condition to abort the loop? e.g in the pseudo code:
> 
>     while (1) {
>         my $rc = $c->input_filters->get_brigade($bb, Apache::MODE_GETLINE);
> 
>         last if $bb->is_empty;
>         # process $bb...
>         last if $rc == APR::EOF;
>    }
> 
> should I just check for EOF and not check whether the brigade is empty? 
> If so, can EOF come and the brigade not being empty? It looks like I 
> need to check both.

So I take it that it's OK to rely on the assumption that if APR_EOF is 
returned by ap_get_brigade(), then the returned brigade contains no (useful) 
data and the read loop can be broken.

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com