]> git.kaiwu.me - nginx.git/commit
Perl: added PERL_SET_INTERP().
authorMaxim Dounin <mdounin@mdounin.ru>
Wed, 7 Dec 2016 16:03:19 +0000 (19:03 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Wed, 7 Dec 2016 16:03:19 +0000 (19:03 +0300)
commit408e49fed64873aa5b7c3affb2a227e15ccee025
tree5b4da70a4153c85a6b9ed4ec01b0f8cc1ae10696
parentfcb2e2864e0c7a245daef1fc11ffedf6598f21df
Perl: added PERL_SET_INTERP().

For Perl compiled with threads, without PERL_SET_INTERP() the PL_curinterp
remains set to the first interpreter created (that is, one created at
original start).  As a result after a reload Perl thinks that operations
are done withing a thread, and, most notably, denies to change environment.

For example, the following code properly works on original start,
but fails after a reload:

    perl 'sub {
        my $r = shift;

        $r->send_http_header("text/plain");

        $ENV{TZ} = "UTC";
        $r->print("tz: " . $ENV{TZ} . " (localtime " . (localtime()) . ")\n");
        $ENV{TZ} = "Europe/Moscow";
        $r->print("tz: " . $ENV{TZ} . " (localtime " . (localtime()) . ")\n");

        return OK;
    }';

To fix this, PERL_SET_INTERP() added anywhere where PERL_SET_CONTEXT()
was previously used.

Note that PERL_SET_INTERP() doesn't seem to be documented anywhere.
Yet it is used in some other software, and also seems to be the only
solution possible.
src/http/modules/perl/ngx_http_perl_module.c