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/06/03 09:35:12 UTC

VOID => RUN_ALL or what?

[moving this issue to a separate thread]


 >> What about
 >> http://perl.apache.org/docs/2.0/user/handlers/intro.html#item_VOID
 >>
 >> Now we say:
 >>
 >> "Handlers of the type VOID will be all executed in the order they have
 >> been registered disregarding their return values. Though in mod_perl
 >> they are expected to return Apache::OK."
 >>
 >> Should we simply call them RUN_ALL?
 >
 >
 > yeah.  my thought was that this only affected the RUN_FIRST handlers.
 > all others should iterate through the stack until finished or error.

Yes. that was a side question, not strictly related to your proposal.

It just strikes me odd where we have: this handler if of type VOID, but in 
mod_perl we expect it to return Apache::OK. While we are changing this stacked 
handlers behavior, may be we should also decide on this one.

So I see two choices:

1. s/VOID/RUN_ALL/ in the docs

2. fix the code to ignore return values for VOID types and remove the doc 
comment of "we expect VOID handlers to return Apache::OK nevertheless"

I believe the second choice is the correct one. Since it really follows the 
Apache spec.

__________________________________________________________________
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: VOID => RUN_ALL or what?

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 
>>> while I tend to want to follow the apache specs closely, I'm not sure 
>>> about this.  the standard mod_perl meme is to always return a value 
>>> from a handler - by letting ignoring the return value of these and 
>>> letting the request proceed we're loosing functionality. for 
>>> instance, filters would no longer be able to use SERVER_ERROR to 
>>> throw errors, which strikes me as very wrong - what it an input 
>>> filter fails to process things correctly, the request is allowed to 
>>> proceed anyway and produce a valid response with possibly corrupt data?
>>
>>
>>
>> not if you die(). And if you die the client will get 500 in any case.
> 
> 
> so that's the idiom - return OK or die() from filters?  I guess that's 
> ok, but it really seems counterintuitive to me when you set up a filter as
> 
> PerlOutputFilterHandler
> 
> since it means that filter handlers behave differently than other 
> handlers.  well, I guess directive handlers also behave differently, but 
> I'm more inclined to accept that difference because it's config time and 
> not request time - here, we're saying that a subset of request handlers 
> behave differently than the rest wrt return codes, and something seems 
> funny about that.

There are:

PerlChildInitHandler         VOID

and

PerlInputFilterHandler       VOID
PerlOutputFilterHandler      VOID

which currently have the return type of VOID. The first one is a normal 
handler and we already have to deal with it. The filter handlers *are* 
different from all other handlers, because they don't stack in the way. And 
since they don't stack like others, the return value OK/DECLINED/DONE has no 
relevance. the return value in the case of errors is relevant. But don't 
forget that RUN_FIRST, RUN_ALL, VOID are different to facilitate stacked 
handlers, not error handling.

>>> as I excercise the filter mechanism, they seem to be a good first try 
>>> but a bit lacking in a few areas (this would be one) - I supposed it 
>>> makes sense to continue if the deflate filter fails, since you 
>>> already have the data, and if the header filter fails the request 
>>> obviously does as well, but for anything else ignoring return values 
>>> seems a bad idea.  I guess I'd probably prefer to do the right thing 
>>> over following Apache closely.
>>
>>
>>
>> Apache filters assert() when something is wrong. Which is equivalent 
>> to perl's die(), but assert() tends to segfault on me :(
>>
>> I suppose we have to first define what is the right thing, before 
>> going on.
> 
> 
> well, if there is an official API for this, then we should probably open 
> it up (if it isn't already :).  we could also offer shortcuts for the 
> streaming API - raw BB filters could have access to $filter->assert, 
> while streaming filters could just return SERVER_ERROR, which we could 
> trap and then call assert() transparently.

I don't think there is an official API in .h files it just calls assert(), 
assuming that some other filter has done wrong and this should be fixed before 
the filter reaches its users. Otherwise they would have chosen some more user 
friendly response.

> of course, if assert() is segfaulting then it's probably not the 
> preferred design :)

;)



__________________________________________________________________
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: VOID => RUN_ALL or what?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>> while I tend to want to follow the apache specs closely, I'm not sure 
>> about this.  the standard mod_perl meme is to always return a value 
>> from a handler - by letting ignoring the return value of these and 
>> letting the request proceed we're loosing functionality. for instance, 
>> filters would no longer be able to use SERVER_ERROR to throw errors, 
>> which strikes me as very wrong - what it an input filter fails to 
>> process things correctly, the request is allowed to proceed anyway and 
>> produce a valid response with possibly corrupt data?
> 
> 
> not if you die(). And if you die the client will get 500 in any case.

