aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/perl/ngx_http_perl_module.c
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2016-12-07 19:03:19 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2016-12-07 19:03:19 +0300
commit408e49fed64873aa5b7c3affb2a227e15ccee025 (patch)
tree5b4da70a4153c85a6b9ed4ec01b0f8cc1ae10696 /src/http/modules/perl/ngx_http_perl_module.c
parentfcb2e2864e0c7a245daef1fc11ffedf6598f21df (diff)
downloadnginx-408e49fed64873aa5b7c3affb2a227e15ccee025.tar.gz
nginx-408e49fed64873aa5b7c3affb2a227e15ccee025.zip
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.
Diffstat (limited to 'src/http/modules/perl/ngx_http_perl_module.c')
-rw-r--r--src/http/modules/perl/ngx_http_perl_module.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/http/modules/perl/ngx_http_perl_module.c b/src/http/modules/perl/ngx_http_perl_module.c
index f9a9a84c0..279631974 100644
--- a/src/http/modules/perl/ngx_http_perl_module.c
+++ b/src/http/modules/perl/ngx_http_perl_module.c
@@ -207,6 +207,7 @@ ngx_http_perl_handle_request(ngx_http_request_t *r)
dTHXa(pmcf->perl);
PERL_SET_CONTEXT(pmcf->perl);
+ PERL_SET_INTERP(pmcf->perl);
if (ctx->next == NULL) {
plcf = ngx_http_get_module_loc_conf(r, ngx_http_perl_module);
@@ -322,6 +323,7 @@ ngx_http_perl_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
dTHXa(pmcf->perl);
PERL_SET_CONTEXT(pmcf->perl);
+ PERL_SET_INTERP(pmcf->perl);
rc = ngx_http_perl_call_handler(aTHX_ r, pmcf->nginx, pv->sub, NULL,
&pv->handler, &value);
@@ -387,6 +389,7 @@ ngx_http_perl_ssi(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ssi_ctx,
dTHXa(pmcf->perl);
PERL_SET_CONTEXT(pmcf->perl);
+ PERL_SET_INTERP(pmcf->perl);
#if 0
@@ -568,6 +571,7 @@ ngx_http_perl_create_interpreter(ngx_conf_t *cf,
dTHXa(perl);
PERL_SET_CONTEXT(perl);
+ PERL_SET_INTERP(perl);
perl_construct(perl);
@@ -828,6 +832,7 @@ ngx_http_perl_cleanup_perl(void *data)
PerlInterpreter *perl = data;
PERL_SET_CONTEXT(perl);
+ PERL_SET_INTERP(perl);
(void) perl_destruct(perl);
@@ -936,6 +941,7 @@ ngx_http_perl(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
dTHXa(pmcf->perl);
PERL_SET_CONTEXT(pmcf->perl);
+ PERL_SET_INTERP(pmcf->perl);
ngx_http_perl_eval_anon_sub(aTHX_ &value[1], &plcf->sub);
@@ -1007,6 +1013,7 @@ ngx_http_perl_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
dTHXa(pmcf->perl);
PERL_SET_CONTEXT(pmcf->perl);
+ PERL_SET_INTERP(pmcf->perl);
ngx_http_perl_eval_anon_sub(aTHX_ &value[2], &pv->sub);
@@ -1039,6 +1046,7 @@ ngx_http_perl_init_worker(ngx_cycle_t *cycle)
if (pmcf) {
dTHXa(pmcf->perl);
PERL_SET_CONTEXT(pmcf->perl);
+ PERL_SET_INTERP(pmcf->perl);
/* set worker's $$ */