diff src/http/modules/perl/ngx_http_perl_module.c @ 320:1e9e2c5e7c14 NGINX_0_5_30

nginx 0.5.30 *) Feature: the $args variable can be set with the "set" directive. *) Feature: the $is_args variable. *) Bugfix: if a client has closed connection to mail proxy then nginx might not close connection to backend. *) Bugfix: now nginx escapes space in $memcached_key variable. *) Bugfix: a segmentation fault might occur in worker process when the HTTPS protocol was used in the "proxy_pass" directive. *) Bugfix: the perl $$ variable value in ngx_http_perl_module was equal to the master process identification number. *) Bugfix: fix building on Solaris/amd64 by Sun Studio 11 and early versions; bug appeared in 0.5.29.
author Igor Sysoev <http://sysoev.ru>
date Mon, 30 Jul 2007 00:00:00 +0400
parents 55328d69b335
children 26ff8d6b618d
line wrap: on
line diff
--- 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_
 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_co
 }
 
 
+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)
 {