so that's the idiom - return OK or die() from filters?  I guess that's ok, 
but it really seems counterintuitive to me when you set up a filter as

PerlOutputFilterHandler

since it means that filter handlers behave differently than other handlers. 
  well, I guess directive handlers also behave differently, but I'm more 
inclined to accept that difference because it's config time and not request 
time - here, we're saying that a subset of request handlers behave 
differently than the rest wrt return codes, and something seems funny about 
that.

> 
>> as I excercise the filter mechanism, they seem to be a good first try 
>> but a bit lacking in a few areas (this would be one) - I supposed it 
>> makes sense to continue if the deflate filter fails, since you already 
>> have the data, and if the header filter fails the request obviously 
>> does as well, but for anything else ignoring return values seems a bad 
>> idea.  I guess I'd probably prefer to do the right thing over 
>> following Apache closely.
> 
> 
> Apache filters assert() when something is wrong. Which is equivalent to 
> perl's die(), but assert() tends to segfault on me :(
> 
> I suppose we have to first define what is the right thing, before going on.

well, if there is an official API for this, then we should probably open it 
up (if it isn't already :).  we could also offer shortcuts for the streaming 
API - raw BB filters could have access to $filter->assert, while streaming 
filters could just return SERVER_ERROR, which we could trap and then call 
assert() transparently.

of course, if assert() is segfaulting then it's probably not the preferred 
design :)

--Geoff


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


Re: VOID => RUN_ALL or what?

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 
>> It just strikes me odd where we have: this handler if of type VOID, 
>> but in mod_perl we expect it to return Apache::OK. While we are 
>> changing this stacked handlers behavior, may be we should also decide 
>> on this one.
>>
>> So I see two choices:
>>
>> 1. s/VOID/RUN_ALL/ in the docs
>>
>> 2. fix the code to ignore return values for VOID types and remove the 
>> doc comment of "we expect VOID handlers to return Apache::OK 
>> nevertheless"
>>
>> I believe the second choice is the correct one. Since it really 
>> follows the Apache spec.
> 
> 
> while I tend to want to follow the apache specs closely, I'm not sure 
> about this.  the standard mod_perl meme is to always return a value from 
> a handler - by letting ignoring the return value of these and letting 
> the request proceed we're loosing functionality. for instance, filters 
> would no longer be able to use SERVER_ERROR to throw errors, which 
> strikes me as very wrong - what it an input filter fails to process 
> things correctly, the request is allowed to proceed anyway and produce a 
> valid response with possibly corrupt data?

not if you die(). And if you die the client will get 500 in any case.

> as I excercise the filter mechanism, they seem to be a good first try 
> but a bit lacking in a few areas (this would be one) - I supposed it 
> makes sense to continue if the deflate filter fails, since you already 
> have the data, and if the header filter fails the request obviously does 
> as well, but for anything else ignoring return values seems a bad idea.  
> I guess I'd probably prefer to do the right thing over following Apache 
> closely.

Apache filters assert() when something is wrong. Which is equivalent to perl's 
die(), but assert() tends to segfault on me :(

I suppose we have to first define what is the right thing, before going on.

__________________________________________________________________
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: VOID => RUN_ALL or what?

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> It just strikes me odd where we have: this handler if of type VOID, but 
> in mod_perl we expect it to return Apache::OK. While we are changing 
> this stacked handlers behavior, may be we should also decide on this one.
> 
> So I see two choices:
> 
> 1. s/VOID/RUN_ALL/ in the docs
> 
> 2. fix the code to ignore return values for VOID types and remove the 
> doc comment of "we expect VOID handlers to return Apache::OK nevertheless"
> 
> I believe the second choice is the correct one. Since it really follows 
> the Apache spec.

while I tend to want to follow the apache specs closely, I'm not sure about this.  the 
standard mod_perl meme is to always return a value from a handler - by letting ignoring 
the return value of these and letting the request proceed we're loosing functionality. 
for instance, filters would no longer be able to use SERVER_ERROR to throw errors, which 
strikes me as very wrong - what it an input filter fails to process things correctly, the 
request is allowed to proceed anyway and produce a valid response with possibly corrupt data?

as I excercise the filter mechanism, they seem to be a good first try but a bit lacking in 
a few areas (this would be one) - I supposed it makes sense to continue if the deflate 
filter fails, since you already have the data, and if the header filter fails the request 
obviously does as well, but for anything else ignoring return values seems a bad idea.  I 
guess I'd probably prefer to do the right thing over following Apache closely.

--Geoff






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