annotate src/http/modules/perl/ngx_http_perl_module.c @ 5324:8ef1722143dc

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