From c21ad7dae5ef16a3e32a10f989c7c1cfeaebcf7d Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Sun, 29 Jul 2007 17:31:00 +0000 Subject: [PATCH] r1258, r1259 merge: set worker's perl $$ --- src/http/modules/perl/ngx_http_perl_module.c | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/http/modules/perl/ngx_http_perl_module.c b/src/http/modules/perl/ngx_http_perl_module.c index b8352f056..248f57823 100644 --- a/src/http/modules/perl/ngx_http_perl_module.c +++ b/src/http/modules/perl/ngx_http_perl_module.c @@ -67,6 +67,7 @@ static char *ngx_http_perl_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static void ngx_http_perl_cleanup_perl(void *data); #endif +static ngx_int_t ngx_http_perl_init_worker(ngx_cycle_t *cycle); static void ngx_http_perl_exit(ngx_cycle_t *cycle); @@ -126,7 +127,7 @@ ngx_module_t ngx_http_perl_module = { NGX_HTTP_MODULE, /* module type */ NULL, /* init master */ NULL, /* init module */ - NULL, /* init process */ + ngx_http_perl_init_worker, /* init process */ NULL, /* init thread */ NULL, /* exit thread */ NULL, /* exit process */ @@ -1004,6 +1005,27 @@ ngx_http_perl_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } +static ngx_int_t +ngx_http_perl_init_worker(ngx_cycle_t *cycle) +{ + ngx_http_perl_main_conf_t *pmcf; + + pmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_perl_module); + + { + + dTHXa(pmcf->perl); + PERL_SET_CONTEXT(pmcf->perl); + + /* set worker's $$ */ + + sv_setiv(GvSV(gv_fetchpv("$", TRUE, SVt_PV)), (I32) ngx_pid); + + } + + return NGX_OK; +} + static void ngx_http_perl_exit(ngx_cycle_t *cycle) {