Mercurial > hg > nginx-quic
annotate src/http/modules/perl/ngx_http_perl_module.c @ 1284:be2b895d31e0
fix segfault when session was freed twice
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 10 Jul 2007 21:04:37 +0000 |
parents | 5076d97b9cf0 |
children | e958b3cab51a |
rev | line source |
---|---|
599 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 #include <ngx_http.h> | |
10 #include <ngx_http_perl_module.h> | |
11 | |
12 | |
13 typedef struct { | |
14 PerlInterpreter *perl; | |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
15 HV *nginx; |
599 | 16 ngx_str_t modules; |
17 ngx_array_t requires; | |
18 } ngx_http_perl_main_conf_t; | |
19 | |
20 | |
21 typedef struct { | |
22 SV *sub; | |
23 ngx_str_t handler; | |
24 } ngx_http_perl_loc_conf_t; | |
25 | |
26 | |
27 typedef struct { | |
28 SV *sub; | |
29 ngx_str_t handler; | |
30 } ngx_http_perl_variable_t; | |
31 | |
32 | |
653 | 33 typedef struct { |
34 SV *sv; | |
35 PerlInterpreter *perl; | |
36 } ngx_http_perl_cleanup_t; | |
37 | |
38 | |
617 | 39 #if (NGX_HTTP_SSI) |
599 | 40 static ngx_int_t ngx_http_perl_ssi(ngx_http_request_t *r, |
41 ngx_http_ssi_ctx_t *ssi_ctx, ngx_str_t **params); | |
617 | 42 #endif |
43 | |
911 | 44 static void ngx_http_perl_sleep_handler(ngx_http_request_t *r); |
599 | 45 static char *ngx_http_perl_init_interpreter(ngx_conf_t *cf, |
46 ngx_http_perl_main_conf_t *pmcf); | |
1069 | 47 static PerlInterpreter *ngx_http_perl_create_interpreter(ngx_conf_t *cf, |
48 ngx_http_perl_main_conf_t *pmcf); | |
653 | 49 static ngx_int_t ngx_http_perl_run_requires(pTHX_ ngx_array_t *requires, |
649 | 50 ngx_log_t *log); |
599 | 51 static ngx_int_t ngx_http_perl_call_handler(pTHX_ ngx_http_request_t *r, |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
52 HV *nginx, SV *sub, ngx_str_t **args, ngx_str_t *handler, ngx_str_t *rv); |
599 | 53 static void ngx_http_perl_eval_anon_sub(pTHX_ ngx_str_t *handler, SV **sv); |
54 | |
55 static ngx_int_t ngx_http_perl_preconfiguration(ngx_conf_t *cf); | |
56 static void *ngx_http_perl_create_main_conf(ngx_conf_t *cf); | |
57 static char *ngx_http_perl_init_main_conf(ngx_conf_t *cf, void *conf); | |
58 static void *ngx_http_perl_create_loc_conf(ngx_conf_t *cf); | |
59 static char *ngx_http_perl_merge_loc_conf(ngx_conf_t *cf, void *parent, | |
60 void *child); | |
61 static char *ngx_http_perl_require(ngx_conf_t *cf, ngx_command_t *cmd, | |
62 void *conf); | |
63 static char *ngx_http_perl(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
64 static char *ngx_http_perl_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | |
872
1c4a5b3f9110
Axe several perl interpreter instances: they may be useful in currently
Igor Sysoev <igor@sysoev.ru>
parents:
871
diff
changeset
|
65 |
1c4a5b3f9110
Axe several perl interpreter instances: they may be useful in currently
Igor Sysoev <igor@sysoev.ru>
parents:
871
diff
changeset
|
66 #if (NGX_HAVE_PERL_MULTIPLICITY) |
599 | 67 static void ngx_http_perl_cleanup_perl(void *data); |
649 | 68 #endif |
599 | 69 |
1257 | 70 static ngx_int_t ngx_http_perl_init_worker(ngx_cycle_t *cycle); |
1221
aa653367028e
PERL_SYS_TERM() should be called once on exit only, this fixes the message
Igor Sysoev <igor@sysoev.ru>
parents:
1165
diff
changeset
|
71 static void ngx_http_perl_exit(ngx_cycle_t *cycle); |
aa653367028e
PERL_SYS_TERM() should be called once on exit only, this fixes the message
Igor Sysoev <igor@sysoev.ru>
parents:
1165
diff
changeset
|
72 |
599 | 73 |
74 static ngx_command_t ngx_http_perl_commands[] = { | |
75 | |
76 { ngx_string("perl_modules"), | |
77 NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, | |
78 ngx_conf_set_str_slot, | |
79 NGX_HTTP_MAIN_CONF_OFFSET, | |
80 offsetof(ngx_http_perl_main_conf_t, modules), | |
81 NULL }, | |
82 | |
83 { ngx_string("perl_require"), | |
84 NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, | |
85 ngx_http_perl_require, | |
86 NGX_HTTP_MAIN_CONF_OFFSET, | |
87 0, | |
88 NULL }, | |
89 | |
90 { ngx_string("perl"), | |
922
a5b9cdfe3e19
allow "perl" inside "limit_except"
Igor Sysoev <igor@sysoev.ru>
parents:
913
diff
changeset
|
91 NGX_HTTP_LOC_CONF|NGX_HTTP_LMT_CONF|NGX_CONF_TAKE1, |
599 | 92 ngx_http_perl, |
93 NGX_HTTP_LOC_CONF_OFFSET, | |
94 0, | |
95 NULL }, | |
96 | |
97 { ngx_string("perl_set"), | |
98 NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE2, | |
99 ngx_http_perl_set, | |
100 NGX_HTTP_LOC_CONF_OFFSET, | |
101 0, | |
102 NULL }, | |
103 | |
104 ngx_null_command | |
105 }; | |
106 | |
107 | |
108 static ngx_http_module_t ngx_http_perl_module_ctx = { | |
109 ngx_http_perl_preconfiguration, /* preconfiguration */ | |
110 NULL, /* postconfiguration */ | |
111 | |
112 ngx_http_perl_create_main_conf, /* create main configuration */ | |
113 ngx_http_perl_init_main_conf, /* init main configuration */ | |
114 | |
115 NULL, /* create server configuration */ | |
116 NULL, /* merge server configuration */ | |
117 | |
118 ngx_http_perl_create_loc_conf, /* create location configuration */ | |
119 ngx_http_perl_merge_loc_conf /* merge location configuration */ | |
120 }; | |
121 | |
122 | |
123 ngx_module_t ngx_http_perl_module = { | |
124 NGX_MODULE_V1, | |
125 &ngx_http_perl_module_ctx, /* module context */ | |
126 ngx_http_perl_commands, /* module directives */ | |
127 NGX_HTTP_MODULE, /* module type */ | |
128 NULL, /* init master */ | |
129 NULL, /* init module */ | |
1257 | 130 ngx_http_perl_init_worker, /* init process */ |
599 | 131 NULL, /* init thread */ |
132 NULL, /* exit thread */ | |
133 NULL, /* exit process */ | |
1221
aa653367028e
PERL_SYS_TERM() should be called once on exit only, this fixes the message
Igor Sysoev <igor@sysoev.ru>
parents:
1165
diff
changeset
|
134 ngx_http_perl_exit, /* exit master */ |
599 | 135 NGX_MODULE_V1_PADDING |
136 }; | |
137 | |
138 | |
617 | 139 #if (NGX_HTTP_SSI) |
140 | |
599 | 141 #define NGX_HTTP_PERL_SSI_SUB 0 |
142 #define NGX_HTTP_PERL_SSI_ARG 1 | |
143 | |
144 | |
145 static ngx_http_ssi_param_t ngx_http_perl_ssi_params[] = { | |
146 { ngx_string("sub"), NGX_HTTP_PERL_SSI_SUB, 1, 0 }, | |
147 { ngx_string("arg"), NGX_HTTP_PERL_SSI_ARG, 0, 1 }, | |
148 { ngx_null_string, 0, 0, 0 } | |
149 }; | |
150 | |
151 static ngx_http_ssi_command_t ngx_http_perl_ssi_command = { | |
667 | 152 ngx_string("perl"), ngx_http_perl_ssi, ngx_http_perl_ssi_params, 0, 0, 1 |
599 | 153 }; |
154 | |
617 | 155 #endif |
156 | |
599 | 157 |
681 | 158 static ngx_str_t ngx_null_name = ngx_null_string; |
159 | |
160 | |
633 | 161 static HV *nginx_stash; |
162 | |
599 | 163 static void |
164 ngx_http_perl_xs_init(pTHX) | |
165 { | |
166 newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, __FILE__); | |
633 | 167 |
168 nginx_stash = gv_stashpv("nginx", TRUE); | |
599 | 169 } |
170 | |
171 | |
172 static ngx_int_t | |
173 ngx_http_perl_handler(ngx_http_request_t *r) | |
174 { | |
629 | 175 /* TODO: Win32 */ |
176 if (r->zero_in_uri) { | |
177 return NGX_HTTP_NOT_FOUND; | |
178 } | |
179 | |
681 | 180 ngx_http_perl_handle_request(r); |
181 | |
182 return NGX_DONE; | |
629 | 183 } |
184 | |
185 | |
681 | 186 void |
629 | 187 ngx_http_perl_handle_request(ngx_http_request_t *r) |
188 { | |
681 | 189 SV *sub; |
599 | 190 ngx_int_t rc; |
681 | 191 ngx_str_t uri, args, *handler; |
599 | 192 ngx_http_perl_ctx_t *ctx; |
193 ngx_http_perl_loc_conf_t *plcf; | |
194 ngx_http_perl_main_conf_t *pmcf; | |
195 | |
196 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "perl handler"); | |
197 | |
198 ctx = ngx_http_get_module_ctx(r, ngx_http_perl_module); | |
199 | |
200 if (ctx == NULL) { | |
201 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_perl_ctx_t)); | |
202 if (ctx == NULL) { | |
681 | 203 ngx_http_finalize_request(r, NGX_ERROR); |
1025 | 204 return; |
599 | 205 } |
206 | |
207 ngx_http_set_ctx(r, ctx, ngx_http_perl_module); | |
208 } | |
209 | |
210 pmcf = ngx_http_get_module_main_conf(r, ngx_http_perl_module); | |
211 | |
212 { | |
213 | |
872
1c4a5b3f9110
Axe several perl interpreter instances: they may be useful in currently
Igor Sysoev <igor@sysoev.ru>
parents:
871
diff
changeset
|
214 dTHXa(pmcf->perl); |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
215 PERL_SET_CONTEXT(pmcf->perl); |
599 | 216 |
681 | 217 if (ctx->next == NULL) { |
218 plcf = ngx_http_get_module_loc_conf(r, ngx_http_perl_module); | |
219 sub = plcf->sub; | |
220 handler = &plcf->handler; | |
599 | 221 |
681 | 222 } else { |
223 sub = ctx->next; | |
224 handler = &ngx_null_name; | |
225 ctx->next = NULL; | |
226 } | |
227 | |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
228 rc = ngx_http_perl_call_handler(aTHX_ r, pmcf->nginx, sub, NULL, handler, |
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
229 NULL); |
599 | 230 |
231 } | |
232 | |
233 if (rc > 600) { | |
234 rc = NGX_OK; | |
235 } | |
236 | |
237 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
238 "perl handler done: %i", rc); | |
239 | |
240 if (ctx->redirect_uri.len) { | |
241 uri = ctx->redirect_uri; | |
242 args = ctx->redirect_args; | |
629 | 243 |
244 } else { | |
245 uri.len = 0; | |
599 | 246 } |
247 | |
633 | 248 ctx->filename.data = NULL; |
599 | 249 ctx->redirect_uri.len = 0; |
250 | |
911 | 251 if (ctx->sleep) { |
252 ngx_add_timer(r->connection->write, (ngx_msec_t) ctx->sleep); | |
253 r->write_event_handler = ngx_http_perl_sleep_handler; | |
254 ctx->sleep = 0; | |
255 } | |
256 | |
681 | 257 if (ctx->done || ctx->next) { |
258 return; | |
259 } | |
260 | |
599 | 261 if (uri.len) { |
629 | 262 ngx_http_internal_redirect(r, &uri, &args); |
263 return; | |
599 | 264 } |
265 | |
266 if (rc == NGX_OK || rc == NGX_HTTP_OK) { | |
629 | 267 ngx_http_send_special(r, NGX_HTTP_LAST); |
681 | 268 ctx->done = 1; |
599 | 269 } |
270 | |
629 | 271 ngx_http_finalize_request(r, rc); |
599 | 272 } |
273 | |
274 | |
911 | 275 static void |
276 ngx_http_perl_sleep_handler(ngx_http_request_t *r) | |
277 { | |
913
90ce4d0e3241
fix ngx_http_perl_sleep_handler()
Igor Sysoev <igor@sysoev.ru>
parents:
911
diff
changeset
|
278 ngx_event_t *wev; |
90ce4d0e3241
fix ngx_http_perl_sleep_handler()
Igor Sysoev <igor@sysoev.ru>
parents:
911
diff
changeset
|
279 |
911 | 280 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
281 "perl sleep handler"); | |
282 | |
913
90ce4d0e3241
fix ngx_http_perl_sleep_handler()
Igor Sysoev <igor@sysoev.ru>
parents:
911
diff
changeset
|
283 wev = r->connection->write; |
90ce4d0e3241
fix ngx_http_perl_sleep_handler()
Igor Sysoev <igor@sysoev.ru>
parents:
911
diff
changeset
|
284 |
90ce4d0e3241
fix ngx_http_perl_sleep_handler()
Igor Sysoev <igor@sysoev.ru>
parents:
911
diff
changeset
|
285 if (wev->timedout) { |
90ce4d0e3241
fix ngx_http_perl_sleep_handler()
Igor Sysoev <igor@sysoev.ru>
parents:
911
diff
changeset
|
286 wev->timedout = 0; |
90ce4d0e3241
fix ngx_http_perl_sleep_handler()
Igor Sysoev <igor@sysoev.ru>
parents:
911
diff
changeset
|
287 ngx_http_perl_handle_request(r); |
90ce4d0e3241
fix ngx_http_perl_sleep_handler()
Igor Sysoev <igor@sysoev.ru>
parents:
911
diff
changeset
|
288 return; |
90ce4d0e3241
fix ngx_http_perl_sleep_handler()
Igor Sysoev <igor@sysoev.ru>
parents:
911
diff
changeset
|
289 } |
90ce4d0e3241
fix ngx_http_perl_sleep_handler()
Igor Sysoev <igor@sysoev.ru>
parents:
911
diff
changeset
|
290 |
90ce4d0e3241
fix ngx_http_perl_sleep_handler()
Igor Sysoev <igor@sysoev.ru>
parents:
911
diff
changeset
|
291 if (ngx_handle_write_event(wev, 0) == NGX_ERROR) { |
90ce4d0e3241
fix ngx_http_perl_sleep_handler()
Igor Sysoev <igor@sysoev.ru>
parents:
911
diff
changeset
|
292 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
90ce4d0e3241
fix ngx_http_perl_sleep_handler()
Igor Sysoev <igor@sysoev.ru>
parents:
911
diff
changeset
|
293 } |
911 | 294 } |
295 | |
296 | |
599 | 297 static ngx_int_t |
298 ngx_http_perl_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, | |
299 uintptr_t data) | |
300 { | |
301 ngx_http_perl_variable_t *pv = (ngx_http_perl_variable_t *) data; | |
302 | |
303 ngx_int_t rc; | |
304 ngx_str_t value; | |
305 ngx_http_perl_ctx_t *ctx; | |
306 ngx_http_perl_main_conf_t *pmcf; | |
307 | |
308 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
309 "perl variable handler"); | |
310 | |
311 ctx = ngx_http_get_module_ctx(r, ngx_http_perl_module); | |
312 | |
313 if (ctx == NULL) { | |
314 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_perl_ctx_t)); | |
315 if (ctx == NULL) { | |
316 return NGX_ERROR; | |
317 } | |
318 | |
319 ngx_http_set_ctx(r, ctx, ngx_http_perl_module); | |
872
1c4a5b3f9110
Axe several perl interpreter instances: they may be useful in currently
Igor Sysoev <igor@sysoev.ru>
parents:
871
diff
changeset
|
320 } |
599 | 321 |
872
1c4a5b3f9110
Axe several perl interpreter instances: they may be useful in currently
Igor Sysoev <igor@sysoev.ru>
parents:
871
diff
changeset
|
322 pmcf = ngx_http_get_module_main_conf(r, ngx_http_perl_module); |
599 | 323 |
324 value.data = NULL; | |
325 | |
326 { | |
327 | |
872
1c4a5b3f9110
Axe several perl interpreter instances: they may be useful in currently
Igor Sysoev <igor@sysoev.ru>
parents:
871
diff
changeset
|
328 dTHXa(pmcf->perl); |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
329 PERL_SET_CONTEXT(pmcf->perl); |
599 | 330 |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
331 rc = ngx_http_perl_call_handler(aTHX_ r, pmcf->nginx, pv->sub, NULL, |
599 | 332 &pv->handler, &value); |
333 | |
334 } | |
335 | |
336 if (value.data) { | |
337 v->len = value.len; | |
338 v->valid = 1; | |
339 v->no_cachable = 0; | |
340 v->not_found = 0; | |
341 v->data = value.data; | |
342 | |
343 } else { | |
344 v->not_found = 1; | |
345 } | |
346 | |
633 | 347 ctx->filename.data = NULL; |
599 | 348 ctx->redirect_uri.len = 0; |
349 | |
871 | 350 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
351 "perl variable done"); | |
352 | |
599 | 353 return rc; |
354 } | |
355 | |
356 | |
617 | 357 #if (NGX_HTTP_SSI) |
358 | |
599 | 359 static ngx_int_t |
360 ngx_http_perl_ssi(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ssi_ctx, | |
361 ngx_str_t **params) | |
362 { | |
363 SV *sv; | |
364 ngx_int_t rc; | |
365 ngx_str_t *handler; | |
366 ngx_http_perl_ctx_t *ctx; | |
367 ngx_http_perl_main_conf_t *pmcf; | |
368 | |
369 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
370 "perl ssi handler"); | |
371 | |
372 ctx = ngx_http_get_module_ctx(r, ngx_http_perl_module); | |
373 | |
374 if (ctx == NULL) { | |
375 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_perl_ctx_t)); | |
376 if (ctx == NULL) { | |
377 return NGX_ERROR; | |
378 } | |
379 | |
380 ngx_http_set_ctx(r, ctx, ngx_http_perl_module); | |
381 } | |
382 | |
872
1c4a5b3f9110
Axe several perl interpreter instances: they may be useful in currently
Igor Sysoev <igor@sysoev.ru>
parents:
871
diff
changeset
|
383 pmcf = ngx_http_get_module_main_conf(r, ngx_http_perl_module); |
599 | 384 |
385 ctx->ssi = ssi_ctx; | |
386 | |
387 handler = params[NGX_HTTP_PERL_SSI_SUB]; | |
388 handler->data[handler->len] = '\0'; | |
389 | |
390 { | |
391 | |
872
1c4a5b3f9110
Axe several perl interpreter instances: they may be useful in currently
Igor Sysoev <igor@sysoev.ru>
parents:
871
diff
changeset
|
392 dTHXa(pmcf->perl); |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
393 PERL_SET_CONTEXT(pmcf->perl); |
599 | 394 |
651 | 395 #if 0 |
396 | |
397 /* the code is disabled to force the precompiled perl code using only */ | |
398 | |
399 ngx_http_perl_eval_anon_sub(aTHX_ handler, &sv); | |
400 | |
401 if (sv == &PL_sv_undef) { | |
402 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
403 "eval_pv(\"%V\") failed", handler); | |
404 return NGX_ERROR; | |
405 } | |
406 | |
407 if (sv == NULL) { | |
408 sv = newSVpvn((char *) handler->data, handler->len); | |
409 } | |
410 | |
411 #endif | |
412 | |
599 | 413 sv = newSVpvn((char *) handler->data, handler->len); |
414 | |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
415 rc = ngx_http_perl_call_handler(aTHX_ r, pmcf->nginx, sv, |
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
416 ¶ms[NGX_HTTP_PERL_SSI_ARG], |
599 | 417 handler, NULL); |
418 | |
419 SvREFCNT_dec(sv); | |
420 | |
421 } | |
422 | |
633 | 423 ctx->filename.data = NULL; |
599 | 424 ctx->redirect_uri.len = 0; |
425 ctx->ssi = NULL; | |
426 | |
871 | 427 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "perl ssi done"); |
428 | |
599 | 429 return rc; |
430 } | |
431 | |
617 | 432 #endif |
433 | |
599 | 434 |
435 static char * | |
436 ngx_http_perl_init_interpreter(ngx_conf_t *cf, ngx_http_perl_main_conf_t *pmcf) | |
437 { | |
872
1c4a5b3f9110
Axe several perl interpreter instances: they may be useful in currently
Igor Sysoev <igor@sysoev.ru>
parents:
871
diff
changeset
|
438 #if (NGX_HAVE_PERL_MULTIPLICITY) |
653 | 439 ngx_pool_cleanup_t *cln; |
599 | 440 |
441 cln = ngx_pool_cleanup_add(cf->pool, 0); | |
442 if (cln == NULL) { | |
443 return NGX_CONF_ERROR; | |
444 } | |
445 | |
649 | 446 #else |
447 static PerlInterpreter *perl; | |
448 #endif | |
449 | |
599 | 450 #ifdef NGX_PERL_MODULES |
451 if (pmcf->modules.data == NULL) { | |
452 pmcf->modules.data = NGX_PERL_MODULES; | |
453 } | |
454 #endif | |
455 | |
639 | 456 if (pmcf->modules.data) { |
457 if (ngx_conf_full_name(cf->cycle, &pmcf->modules) != NGX_OK) { | |
458 return NGX_CONF_ERROR; | |
459 } | |
629 | 460 } |
461 | |
872
1c4a5b3f9110
Axe several perl interpreter instances: they may be useful in currently
Igor Sysoev <igor@sysoev.ru>
parents:
871
diff
changeset
|
462 #if !(NGX_HAVE_PERL_MULTIPLICITY) |
649 | 463 |
464 if (perl) { | |
1165 | 465 |
466 if (ngx_set_environment(cf->cycle, NULL) == NULL) { | |
467 return NGX_CONF_ERROR; | |
468 } | |
469 | |
653 | 470 if (ngx_http_perl_run_requires(aTHX_ &pmcf->requires, cf->log) |
471 != NGX_OK) | |
472 { | |
649 | 473 return NGX_CONF_ERROR; |
474 } | |
475 | |
476 pmcf->perl = perl; | |
1163
8288459f15c9
set nginx_stash after reconfiguration in single interpreter perl
Igor Sysoev <igor@sysoev.ru>
parents:
1069
diff
changeset
|
477 pmcf->nginx = nginx_stash; |
649 | 478 |
479 return NGX_CONF_OK; | |
480 } | |
481 | |
482 #endif | |
483 | |
1221
aa653367028e
PERL_SYS_TERM() should be called once on exit only, this fixes the message
Igor Sysoev <igor@sysoev.ru>
parents:
1165
diff
changeset
|
484 if (nginx_stash == NULL) { |
aa653367028e
PERL_SYS_TERM() should be called once on exit only, this fixes the message
Igor Sysoev <igor@sysoev.ru>
parents:
1165
diff
changeset
|
485 PERL_SYS_INIT(&ngx_argc, &ngx_argv); |
aa653367028e
PERL_SYS_TERM() should be called once on exit only, this fixes the message
Igor Sysoev <igor@sysoev.ru>
parents:
1165
diff
changeset
|
486 } |
599 | 487 |
1069 | 488 pmcf->perl = ngx_http_perl_create_interpreter(cf, pmcf); |
599 | 489 |
490 if (pmcf->perl == NULL) { | |
491 return NGX_CONF_ERROR; | |
492 } | |
493 | |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
494 pmcf->nginx = nginx_stash; |
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
495 |
872
1c4a5b3f9110
Axe several perl interpreter instances: they may be useful in currently
Igor Sysoev <igor@sysoev.ru>
parents:
871
diff
changeset
|
496 #if (NGX_HAVE_PERL_MULTIPLICITY) |
649 | 497 |
599 | 498 cln->handler = ngx_http_perl_cleanup_perl; |
499 cln->data = pmcf->perl; | |
500 | |
649 | 501 #else |
502 | |
503 perl = pmcf->perl; | |
504 | |
505 #endif | |
506 | |
599 | 507 return NGX_CONF_OK; |
508 } | |
509 | |
510 | |
511 static PerlInterpreter * | |
1069 | 512 ngx_http_perl_create_interpreter(ngx_conf_t *cf, |
513 ngx_http_perl_main_conf_t *pmcf) | |
599 | 514 { |
515 int n; | |
775 | 516 STRLEN len; |
517 SV *sv; | |
518 char *ver, *embedding[6]; | |
599 | 519 PerlInterpreter *perl; |
520 | |
1069 | 521 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, cf->log, 0, "create perl interpreter"); |
522 | |
523 if (ngx_set_environment(cf->cycle, NULL) == NULL) { | |
524 return NULL; | |
525 } | |
599 | 526 |
527 perl = perl_alloc(); | |
528 if (perl == NULL) { | |
1069 | 529 ngx_log_error(NGX_LOG_ALERT, cf->log, 0, "perl_alloc() failed"); |
599 | 530 return NULL; |
531 } | |
532 | |
533 { | |
534 | |
535 dTHXa(perl); | |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
536 PERL_SET_CONTEXT(perl); |
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
537 |
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
538 perl_construct(perl); |
599 | 539 |
540 #ifdef PERL_EXIT_DESTRUCT_END | |
541 PL_exit_flags |= PERL_EXIT_DESTRUCT_END; | |
542 #endif | |
543 | |
544 embedding[0] = ""; | |
545 | |
546 if (pmcf->modules.data) { | |
547 embedding[1] = "-I"; | |
548 embedding[2] = (char *) pmcf->modules.data; | |
549 n = 3; | |
550 | |
551 } else { | |
552 n = 1; | |
553 } | |
554 | |
555 embedding[n++] = "-Mnginx"; | |
556 embedding[n++] = "-e"; | |
557 embedding[n++] = "0"; | |
558 | |
559 n = perl_parse(perl, ngx_http_perl_xs_init, n, embedding, NULL); | |
560 | |
561 if (n != 0) { | |
1069 | 562 ngx_log_error(NGX_LOG_ALERT, cf->log, 0, "perl_parse() failed: %d", n); |
599 | 563 goto fail; |
564 } | |
565 | |
775 | 566 sv = get_sv("nginx::VERSION", FALSE); |
567 ver = SvPV(sv, len); | |
568 | |
569 if (ngx_strcmp(ver, NGINX_VERSION) != 0) { | |
1069 | 570 ngx_log_error(NGX_LOG_ALERT, cf->log, 0, |
775 | 571 "version " NGINX_VERSION " of nginx.pm is required, " |
572 "but %s was found", ver); | |
573 goto fail; | |
574 } | |
575 | |
1069 | 576 if (ngx_http_perl_run_requires(aTHX_ &pmcf->requires, cf->log) != NGX_OK) { |
649 | 577 goto fail; |
599 | 578 } |
579 | |
580 } | |
581 | |
582 return perl; | |
583 | |
584 fail: | |
585 | |
586 (void) perl_destruct(perl); | |
587 | |
588 perl_free(perl); | |
589 | |
590 return NULL; | |
591 } | |
592 | |
593 | |
649 | 594 static ngx_int_t |
653 | 595 ngx_http_perl_run_requires(pTHX_ ngx_array_t *requires, ngx_log_t *log) |
649 | 596 { |
597 char **script; | |
598 STRLEN len; | |
599 ngx_str_t err; | |
600 ngx_uint_t i; | |
601 | |
602 script = requires->elts; | |
603 for (i = 0; i < requires->nelts; i++) { | |
604 | |
605 require_pv(script[i]); | |
606 | |
607 if (SvTRUE(ERRSV)) { | |
608 | |
609 err.data = (u_char *) SvPV(ERRSV, len); | |
610 for (len--; err.data[len] == LF || err.data[len] == CR; len--) { | |
611 /* void */ | |
612 } | |
613 err.len = len + 1; | |
614 | |
615 ngx_log_error(NGX_LOG_EMERG, log, 0, | |
616 "require_pv(\"%s\") failed: \"%V\"", script[i], &err); | |
617 | |
618 return NGX_ERROR; | |
619 } | |
620 } | |
621 | |
622 return NGX_OK; | |
623 } | |
624 | |
625 | |
599 | 626 static ngx_int_t |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
627 ngx_http_perl_call_handler(pTHX_ ngx_http_request_t *r, HV *nginx, SV *sub, |
599 | 628 ngx_str_t **args, ngx_str_t *handler, ngx_str_t *rv) |
629 { | |
630 SV *sv; | |
631 int n, status; | |
632 char *line; | |
633 STRLEN len, n_a; | |
634 ngx_str_t err; | |
635 ngx_uint_t i; | |
636 | |
637 dSP; | |
638 | |
639 status = 0; | |
640 | |
641 ENTER; | |
642 SAVETMPS; | |
643 | |
644 PUSHMARK(sp); | |
645 | |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
646 sv = sv_2mortal(sv_bless(newRV_noinc(newSViv(PTR2IV(r))), nginx)); |
599 | 647 XPUSHs(sv); |
648 | |
649 if (args) { | |
650 for (i = 0; args[i]; i++) { /* void */ } | |
651 | |
652 EXTEND(sp, (int) i); | |
653 | |
654 for (i = 0; args[i]; i++) { | |
655 PUSHs(sv_2mortal(newSVpvn((char *) args[i]->data, args[i]->len))); | |
656 } | |
657 } | |
658 | |
659 PUTBACK; | |
660 | |
661 n = call_sv(sub, G_EVAL); | |
662 | |
663 SPAGAIN; | |
664 | |
665 if (n) { | |
666 if (rv == NULL) { | |
667 status = POPi; | |
668 | |
669 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
670 "call_sv: %d", status); | |
671 | |
672 } else { | |
619 | 673 line = SvPVx(POPs, n_a); |
599 | 674 rv->len = n_a; |
675 | |
676 rv->data = ngx_palloc(r->pool, n_a); | |
677 if (rv->data == NULL) { | |
678 return NGX_ERROR; | |
679 } | |
680 | |
681 ngx_memcpy(rv->data, line, n_a); | |
682 } | |
683 } | |
684 | |
685 PUTBACK; | |
686 | |
687 FREETMPS; | |
688 LEAVE; | |
689 | |
690 /* check $@ */ | |
691 | |
692 if (SvTRUE(ERRSV)) { | |
693 | |
694 err.data = (u_char *) SvPV(ERRSV, len); | |
695 for (len--; err.data[len] == LF || err.data[len] == CR; len--) { | |
696 /* void */ | |
697 } | |
698 err.len = len + 1; | |
699 | |
700 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
701 "call_sv(\"%V\") failed: \"%V\"", | |
702 handler, &err); | |
703 | |
704 if (rv) { | |
705 return NGX_ERROR; | |
706 } | |
707 | |
708 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
709 } | |
710 | |
711 if (n != 1) { | |
712 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
713 "call_sv(\"%V\") returned %d results", handler, n); | |
714 status = NGX_OK; | |
715 } | |
716 | |
717 if (rv) { | |
718 return NGX_OK; | |
719 } | |
720 | |
721 return (ngx_int_t) status; | |
722 } | |
723 | |
724 | |
725 static void | |
726 ngx_http_perl_eval_anon_sub(pTHX_ ngx_str_t *handler, SV **sv) | |
727 { | |
623 | 728 u_char *p; |
729 | |
730 for (p = handler->data; *p; p++) { | |
731 if (*p != ' ' && *p != '\t' && *p != CR && *p != LF) { | |
732 break; | |
733 } | |
734 } | |
735 | |
649 | 736 if (ngx_strncmp(p, "sub ", 4) == 0 || ngx_strncmp(p, "use ", 4) == 0) { |
623 | 737 *sv = eval_pv((char *) p, FALSE); |
874 | 738 |
739 /* eval_pv() does not set ERRSV on failure */ | |
740 | |
599 | 741 return; |
742 } | |
743 | |
744 *sv = NULL; | |
745 } | |
746 | |
747 | |
748 static void * | |
749 ngx_http_perl_create_main_conf(ngx_conf_t *cf) | |
750 { | |
751 ngx_http_perl_main_conf_t *pmcf; | |
752 | |
753 pmcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_perl_main_conf_t)); | |
754 if (pmcf == NULL) { | |
755 return NGX_CONF_ERROR; | |
756 } | |
757 | |
758 if (ngx_array_init(&pmcf->requires, cf->pool, 1, sizeof(u_char *)) | |
759 != NGX_OK) | |
760 { | |
761 return NULL; | |
762 } | |
763 | |
764 return pmcf; | |
765 } | |
766 | |
767 | |
768 static char * | |
769 ngx_http_perl_init_main_conf(ngx_conf_t *cf, void *conf) | |
770 { | |
771 ngx_http_perl_main_conf_t *pmcf = conf; | |
772 | |
773 if (pmcf->perl == NULL) { | |
774 if (ngx_http_perl_init_interpreter(cf, pmcf) != NGX_CONF_OK) { | |
775 return NGX_CONF_ERROR; | |
776 } | |
777 } | |
778 | |
779 return NGX_CONF_OK; | |
780 } | |
781 | |
782 | |
872
1c4a5b3f9110
Axe several perl interpreter instances: they may be useful in currently
Igor Sysoev <igor@sysoev.ru>
parents:
871
diff
changeset
|
783 #if (NGX_HAVE_PERL_MULTIPLICITY) |
649 | 784 |
599 | 785 static void |
786 ngx_http_perl_cleanup_perl(void *data) | |
787 { | |
649 | 788 PerlInterpreter *perl = data; |
599 | 789 |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
790 PERL_SET_CONTEXT(perl); |
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
791 |
599 | 792 (void) perl_destruct(perl); |
793 | |
794 perl_free(perl); | |
795 } | |
796 | |
649 | 797 #endif |
798 | |
799 | |
599 | 800 static ngx_int_t |
801 ngx_http_perl_preconfiguration(ngx_conf_t *cf) | |
802 { | |
617 | 803 #if (NGX_HTTP_SSI) |
599 | 804 ngx_int_t rc; |
805 ngx_http_ssi_main_conf_t *smcf; | |
806 | |
807 smcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_ssi_filter_module); | |
808 | |
809 rc = ngx_hash_add_key(&smcf->commands, &ngx_http_perl_ssi_command.name, | |
810 &ngx_http_perl_ssi_command, NGX_HASH_READONLY_KEY); | |
811 | |
812 if (rc != NGX_OK) { | |
813 if (rc == NGX_BUSY) { | |
814 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
815 "conflicting SSI command \"%V\"", | |
816 &ngx_http_perl_ssi_command.name); | |
817 } | |
818 | |
819 return NGX_ERROR; | |
820 } | |
617 | 821 #endif |
599 | 822 |
823 return NGX_OK; | |
824 } | |
825 | |
826 | |
827 static void * | |
828 ngx_http_perl_create_loc_conf(ngx_conf_t *cf) | |
829 { | |
830 ngx_http_perl_loc_conf_t *plcf; | |
831 | |
832 plcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_perl_loc_conf_t)); | |
833 if (plcf == NULL) { | |
834 return NGX_CONF_ERROR; | |
835 } | |
836 | |
837 /* | |
838 * set by ngx_pcalloc(): | |
839 * | |
840 * plcf->handler = { 0, NULL }; | |
841 */ | |
842 | |
843 return plcf; | |
844 } | |
845 | |
846 | |
847 static char * | |
848 ngx_http_perl_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
849 { | |
850 ngx_http_perl_loc_conf_t *prev = parent; | |
851 ngx_http_perl_loc_conf_t *conf = child; | |
852 | |
853 if (conf->sub == NULL) { | |
854 conf->sub = prev->sub; | |
855 conf->handler = prev->handler; | |
856 } | |
857 | |
858 return NGX_CONF_OK; | |
859 } | |
860 | |
861 | |
862 static char * | |
863 ngx_http_perl_require(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
864 { | |
865 ngx_http_perl_main_conf_t *pmcf = conf; | |
866 | |
867 u_char **p; | |
868 ngx_str_t *value; | |
869 | |
870 value = cf->args->elts; | |
871 | |
872 p = ngx_array_push(&pmcf->requires); | |
873 | |
874 if (p == NULL) { | |
875 return NGX_CONF_ERROR; | |
876 } | |
877 | |
878 *p = value[1].data; | |
879 | |
880 return NGX_CONF_OK; | |
881 } | |
882 | |
883 | |
884 static char * | |
885 ngx_http_perl(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
886 { | |
887 ngx_http_perl_loc_conf_t *plcf = conf; | |
888 | |
889 ngx_str_t *value; | |
890 ngx_http_core_loc_conf_t *clcf; | |
891 ngx_http_perl_main_conf_t *pmcf; | |
892 | |
893 value = cf->args->elts; | |
894 | |
895 if (plcf->handler.data) { | |
896 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
897 "duplicate perl handler \"%V\"", &value[1]); | |
898 return NGX_CONF_ERROR; | |
899 } | |
900 | |
901 pmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_perl_module); | |
902 | |
903 if (pmcf->perl == NULL) { | |
904 if (ngx_http_perl_init_interpreter(cf, pmcf) != NGX_CONF_OK) { | |
905 return NGX_CONF_ERROR; | |
906 } | |
907 } | |
908 | |
909 plcf->handler = value[1]; | |
910 | |
911 { | |
912 | |
913 dTHXa(pmcf->perl); | |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
914 PERL_SET_CONTEXT(pmcf->perl); |
599 | 915 |
916 ngx_http_perl_eval_anon_sub(aTHX_ &value[1], &plcf->sub); | |
917 | |
918 if (plcf->sub == &PL_sv_undef) { | |
919 ngx_conf_log_error(NGX_LOG_ERR, cf, 0, | |
920 "eval_pv(\"%V\") failed", &value[1]); | |
921 return NGX_CONF_ERROR; | |
922 } | |
923 | |
924 if (plcf->sub == NULL) { | |
925 plcf->sub = newSVpvn((char *) value[1].data, value[1].len); | |
926 } | |
927 | |
928 } | |
929 | |
930 clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); | |
931 clcf->handler = ngx_http_perl_handler; | |
932 | |
933 return NGX_CONF_OK; | |
934 } | |
935 | |
936 | |
937 static char * | |
938 ngx_http_perl_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
939 { | |
940 ngx_int_t index; | |
941 ngx_str_t *value; | |
942 ngx_http_variable_t *v; | |
943 ngx_http_perl_variable_t *pv; | |
944 ngx_http_perl_main_conf_t *pmcf; | |
945 | |
946 value = cf->args->elts; | |
947 | |
948 if (value[1].data[0] != '$') { | |
949 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
950 "invalid variable name \"%V\"", &value[1]); | |
951 return NGX_CONF_ERROR; | |
952 } | |
953 | |
954 value[1].len--; | |
955 value[1].data++; | |
956 | |
957 v = ngx_http_add_variable(cf, &value[1], NGX_HTTP_VAR_CHANGABLE); | |
958 if (v == NULL) { | |
959 return NGX_CONF_ERROR; | |
960 } | |
961 | |
962 pv = ngx_palloc(cf->pool, sizeof(ngx_http_perl_variable_t)); | |
963 if (pv == NULL) { | |
964 return NGX_CONF_ERROR; | |
965 } | |
966 | |
967 index = ngx_http_get_variable_index(cf, &value[1]); | |
968 if (index == NGX_ERROR) { | |
969 return NGX_CONF_ERROR; | |
970 } | |
971 | |
972 pmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_perl_module); | |
973 | |
974 if (pmcf->perl == NULL) { | |
975 if (ngx_http_perl_init_interpreter(cf, pmcf) != NGX_CONF_OK) { | |
976 return NGX_CONF_ERROR; | |
977 } | |
978 } | |
979 | |
980 pv->handler = value[2]; | |
981 | |
982 { | |
983 | |
984 dTHXa(pmcf->perl); | |
873
f92ad15c2db1
fix segfaults in future workers those will use old configuration,
Igor Sysoev <igor@sysoev.ru>
parents:
872
diff
changeset
|
985 PERL_SET_CONTEXT(pmcf->perl); |
599 | 986 |
987 ngx_http_perl_eval_anon_sub(aTHX_ &value[2], &pv->sub); | |
988 | |
989 if (pv->sub == &PL_sv_undef) { | |
990 ngx_conf_log_error(NGX_LOG_ERR, cf, 0, | |
991 "eval_pv(\"%V\") failed", &value[2]); | |
992 return NGX_CONF_ERROR; | |
993 } | |
994 | |
995 if (pv->sub == NULL) { | |
996 pv->sub = newSVpvn((char *) value[2].data, value[2].len); | |
997 } | |
998 | |
999 } | |
1000 | |
637 | 1001 v->get_handler = ngx_http_perl_variable; |
599 | 1002 v->data = (uintptr_t) pv; |
1003 | |
1004 return NGX_CONF_OK; | |
1005 } | |
1221
aa653367028e
PERL_SYS_TERM() should be called once on exit only, this fixes the message
Igor Sysoev <igor@sysoev.ru>
parents:
1165
diff
changeset
|
1006 |
aa653367028e
PERL_SYS_TERM() should be called once on exit only, this fixes the message
Igor Sysoev <igor@sysoev.ru>
parents:
1165
diff
changeset
|
1007 |
1257 | 1008 static ngx_int_t |
1009 ngx_http_perl_init_worker(ngx_cycle_t *cycle) | |
1010 { | |
1258
5076d97b9cf0
fix building on threaded or multiplicity interpreter perl,
Igor Sysoev <igor@sysoev.ru>
parents:
1257
diff
changeset
|
1011 ngx_http_perl_main_conf_t *pmcf; |
5076d97b9cf0
fix building on threaded or multiplicity interpreter perl,
Igor Sysoev <igor@sysoev.ru>
parents:
1257
diff
changeset
|
1012 |
5076d97b9cf0
fix building on threaded or multiplicity interpreter perl,
Igor Sysoev <igor@sysoev.ru>
parents:
1257
diff
changeset
|
1013 pmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_perl_module); |
5076d97b9cf0
fix building on threaded or multiplicity interpreter perl,
Igor Sysoev <igor@sysoev.ru>
parents:
1257
diff
changeset
|
1014 |
5076d97b9cf0
fix building on threaded or multiplicity interpreter perl,
Igor Sysoev <igor@sysoev.ru>
parents:
1257
diff
changeset
|
1015 { |
5076d97b9cf0
fix building on threaded or multiplicity interpreter perl,
Igor Sysoev <igor@sysoev.ru>
parents:
1257
diff
changeset
|
1016 |
5076d97b9cf0
fix building on threaded or multiplicity interpreter perl,
Igor Sysoev <igor@sysoev.ru>
parents:
1257
diff
changeset
|
1017 dTHXa(pmcf->perl); |
5076d97b9cf0
fix building on threaded or multiplicity interpreter perl,
Igor Sysoev <igor@sysoev.ru>
parents:
1257
diff
changeset
|
1018 PERL_SET_CONTEXT(pmcf->perl); |
5076d97b9cf0
fix building on threaded or multiplicity interpreter perl,
Igor Sysoev <igor@sysoev.ru>
parents:
1257
diff
changeset
|
1019 |
1257 | 1020 /* set worker's $$ */ |
1021 | |
1022 sv_setiv(GvSV(gv_fetchpv("$", TRUE, SVt_PV)), (I32) ngx_pid); | |
1023 | |
1258
5076d97b9cf0
fix building on threaded or multiplicity interpreter perl,
Igor Sysoev <igor@sysoev.ru>
parents:
1257
diff
changeset
|
1024 } |
5076d97b9cf0
fix building on threaded or multiplicity interpreter perl,
Igor Sysoev <igor@sysoev.ru>
parents:
1257
diff
changeset
|
1025 |
1257 | 1026 return NGX_OK; |
1027 } | |
1028 | |
1221
aa653367028e
PERL_SYS_TERM() should be called once on exit only, this fixes the message
Igor Sysoev <igor@sysoev.ru>
parents:
1165
diff
changeset
|
1029 static void |
aa653367028e
PERL_SYS_TERM() should be called once on exit only, this fixes the message
Igor Sysoev <igor@sysoev.ru>
parents:
1165
diff
changeset
|
1030 ngx_http_perl_exit(ngx_cycle_t *cycle) |
aa653367028e
PERL_SYS_TERM() should be called once on exit only, this fixes the message
Igor Sysoev <igor@sysoev.ru>
parents:
1165
diff
changeset
|
1031 { |
aa653367028e
PERL_SYS_TERM() should be called once on exit only, this fixes the message
Igor Sysoev <igor@sysoev.ru>
parents:
1165
diff
changeset
|
1032 PERL_SYS_TERM(); |
aa653367028e
PERL_SYS_TERM() should be called once on exit only, this fixes the message
Igor Sysoev <igor@sysoev.ru>
parents:
1165
diff
changeset
|
1033 } |