perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe M. Chiasson" <go...@ectoplasm.org>
Subject Re: What is PERL_SET_CONTEXT for?
Date Wed, 26 Sep 2007 22:54:59 GMT


Torsten Foertsch wrote:
> Hi,
> 
> in modperl_callback.c I have found this piece of code:
> 
>     if (r || c) {
>         interp = modperl_interp_select(r, c, s);
>         aTHX = interp->perl;
>     }
>     else {
>         /* Child{Init,Exit}, OpenLogs */
>         aTHX = scfg->mip->parent->perl;
>         PERL_SET_CONTEXT(aTHX);
>     }
> 
> "man perlembed" says:
> 
>        Note the calls to PERL_SET_CONTEXT().  These are necessary to initialā€
>        ize the global state that tracks which interpreter is the "current" one
>        on the particular process or thread that may be running it.  It should
>        always be used if you have more than one interpreter and are making
>        perl API calls on both interpreters in an interleaved fashion.
> 
>        PERL_SET_CONTEXT(interp) should also be called whenever "interp" is
>        used by a thread that did not create it (using either perl_alloc(), or
>        the more esoteric perl_clone()).
> 
> So, is it an error not to call PERL_SET_CONTEXT in the if-branch?

I would say yes, it's a bug.

> Shouldn't PERL_SET_CONTEXT be called every time an interpreter is selected?

Pretty much, yes. I personally think all this SET_CONTEXT stuff belongs
in modperl_interp_* and not sprinkled all over the place.

------------------------------------------------------------------------
Philippe M. Chiasson     GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5
http://gozer.ectoplasm.org/       m/gozer\@(apache|cpan|ectoplasm)\.org/


Mime
View raw message