You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2003/01/12 03:26:18 UTC

Re: cvs commit: modperl-2.0 Changes

stas@apache.org wrote:
> stas        2003/01/11 18:21:37
> 
>   Modified:    src/modules/perl modperl_filter.c
>                .        Changes
>   Log:
>   Request input and output filters are now getting the EOS bucket, which
>   wasn't passed through before. Now the context can be flushed on
>   EOS.

Doug, since the logic for skipping EOS wasn't explained I've removed it. 
The reason for always passing EOS to the filter is that so it knows when 
the context can be flushed. Before that patch it was impossible.

Also notice that the EOS bucket can be a part of a bb with other buckets 
as well as to be the only one. So there shouldn't be any special 
handling for this.

This change will possibly break some of the code where people have 
erroneously relied on the filter to be called once during request time. 
I'll shortly update the tests and the online docs to show the proper way 
to handle things.

>   Revision  Changes    Path
>   1.42      +4 -21     modperl-2.0/src/modules/perl/modperl_filter.c
>   
>   Index: modperl_filter.c
>   ===================================================================
>   RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v
>   retrieving revision 1.41
>   retrieving revision 1.42
>   diff -u -r1.41 -r1.42
>   --- modperl_filter.c	12 Jan 2003 02:15:58 -0000	1.41
>   +++ modperl_filter.c	12 Jan 2003 02:21:37 -0000	1.42
>   @@ -383,24 +383,14 @@
>        return modperl_wbucket_write(&filter->wbucket, buf, len);
>    }
>    
>   -#define APR_BRIGADE_IS_EOS(bb) \
>   -APR_BUCKET_IS_EOS(APR_BRIGADE_FIRST(bb))
>   -
>    apr_status_t modperl_output_filter_handler(ap_filter_t *f,
>                                               apr_bucket_brigade *bb)
>    {
>        modperl_filter_t *filter;
>        int status;
>    
>   -    if (APR_BRIGADE_IS_EOS(bb)) {
>   -        /* XXX: see about preventing this in the first place */
>   -        MP_TRACE_f(MP_FUNC, "first bucket is EOS, skipping callback\n");
>   -        return ap_pass_brigade(f->next, bb);
>   -    }
>   -    else {
>   -        filter = modperl_filter_new(f, bb, MP_OUTPUT_FILTER_MODE);
>   -        status = modperl_run_filter(filter, 0, 0, 0);
>   -    }
>   +    filter = modperl_filter_new(f, bb, MP_OUTPUT_FILTER_MODE);
>   +    status = modperl_run_filter(filter, 0, 0, 0);
>    
>        switch (status) {
>          case OK:
>   @@ -421,15 +411,8 @@
>        modperl_filter_t *filter;
>        int status;
>    
>   -    if (APR_BRIGADE_IS_EOS(bb)) {
>   -        /* XXX: see about preventing this in the first place */
>   -        MP_TRACE_f(MP_FUNC, "first bucket is EOS, skipping callback\n");
>   -        return APR_SUCCESS;
>   -    }
>   -    else {
>   -        filter = modperl_filter_new(f, bb, MP_INPUT_FILTER_MODE);
>   -        status = modperl_run_filter(filter, mode, block, readbytes);
>   -    }
>   +    filter = modperl_filter_new(f, bb, MP_INPUT_FILTER_MODE);
>   +    status = modperl_run_filter(filter, mode, block, readbytes);
>    
>        switch (status) {
>          case OK:
>   
>   
>   
>   1.98      +4 -0      modperl-2.0/Changes
>   
>   Index: Changes
>   ===================================================================
>   RCS file: /home/cvs/modperl-2.0/Changes,v
>   retrieving revision 1.97
>   retrieving revision 1.98
>   diff -u -r1.97 -r1.98
>   --- Changes	11 Jan 2003 04:17:58 -0000	1.97
>   +++ Changes	12 Jan 2003 02:21:37 -0000	1.98
>   @@ -10,6 +10,10 @@
>    
>    =item 1.99_09-dev
>    
>   +Request input and output filters are now getting the EOS bucket, which
>   +wasn't passed through before. Now the context can be flushed on
>   +EOS. [Stas]
>   +
>    =item 1.99_08 - January 10, 2003
>    
>    Correct ModPerl::RegistryCooker to reset %INC, after compile for .pl
>   
>   
>   


-- 


__________________________________________________________________
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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: cvs commit: modperl-2.0 Changes

Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:
> stas@apache.org wrote:
> 
>> stas        2003/01/11 18:21:37
>>
>>   Modified:    src/modules/perl modperl_filter.c
>>                .        Changes
>>   Log:
>>   Request input and output filters are now getting the EOS bucket, which
>>   wasn't passed through before. Now the context can be flushed on
>>   EOS.
> 
> 
> Doug, since the logic for skipping EOS wasn't explained I've removed it. 
> The reason for always passing EOS to the filter is that so it knows when 
> the context can be flushed. Before that patch it was impossible.
> 
> Also notice that the EOS bucket can be a part of a bb with other buckets 
> as well as to be the only one. So there shouldn't be any special 
> handling for this.
> 
> This change will possibly break some of the code where people have 
> erroneously relied on the filter to be called once during request time. 
> I'll shortly update the tests and the online docs to show the proper way 
> to handle things.

I've partially restored this functionality and the call to the filter will 
be skipped only if EOS has been sent already. Which unfortunately will be 
detected only if the streaming interface is used. I'll commit the solution 
soonish, together with the implementation of streaming interface for input 
filters.

The real problem lies in the buggy httpd, which sends the EOS bucket more 
than once for input filters. I've reported the bug to httpd-dev, but we 
will have to deal with earlier versions of httpd as well. Also it's always 
possible that mod_perl will have to interact with other buggy filters, so 
it's good to have an inhouse protection and always send eos only once.

This protection works only in the streaming interface. Bucket brigades 
perl filters will have to use their own ctx to remember whether they have 
passed-through the EOS bucket already. The only solution I can think of 
for bb filters, is to provide a special interface for sending eos buckets, 
which will remember whether the eos bucket was already sent in the current 
context. This will reduce to code clutter, but will make the interface not 
1:1 with C API. Of course users will still be able to pass EOS buckets by 
themselves and then they will have to take care of multiple EOS buckets 
themselves.

__________________________________________________________________
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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org