You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Chris Thorman <ct...@webfeeds.com> on 2000/02/23 00:31:43 UTC
mod_perl bug? PerlPassEnv fails on 2nd exec in pid
Hi,
using apache_1.3.6, mod_perl-1.21
PerlSetEnv VAR val ==> always works; $ENV{VAR} is correctly defined
PerlPassEnv VAR ==> $ENV{VAR} is only defined on 1st exec by pid
There seems to be a bug where environment variables put into the environment using PerlPassEnv appear correctly in a given child process's Embperl environment, but then "disappear" after the first time that a child process has run an Embperl app -- and only the "standard" env variables remain.
Those set with PerlSetEnv are not subject to this problem; they persist throughout all executions of all apps in all pids.
"perldoc mod_perl" seems to imply that variables set via PerlPassEnv and PerlSetEnv should have equivalent lifetimes, so I think I've found a bug here.
I tested this phenomenon three different ways:
1) /perl-status/?env (simplest test)
2) Embperl (1.2.1)
3) Apache::Registry
... and got the same results each time so I conclude the problem must be in mod_perl, not in Embperl or Registry.
For reference, here are the Embperl and Apache::Registry test apps I used:
<HTML>
<BODY>
<PRE>
PID: [+ $$ +]
ENV:
[+ join("\n", map {"$_ => $ENV{$_}"} sort keys %ENV) +]
</PRE>
</BODY>
</HTML>
#!/usr/bin/perl
use strict;
use CGI qw/:standard/;
print header;
print (<< "END_HTML");
<HTML>
<BODY>
<PRE>
PID: $$
ENV:
@{[join ("\n", map {"$_ => $ENV{$_}"} sort keys %ENV)]}
</PRE>
</BODY>
</HTML>
END_HTML
So: is this a bug in PerlPassEnv, or am I missing something obvious?
-c
------------------------------------------------------------------------
870 Market Street #1270 (415) 394-9818
San Francisco, CA 94102 (413) 473-0853 fax
------------------------------------------------------------------------
Re: mod_perl bug? PerlPassEnv fails on 2nd exec in pid
Posted by Doug MacEachern <do...@pobox.com>.
On Tue, 22 Feb 2000, Chris Thorman wrote:
> Hi,
>
> using apache_1.3.6, mod_perl-1.21
>
> PerlSetEnv VAR val ==> always works; $ENV{VAR} is correctly defined
> PerlPassEnv VAR ==> $ENV{VAR} is only defined on 1st exec by pid
>
> There seems to be a bug where environment variables put into the environment using PerlPassEnv appear correctly in a given child process's Embperl environment, but then "disappear" after the first time that a child process has run an Embperl app -- and only the "standard" env variables remain.
>
> Those set with PerlSetEnv are not subject to this problem; they persist throughout all executions of all apps in all pids.
hmm, strange this hasn't come up before, fix below.
--- perl_config.c 1999/12/30 19:16:39 1.82
+++ perl_config.c 2000/03/01 07:20:41
@@ -696,11 +696,9 @@
if(PERL_RUNNING()) {
mp_PassEnv(arg);
}
- else {
- char **entry;
- entry = (char **)push_array(cls->PerlPassEnv);
- *entry = pstrdup(parms->pool, arg);
- }
+
+ *(char **)push_array(cls->PerlPassEnv) = pstrdup(parms->pool, arg);
+