comparison src/http/modules/perl/ngx_http_perl_module.c @ 1349:50bdde056629 stable-0.5

r1258, r1259 merge: set worker's perl $$
author Igor Sysoev <igor@sysoev.ru>
date Sun, 29 Jul 2007 17:31:00 +0000
parents aa653367028e
children 6b81bbc36eaf
comparison
equal deleted inserted replaced
1348:fe5c88df87f5 1349:50bdde056629
65 65
66 #if (NGX_HAVE_PERL_MULTIPLICITY) 66 #if (NGX_HAVE_PERL_MULTIPLICITY)
67 static void ngx_http_perl_cleanup_perl(void *data); 67 static void ngx_http_perl_cleanup_perl(void *data);
68 #endif 68 #endif
69 69
70 static ngx_int_t ngx_http_perl_init_worker(ngx_cycle_t *cycle);
70 static void ngx_http_perl_exit(ngx_cycle_t *cycle); 71 static void ngx_http_perl_exit(ngx_cycle_t *cycle);
71 72
72 73
73 static ngx_command_t ngx_http_perl_commands[] = { 74 static ngx_command_t ngx_http_perl_commands[] = {
74 75
124 &ngx_http_perl_module_ctx, /* module context */ 125 &ngx_http_perl_module_ctx, /* module context */
125 ngx_http_perl_commands, /* module directives */ 126 ngx_http_perl_commands, /* module directives */
126 NGX_HTTP_MODULE, /* module type */ 127 NGX_HTTP_MODULE, /* module type */
127 NULL, /* init master */ 128 NULL, /* init master */
128 NULL, /* init module */ 129 NULL, /* init module */
129 NULL, /* init process */ 130 ngx_http_perl_init_worker, /* init process */
130 NULL, /* init thread */ 131 NULL, /* init thread */
131 NULL, /* exit thread */ 132 NULL, /* exit thread */
132 NULL, /* exit process */ 133 NULL, /* exit process */
133 ngx_http_perl_exit, /* exit master */ 134 ngx_http_perl_exit, /* exit master */
134 NGX_MODULE_V1_PADDING 135 NGX_MODULE_V1_PADDING
1002 1003
1003 return NGX_CONF_OK; 1004 return NGX_CONF_OK;
1004 } 1005 }
1005 1006
1006 1007
1008 static ngx_int_t
1009 ngx_http_perl_init_worker(ngx_cycle_t *cycle)
1010 {
1011 ngx_http_perl_main_conf_t *pmcf;
1012
1013 pmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_perl_module);
1014
1015 {
1016
1017 dTHXa(pmcf->perl);
1018 PERL_SET_CONTEXT(pmcf->perl);
1019
1020 /* set worker's $$ */
1021
1022 sv_setiv(GvSV(gv_fetchpv("$", TRUE, SVt_PV)), (I32) ngx_pid);
1023
1024 }
1025
1026 return NGX_OK;
1027 }
1028
1007 static void 1029 static void
1008 ngx_http_perl_exit(ngx_cycle_t *cycle) 1030 ngx_http_perl_exit(ngx_cycle_t *cycle)
1009 { 1031 {
1010 PERL_SYS_TERM(); 1032 PERL_SYS_TERM();
1011 } 1033 }