perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Blackman <m...@blackmans.org>
Subject Re: reinitializing Perl's notion of $$ in mod_perl
Date Tue, 15 Apr 2008 13:28:18 GMT

On 15 Apr 2008, at 14:15, Perrin Harkins wrote:
> On Tue, Apr 15, 2008 at 9:05 AM, Mark Blackman <mark@blackmans.org>  
> wrote:
>>  My assumption is that perl caches the PID on startup  and
>>  only reinitializes on perl fork(), thus in the embedded case
>>  a fork() outside the perl API doesn't reinitialize $$ at least
>>  for some cases.
>
> It must be a mod_perl 2/apache 2 issue.  I've never seen this happen
> with mp1 or with perl programs that use fork().

well perl fork is clearly an obvious cache invalidation event.

in mod_perl 2.0.3 mod_perl.c, I can see..

static void modperl_hook_child_init(apr_pool_t *p, server_rec *s){
    modperl_perl_init_ids_server(s);

and modperl_perl_init_ids_server() eventually calls

modperl_perl_init_ids() which itself eventually does a

sv_setiv(GvSV(gv_fetchpv("$", TRUE, SVt_PV)), ids->pid);

where ids->pid should contain the result of a recent getpid.

*However* I note that in the main perl code perl.c $$ is set
to be a readonly variable so I suspect, this code *might* need
to to look more like.

if ((tmpgv = gv_fetchpv("$",TRUE, SVt_PV))) {
   SvREADONLY_off(GvSV(tmpgv));
   sv_setiv(GvSV(tmpgv), ids->pid);
   SvREADONLY_on(GvSV(tmpgv));
}

- Mark



>
> - Perrin


Mime
View raw message