On Thu, 2004-02-12 at 23:06 +0000, [EMAIL PROTECTED] wrote: > geoff 2004/02/12 15:06:24 > > Modified: . Changes > lib/ModPerl Code.pm > src/modules/perl mod_perl.c modperl_callback.c modperl_env.c > modperl_env.h > t/hooks/TestHooks headerparser.pm > t/modperl cookie.t > t/response/TestDirective env.pm > t/response/TestModperl cookie.pm > xs/Apache/RequestRec Apache__RequestRec.h > Added: t/modperl setupenv.t > t/response/TestModperl setupenv.pm > Log: > standard %ENV population with CGI variables and contents of the > subprocess_env table (such as SetEnv and PassEnv) has been delayed > until the last possible moment before content-generation runs. > PerlSetEnv and PerlPassEnv are each an exception to this and are > placed in both %ENV and the subprocess_env table immediately, > regardless of the current [+-]SetupEnv setting. > > [...]
A few compilation problems were introduced by this one, see below.
> Index: mod_perl.c
> ===================================================================
> RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
> retrieving revision 1.206
> retrieving revision 1.207
> diff -u -r1.206 -r1.207
> --- mod_perl.c 10 Jan 2004 05:01:04 -0000 1.206
> +++ mod_perl.c 12 Feb 2004 23:06:23 -0000 1.207
> @@ -837,11 +837,40 @@
>
> int modperl_response_handler(request_rec *r)
> {
> + MP_dDCFG;
> + apr_status_t retval;
> +
> +#ifdef USE_ITHREADS
> + pTHX;
> + modperl_interp_t *interp;
> +#endif
> +
> if (!strEQ(r->handler, "modperl")) {
> return DECLINED;
> }
>
> - return modperl_response_handler_run(r, TRUE);
> + /* default is -SetupEnv, add if PerlOption +SetupEnv */
> + if (MpDirSETUP_ENV(dcfg)) {
> +#ifdef USE_ITHREADS
> + interp = modperl_interp_select(r, r->connection, r->server);
> + aTHX = interp->perl;
> +#endif
> +
> + modperl_env_request_populate(aTHX_ r);
> + }
> +
> + retval = modperl_response_handler_run(r, TRUE);
> +
> + if (MpDirSETUP_ENV(dcfg)) {
> +#ifdef USE_ITHREADS
> + if (MpInterpPUTBACK(interp)) {
> + /* PerlInterpScope handler */
> + modperl_interp_unselect(interp);
> + }
> +#endif
> + }
> +
> + return retval;
> }
>
> int modperl_response_handler_cgi(request_rec *r)
>
mod_perl.c: In function `modperl_response_handler':
mod_perl.c:845: warning: `interp' might be used uninitialized in this
function
>
> 1.69 +14 -4 modperl-2.0/src/modules/perl/modperl_callback.c
>
> Index: modperl_callback.c
> ===================================================================
> RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_callback.c,v
> retrieving revision 1.68
> retrieving revision 1.69
> diff -u -r1.68 -r1.69
> --- modperl_callback.c 9 Feb 2004 19:32:42 -0000 1.68
> +++ modperl_callback.c 12 Feb 2004 23:06:24 -0000 1.69
> @@ -198,15 +198,25 @@
> modperl_config_req_cleanup_register(r, rcfg);
>
> switch (type) {
> - case MP_HANDLER_TYPE_PER_DIR:
> case MP_HANDLER_TYPE_PER_SRV:
> modperl_handler_make_args(aTHX_ &av_args,
> "Apache::RequestRec", r, NULL);
>
> - /* only happens once per-request */
> - if (MpDirSETUP_ENV(dcfg)) {
> - modperl_env_request_populate(aTHX_ r);
> + /* per-server PerlSetEnv and PerlPassEnv - only once per-request */
> + if (! MpReqPERL_SET_ENV_SRV(rcfg)) {
> + modperl_env_configure_request_srv(aTHX_ r);
> + }
> +
> + break;
> + case MP_HANDLER_TYPE_PER_DIR:
> + modperl_handler_make_args(aTHX_ &av_args,
> + "Apache::RequestRec", r, NULL);
> +
> + /* per-directory PerlSetEnv - only once per-request */
> + if (! MpReqPERL_SET_ENV_DIR(rcfg)) {
> + modperl_env_configure_request_dir(aTHX_ r);
> }
> +
> break;
> case MP_HANDLER_TYPE_PRE_CONNECTION:
> case MP_HANDLER_TYPE_CONNECTION:
modperl_callback.c: In function `modperl_callback_run_handlers':
modperl_callback.c:206: warning: implicit declaration of function
`MpReqPERL_SET_ENV_SRV'
modperl_callback.c:216: warning: implicit declaration of function
`MpReqPERL_SET_ENV_DIR'
>
> 1.30 +98 -16 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.29
> retrieving revision 1.30
> diff -u -r1.29 -r1.30
> --- modperl_env.c 22 Sep 2003 23:29:52 -0000 1.29
> +++ modperl_env.c 12 Feb 2004 23:06:24 -0000 1.30
> @@ -143,10 +143,13 @@
>
> void modperl_env_configure_server(pTHX_ apr_pool_t *p, server_rec *s)
> {
> - /* XXX: propagate scfg->SetEnv to environ */
> MP_dSCFG(s);
> int i = 0;
>
> + /* make per-server PerlSetEnv and PerlPassEnv entries visible
> + * to %ENV at config time
> + */
> +
> for (i=0; MP_env_pass_defaults[i]; i++) {
> const char *key = MP_env_pass_defaults[i];
> char *val;
> @@ -180,18 +183,79 @@
> r->subprocess_env, \
> tab)
>
> -void modperl_env_configure_request(request_rec *r)
> +void modperl_env_configure_request_dir(pTHX_ request_rec *r)
> {
> + MP_dRCFG;
> MP_dDCFG;
> - MP_dSCFG(r->server);
> +
> + /* populate %ENV and r->subprocess_env with per-directory
> + * PerlSetEnv entries.
> + *
> + * note that per-server PerlSetEnv entries, as well as
> + * PerlPassEnv entries (which are only per-server), are added
> + * to %ENV and r->subprocess_env via modperl_env_configure_request_srv
> + */
>
> if (!apr_is_empty_table(dcfg->SetEnv)) {
> - overlay_subprocess_env(r, dcfg->SetEnv);
> + apr_table_t *setenv_copy;
> +
> + /* add per-directory PerlSetEnv entries to %ENV
> + * collisions with per-server PerlSetEnv entries are
> + * resolved via the nature of a Perl hash
> + */
> + MP_TRACE_e(MP_FUNC, "\n\t[%s/0x%lx/%s]"
> + "[EMAIL PROTECTED] dcfg->SetEnv} = values dcfg->SetEnv;",
> + modperl_pid_tid(r->pool), modperl_interp_address(aTHX),
> + modperl_server_desc(r->server, r->pool));
> + modperl_env_table_populate(aTHX_ dcfg->SetEnv);
> +
> + /* make sure the entries are in the subprocess_env table as well.
> + * we need to use apr_table_overlap (not apr_table_overlay) because
> + * r->subprocess_env might have per-server PerlSetEnv entries in it
> + * and using apr_table_overlay would generate duplicate entries.
> + * in order to use apr_table_overlap, though, we need to copy the
> + * the dcfg table so that pool requirements are satisfied */
> +
> + setenv_copy = apr_table_copy(r->pool, dcfg->SetEnv);
> + apr_table_overlap(r->subprocess_env, setenv_copy, APR_OVERLAP_TABLES_SET);
> + }
> +
> + MpReqPERL_SET_ENV_DIR_On(rcfg);
> +}
> +
> +void modperl_env_configure_request_srv(pTHX_ request_rec *r)
> +{
> + MP_dRCFG;
> + MP_dSCFG(r->server);
> +
> + /* populate %ENV and r->subprocess_env with per-server PerlSetEnv
> + * and PerlPassEnv entries.
> + *
> + * although both are setup in %ENV in modperl_request_configure_server
> + * %ENV will be reset via modperl_env_request_unpopulate.
> + */
> +
> + if (!apr_is_empty_table(scfg->SetEnv)) {
> + MP_TRACE_e(MP_FUNC, "\n\t[%s/0x%lx/%s]"
> + "[EMAIL PROTECTED] scfg->SetEnv} = values scfg->SetEnv;",
> + modperl_pid_tid(r->pool), modperl_interp_address(aTHX),
> + modperl_server_desc(r->server, r->pool));
> + modperl_env_table_populate(aTHX_ scfg->SetEnv);
> +
> + overlay_subprocess_env(r, scfg->SetEnv);
> }
>
> if (!apr_is_empty_table(scfg->PassEnv)) {
> + MP_TRACE_e(MP_FUNC, "\n\t[%s/0x%lx/%s]"
> + "[EMAIL PROTECTED] scfg->PassEnv} = values scfg->PassEnv;",
> + modperl_pid_tid(r->pool), modperl_interp_address(aTHX),
> + modperl_server_desc(r->server, r->pool));
> + modperl_env_table_populate(aTHX_ scfg->PassEnv);
> +
> overlay_subprocess_env(r, scfg->PassEnv);
> }
> +
> + MpReqPERL_SET_ENV_SRV_On(rcfg);
> }
>
> void modperl_env_default_populate(pTHX)
> @@ -217,27 +281,45 @@
> void modperl_env_request_populate(pTHX_ request_rec *r)
> {
> MP_dRCFG;
> -
> - if (MpReqSETUP_ENV(rcfg)) {
> - return;
> - }
> -
> - /* XXX: might want to always do this regardless of PerlOptions -SetupEnv */
> - modperl_env_configure_request(r);
> -
> - ap_add_common_vars(r);
> - ap_add_cgi_vars(r);
> +
> + /* this is called under the following conditions
> + * - if PerlOptions +SetupEnv
> + * - if $r->subprocess_env() is called in a void context with no args
> + *
> + * normally, %ENV is only populated once per request (if at all) -
> + * just prior to content generation if +SetupEnv.
> + *
> + * however, in the $r->subprocess_env() case it will be called
> + * more than once - once for each void call, and once again just
> + * prior to content generation. while costly, the multiple
> + * passes are required, otherwise void calls would prohibit later
> + * phases from populating %ENV with new subprocess_env table entries
> + */
>
> MP_TRACE_e(MP_FUNC, "\n\t[%s/0x%lx/%s%s]"
> "[EMAIL PROTECTED] r->subprocess_env} = values r->subprocess_env;",
> modperl_pid_tid(r->pool), modperl_interp_address(aTHX),
> modperl_server_desc(r->server, r->pool), r->uri);
> - modperl_env_table_populate(aTHX_ r->subprocess_env);
> +
> + /* we can eliminate some of the cost by only doing CGI variables once
> + * per-request no matter how many times $r->subprocess_env() is called
> + */
> + if (! MpReqSETUP_ENV(rcfg)) {
> +
> + ap_add_common_vars(r);
> + ap_add_cgi_vars(r);
>
> #ifdef MP_COMPAT_1X
> - modperl_env_default_populate(aTHX); /* reset GATEWAY_INTERFACE */
> + modperl_env_default_populate(aTHX); /* reset GATEWAY_INTERFACE */
> #endif
> + }
> +
> + modperl_env_table_populate(aTHX_ r->subprocess_env);
>
> + /* don't set up CGI variables again this request.
> + * this also triggers modperl_env_request_unpopulate, which
> + * resets %ENV between requests - see modperl_config_request_cleanup
> + */
> MpReqSETUP_ENV_On(rcfg);
> }
>
modperl_env.c: In function `modperl_env_configure_request_dir':
modperl_env.c:223: warning: implicit declaration of function `MpReqPERL_SET_ENV_DIR_On'
modperl_env.c: In function `modperl_env_configure_request_srv':
modperl_env.c:258: warning: implicit declaration of function `MpReqPERL_SET_ENV_SRV_On'
> [...]
signature.asc
Description: This is a digitally signed message part
