Pratik wrote:
I am having the following apache configuration file.

==============================
% cat ~/lab/mp2/test/httpd.conf
ServerRoot "/home/pvnaik/lab/mp2/test"
Timeout 300
DocumentRoot "/home/pvnaik/lab/mp2/test/webdocs"
ErrorLog logs/error_log
Listen 44951

PerlModule Apache2

<Perl>
;
</Perl>

PerlSetEnv MyVar "Hello"

<Perl>
print "HELLO = ", $ENV{MyVar}, "\n";
</Perl>

==============================

Now, the output is :

==============================
% ~/lab/mymp2/mp2/bin/httpd -X -f ~/lab/mp2/test/httpd.conf
HELLO = HELLO = ==============================


This is happening because, initialization of %ENV will take place when
the first <Perl>..</Perl>. And all the subsequent PerlPassEnv and
PerlSetEnv values will be stored only in scfg->SetEnv table and won't
be copied to %ENV.

This issue was previously discussed at
http://gossamer-threads.com/lists/modperl/dev/7256

The same patch would be something like below now :

==============================
% diff -u modperl_cmd.c~ modperl_cmd.c
--- modperl_cmd.c~ 2004-12-14 03:12:14.000000000 -0800
+++ modperl_cmd.c 2004-12-14 09:35:47.000000000 -0800
@@ -545,6 +545,8 @@
ENTER;SAVETMPS;
save_scalar(gv); /* local $0 */
sv_setpv_mg(GvSV(gv), directive->filename);
+ /* Populate %ENV */
+ modperl_env_configure_server(aTHX_ p, s); eval_pv(arg, FALSE);
FREETMPS;LEAVE;
}
==============================


This patch seems to be working fine for me. But probably, calling
modperl_env_configure_server() for every eval_pv would be a bit
costly.

Another option may be to call modperl_env_hv_store():modperl_env.c
from MP_CMD_SRV_DECLARE2(set_env) and MP_CMD_SRV_DECLARE(pass_env) of
modperl_cmd.c.

Another option is not to use <Perl> sections for anything but Apache config. do you need to have this <Perl> section that you've the problem with during config phase? If not move it into post_config phase and your problem is solved.


Another alternative is to drop:

PerlSetEnv MyVar "Hello"

and instead use:

<Perl>
$ENV{MyVar} = "Hello";
</Perl>

PerlSetEnv was originally designed to make Env setting be visible before the response phase (which is what SetEnv did). So I think you are simply misusing this feature and the doc should just say, that PerlSetEnv takes effect only in post_config phase and drop any semi-complete support in <Perl> sections (i.e. dropping modperl_env_configure_server() completely).

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

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to