perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [mp2 bug] Perl*Env issues
Date Thu, 23 Dec 2004 20:24:05 GMT
Pratik wrote:
>>Very nice work, Pratik. The only problem is that it syncs SetEnv|PassEvn
>><=> %ENV completely twice for each <Perl>..</Perl>, PerlRequire
and
>>PerlModule, which is not very effective. It would be nice to keep track of
>>just what keys have changed.
>>
> 
> 
> I need a little help here. MP2 directly uses Perl API call eval_pv()
> for <Perl>..</Perl>. Similarly, it uses Perl API for PerlRequire and
> PerlModule. How can I get the list of %ENV variables that got changed
> in <Perl>..</Perl>, PerlRequire or PerlModule ?

I'm not sure I understand your question. Do you ask how can you test those 
changes? For example by writing a new <Perl> section where you test that 
some ENV var got set or not (e.g. die if it's not).

>>Regardless, we need to have the tests, since it looks that what you need
>>is the right thing.
>>
>>Of course it'd be nice to have a more efficient solution.
>>
> 
> 
> I tried to populate %ENV on encountering PerlPassEnv & PerlSetEnv, but
> "HV *hv = ENVHV;" statement in the new procedure that I wrote ( and
> called it on PerlPassEnv and PerlSetEnv ) - gave me segmentation
> fault. The procedure was something like below :
> 
> void modperl_env_hv_populate(pTHX_ char *key, char *val)
> {
>     HV *hv = ENVHV;
>     I32 klen = strlen(key);
>     SV **svp = hv_fetch(hv, key, klen, FALSE);
> 
>     if (svp) {
>         sv_setpv(*svp, val);
>     }
>     else {
>         SV *sv = newSVpv(val, 0);
>         hv_store(hv, key, klen, sv, FALSE);
>         modperl_envelem_tie(sv, key, klen);
>         svp = &sv;
>     }
> 
>     SvTAINTED_on(*svp);
> }
> 
> Any idea ?
> 
> If we populate %ENV on occurance of PerlPassEnv and PerlSetEnv, there
> won't be any need modperl_env_sync_tables2env() call and only
> modperl_env_sync_env2tables() will be required at the end of every
> <Perl>..</Perl>, PerlRequire & PerlModule.

where do you call it? Can you post the whole patch so I can try?


-- 
__________________________________________________________________
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


Mime
View raw message