You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Matthew Bernstein <ma...@tanima.co.uk> on 2002/08/13 17:36:32 UTC

[mp2.0, NT] Environment variables disappearing in filter

I've been having an ongoing problem with mod_perl under NT for a while now (different mp2 builds, different apache builds, different perl builds).

I'm using a PerlOutputFilterHandler which is filtering the output of a perl-script.

If the output of the script is sufficient (this varies, but ~6k), then the POFH receives a complete environment.

Otherwise, the environment consists only of MOD_PERL, PATH and GATEWAY_INTERFACE (a bit like PerlOptions -SetupEnv).  The script seems to always get everything.

Anything I can try?  I've been trying to debug the problem, but I feel like I'm looking for a needle in a haystack given I'm totally unfamiliar with the modperl source.

Many thanks,
Matthew.

Re: [mp2.0, NT] Environment variables disappearing in filter

Posted by Matthew Bernstein <ma...@tanima.co.uk>.
> Now this doesn't solve your problem. You want the env to be set in
> filters. We need to spec how this should work first. Doug?

Thanks for the explaination.

I had a feeling it was due to some sort of buffering, but I thought the
error was when I didn't get the environment, rather than when I actually
did.

It was useful to have them, as I was using the filter to display a menu at
the top of each page (be it script, or static html), and the content of the
menu depended on REMOTE_USER (and in part, REMOTE_ADDR).

In mod_perl, i was using PerlRunFilter to process a script, and then chain
to the menu "filter", but perhaps there's a better way in mod_perl2 of doing
this (for better, read _correct_ ;) )...?

Thanks,
Matthew.


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


Re: [mp2.0, NT] Environment variables disappearing in filter

Posted by Stas Bekman <st...@stason.org>.
Matthew Bernstein wrote:
> I've been having an ongoing problem with mod_perl under NT for a while 
> now (different mp2 builds, different apache builds, different perl builds).
>  
> I'm using a PerlOutputFilterHandler which is filtering the output of a 
> perl-script.
>  
> If the output of the script is sufficient (this varies, but ~6k), then 
> the POFH receives a complete environment.
>  
> Otherwise, the environment consists only of MOD_PERL, PATH and 
> GATEWAY_INTERFACE (a bit like PerlOptions -SetupEnv).  The script seems 
> to always get everything.
>  
> Anything I can try?  I've been trying to debug the problem, but I feel 
> like I'm looking for a needle in a haystack given I'm totally unfamiliar 
> with the modperl source.

This is a global issue, not particular to NT. What happens is that the 
env behavior for filters is not defined. You observe the following:

when you send a response with a little data it gets buffered first, the 
response handler finishes and then the output filter is called. When the 
handler is finished it resets the environment, and therefore the filter 
doesn't see it.

when you send a response with more data than fits into the buffer, the 
output filter is getting called on the first buffer while you are still 
inside the response handler. therefore the filter sees the extended env, 
but the last buffer won't see it anymore (unless flushed), because the 
handler will finish before it's flushed.

You can observe the same behavior by forcing flush:

     $r->print("x");
     $r->rflush;
     $r->print("x");

The following section should make things more clear:
http://perl.apache.org/docs/2.0/user/handlers/handlers.html#All_in_One_Filter

Now this doesn't solve your problem. You want the env to be set in 
filters. We need to spec how this should work first. Doug?

My initial thought is that it's going to be very expensive to set the 
env (like we do for mod_perl handlers) every time a filter is called.

__________________________________________________________________
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