perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Blackman <>
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 <>  
> 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){

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))) {
   sv_setiv(GvSV(tmpgv), ids->pid);

- Mark

> - Perrin

View raw message