dougm 01/09/28 10:15:08 Modified: lib/Apache compat.pm src/modules/perl mod_perl.c modperl_env.c modperl_env.h t/conf modperl_extra.pl t/response/TestModules cgi.pm Log: setup @ENV{MOD_PERL,GATEWAY_INTERFACE} before any Perl code is run Revision Changes Path 1.14 +0 -3 modperl-2.0/lib/Apache/compat.pm Index: compat.pm =================================================================== RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- compat.pm 2001/09/28 13:51:57 1.13 +++ compat.pm 2001/09/28 17:15:07 1.14 @@ -31,9 +31,6 @@ $INC{'Apache.pm'} = 1; $INC{'Apache/Constants.pm'} = 1; - - $ENV{MOD_PERL} = $mod_perl::VERSION; - $ENV{GATEWAY_INTERFACE} = 'CGI-Perl/1.1'; } package Apache; 1.80 +2 -0 modperl-2.0/src/modules/perl/mod_perl.c Index: mod_perl.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v retrieving revision 1.79 retrieving revision 1.80 diff -u -r1.79 -r1.80 --- mod_perl.c 2001/09/28 15:16:06 1.79 +++ mod_perl.c 2001/09/28 17:15:07 1.80 @@ -35,6 +35,8 @@ dTHX; /* XXX: not too worried since this only happens at startup */ int i; + modperl_env_default_populate(aTHX); + for (i=0; MP_xs_loaders[i]; i++) { char *name = Perl_form(aTHX_ MP_xs_loader_name, MP_xs_loaders[i]); newCONSTSUB(PL_defstash, name, newSViv(1)); 1.10 +26 -8 modperl-2.0/src/modules/perl/modperl_env.c Index: modperl_env.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_env.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- modperl_env.c 2001/09/28 16:39:15 1.9 +++ modperl_env.c 2001/09/28 17:15:08 1.10 @@ -32,16 +32,37 @@ { k, sizeof(k)-1, v, sizeof(v)-1, 0 } static const modperl_env_ent_t modperl_env_const_vars[] = { +#ifdef MP_COMPAT_1X MP_ENV_ENT("GATEWAY_INTERFACE", "CGI-Perl/1.1"), +#endif + MP_ENV_ENT("MOD_PERL", MP_VERSION_STRING), { NULL } }; +void modperl_env_default_populate(pTHX) +{ + HV *hv = ENVHV; + U32 mg_flags; + int i; + + modperl_env_untie(mg_flags); + + for (i = 0; modperl_env_const_vars[i].key; i++) { + const modperl_env_ent_t *ent = &modperl_env_const_vars[i]; + + hv_store(hv, ent->key, ent->klen, + newSVpvn(ent->val, ent->vlen), ent->hash); + } + + modperl_env_tie(mg_flags); +} + void modperl_env_request_populate(pTHX_ request_rec *r) { MP_dRCFG; HV *hv = ENVHV; - int i; U32 mg_flags; + int i; apr_array_header_t *array; apr_table_entry_t *elts; @@ -67,14 +88,11 @@ modperl_env_hv_store(aTHX_ hv, &elts[i]); } - for (i = 0; modperl_env_const_vars[i].key; i++) { - const modperl_env_ent_t *ent = &modperl_env_const_vars[i]; - - hv_store(hv, ent->key, ent->klen, - newSVpvn(ent->val, ent->vlen), ent->hash); - } - modperl_env_tie(mg_flags); + +#ifdef MP_COMPAT_1X + modperl_env_default_populate(aTHX); /* reset GATEWAY_INTERFACE */ +#endif MpReqSETUP_ENV_On(rcfg); } 1.6 +2 -0 modperl-2.0/src/modules/perl/modperl_env.h Index: modperl_env.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_env.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- modperl_env.h 2001/09/28 16:39:15 1.5 +++ modperl_env.h 2001/09/28 17:15:08 1.6 @@ -12,6 +12,8 @@ #define modperl_env_tie(mg_flags) \ SvFLAGS((SV*)ENVHV) |= mg_flags +void modperl_env_default_populate(pTHX); + void modperl_env_request_populate(pTHX_ request_rec *r); void modperl_env_request_tie(pTHX_ request_rec *r); 1.8 +4 -0 modperl-2.0/t/conf/modperl_extra.pl Index: modperl_extra.pl =================================================================== RCS file: /home/cvs/modperl-2.0/t/conf/modperl_extra.pl,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- modperl_extra.pl 2001/05/04 06:31:34 1.7 +++ modperl_extra.pl 2001/09/28 17:15:08 1.8 @@ -13,6 +13,10 @@ use APR::Table (); +unless ($ENV{MOD_PERL}) { + die '$ENV{MOD_PERL} not set!'; +} + my $ap_mods = scalar grep { /^Apache/ } keys %INC; my $apr_mods = scalar grep { /^APR/ } keys %INC; 1.8 +9 -0 modperl-2.0/t/response/TestModules/cgi.pm Index: cgi.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/response/TestModules/cgi.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- cgi.pm 2001/09/27 15:52:09 1.7 +++ cgi.pm 2001/09/28 17:15:08 1.8 @@ -9,6 +9,15 @@ sub handler { my $r = shift; + unless ($ENV{MOD_PERL}) { + die "\$ENV{MOD_PERL} is not set"; + } + + my $gw = $ENV{GATEWAY_INTERFACE} || ''; + unless ($gw eq 'CGI-Perl/1.1') { + die "\$ENV{GATEWAY_INTERFACE} is not properly set ($gw)"; + } + if ($CGI::Q) { die "CGI.pm globals were not reset"; }