Mercurial > hg > nginx
annotate src/core/nginx.c @ 8794:ba5977b38b2e quic
HTTP/3: reordered H3_MISSING_SETTINGS and H3_FRAME_UNEXPECTED.
The quic-http-34 is ambiguous as to what error should be generated for the
first frame in control stream:
Each side MUST initiate a single control stream at the beginning of
the connection and send its SETTINGS frame as the first frame on this
stream. If the first frame of the control stream is any other frame
type, this MUST be treated as a connection error of type
H3_MISSING_SETTINGS.
If a DATA frame is received on a control stream, the recipient MUST
respond with a connection error of type H3_FRAME_UNEXPECTED.
If a HEADERS frame is received on a control stream, the recipient MUST
respond with a connection error of type H3_FRAME_UNEXPECTED.
Previously, H3_FRAME_UNEXPECTED had priority, but now H3_MISSING_SETTINGS has.
The arguments in the spec sound more compelling for H3_MISSING_SETTINGS.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Fri, 11 Jun 2021 10:56:51 +0300 |
parents | 7df607cb2d11 |
children | c209dc4eed17 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
440
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
440
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
443
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
440
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
440
diff
changeset
|
6 |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
7 |
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
8 #include <ngx_config.h> |
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
9 #include <ngx_core.h> |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <nginx.h> |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
6446
0ff7eff48c7e
Fix build with -Wmissing-prototypes.
Piotr Sikora <piotrsikora@google.com>
parents:
6402
diff
changeset
|
13 static void ngx_show_version_info(void); |
282
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
14 static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle); |
6822
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
15 static void ngx_cleanup_environment(void *data); |
2730
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
16 static ngx_int_t ngx_get_options(int argc, char *const *argv); |
2758 | 17 static ngx_int_t ngx_process_options(ngx_cycle_t *cycle); |
452 | 18 static ngx_int_t ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv); |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
19 static void *ngx_core_module_create_conf(ngx_cycle_t *cycle); |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
20 static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf); |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
21 static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
1069 | 22 static char *ngx_set_env(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
473 | 23 static char *ngx_set_priority(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
577 | 24 static char *ngx_set_cpu_affinity(ngx_conf_t *cf, ngx_command_t *cmd, |
25 void *conf); | |
4890
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
26 static char *ngx_set_worker_processes(ngx_conf_t *cf, ngx_command_t *cmd, |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
27 void *conf); |
6383 | 28 static char *ngx_load_module(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
29 #if (NGX_HAVE_DLOPEN) | |
30 static void ngx_unload_module(void *data); | |
31 #endif | |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
2
diff
changeset
|
32 |
117
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
33 |
461 | 34 static ngx_conf_enum_t ngx_debug_points[] = { |
35 { ngx_string("stop"), NGX_DEBUG_POINTS_STOP }, | |
36 { ngx_string("abort"), NGX_DEBUG_POINTS_ABORT }, | |
37 { ngx_null_string, 0 } | |
577 | 38 }; |
461 | 39 |
40 | |
117
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
41 static ngx_command_t ngx_core_commands[] = { |
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
42 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
43 { ngx_string("daemon"), |
563 | 44 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_FLAG, |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
45 ngx_conf_set_flag_slot, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
46 0, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
47 offsetof(ngx_core_conf_t, daemon), |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
48 NULL }, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
49 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
50 { ngx_string("master_process"), |
563 | 51 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_FLAG, |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
52 ngx_conf_set_flag_slot, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
53 0, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
54 offsetof(ngx_core_conf_t, master), |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
55 NULL }, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
56 |
563 | 57 { ngx_string("timer_resolution"), |
58 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
59 ngx_conf_set_msec_slot, | |
60 0, | |
61 offsetof(ngx_core_conf_t, timer_resolution), | |
62 NULL }, | |
63 | |
543 | 64 { ngx_string("pid"), |
65 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
66 ngx_conf_set_str_slot, | |
67 0, | |
68 offsetof(ngx_core_conf_t, pid), | |
69 NULL }, | |
70 | |
611 | 71 { ngx_string("lock_file"), |
72 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
73 ngx_conf_set_str_slot, | |
74 0, | |
75 offsetof(ngx_core_conf_t, lock_file), | |
76 NULL }, | |
77 | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
78 { ngx_string("worker_processes"), |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
79 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, |
4890
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
80 ngx_set_worker_processes, |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
81 0, |
4890
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
82 0, |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
83 NULL }, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
84 |
461 | 85 { ngx_string("debug_points"), |
86 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
87 ngx_conf_set_enum_slot, | |
88 0, | |
89 offsetof(ngx_core_conf_t, debug_points), | |
90 &ngx_debug_points }, | |
91 | |
543 | 92 { ngx_string("user"), |
93 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE12, | |
94 ngx_set_user, | |
95 0, | |
96 0, | |
97 NULL }, | |
98 | |
99 { ngx_string("worker_priority"), | |
100 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
101 ngx_set_priority, | |
102 0, | |
103 0, | |
104 NULL }, | |
105 | |
577 | 106 { ngx_string("worker_cpu_affinity"), |
107 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_1MORE, | |
108 ngx_set_cpu_affinity, | |
109 0, | |
110 0, | |
111 NULL }, | |
112 | |
543 | 113 { ngx_string("worker_rlimit_nofile"), |
114 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
115 ngx_conf_set_num_slot, | |
116 0, | |
117 offsetof(ngx_core_conf_t, rlimit_nofile), | |
118 NULL }, | |
119 | |
589 | 120 { ngx_string("worker_rlimit_core"), |
121 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
3762
89002ac695e5
worker_rlimit_core should be off_t
Igor Sysoev <igor@sysoev.ru>
parents:
3750
diff
changeset
|
122 ngx_conf_set_off_slot, |
589 | 123 0, |
124 offsetof(ngx_core_conf_t, rlimit_core), | |
125 NULL }, | |
126 | |
6930
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6822
diff
changeset
|
127 { ngx_string("worker_shutdown_timeout"), |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6822
diff
changeset
|
128 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6822
diff
changeset
|
129 ngx_conf_set_msec_slot, |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6822
diff
changeset
|
130 0, |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6822
diff
changeset
|
131 offsetof(ngx_core_conf_t, shutdown_timeout), |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6822
diff
changeset
|
132 NULL }, |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6822
diff
changeset
|
133 |
543 | 134 { ngx_string("working_directory"), |
135 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
136 ngx_conf_set_str_slot, | |
137 0, | |
138 offsetof(ngx_core_conf_t, working_directory), | |
139 NULL }, | |
140 | |
1069 | 141 { ngx_string("env"), |
142 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
143 ngx_set_env, | |
144 0, | |
145 0, | |
146 NULL }, | |
147 | |
6383 | 148 { ngx_string("load_module"), |
149 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
150 ngx_load_module, | |
151 0, | |
152 0, | |
153 NULL }, | |
154 | |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
155 ngx_null_command |
117
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
156 }; |
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
157 |
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
158 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
159 static ngx_core_module_t ngx_core_module_ctx = { |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
160 ngx_string("core"), |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
161 ngx_core_module_create_conf, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
162 ngx_core_module_init_conf |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
163 }; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
164 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
165 |
117
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
166 ngx_module_t ngx_core_module = { |
509 | 167 NGX_MODULE_V1, |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
168 &ngx_core_module_ctx, /* module context */ |
117
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
169 ngx_core_commands, /* module directives */ |
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
170 NGX_CORE_MODULE, /* module type */ |
541 | 171 NULL, /* init master */ |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
172 NULL, /* init module */ |
541 | 173 NULL, /* init process */ |
174 NULL, /* init thread */ | |
175 NULL, /* exit thread */ | |
176 NULL, /* exit process */ | |
177 NULL, /* exit master */ | |
178 NGX_MODULE_V1_PADDING | |
117
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
179 }; |
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
180 |
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
181 |
2735 | 182 static ngx_uint_t ngx_show_help; |
2725 | 183 static ngx_uint_t ngx_show_version; |
184 static ngx_uint_t ngx_show_configure; | |
2758 | 185 static u_char *ngx_prefix; |
7744
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
186 static u_char *ngx_error_log; |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
187 static u_char *ngx_conf_file; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
188 static u_char *ngx_conf_params; |
2725 | 189 static char *ngx_signal; |
190 | |
639 | 191 |
1069 | 192 static char **ngx_os_environ; |
601 | 193 |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
194 |
503 | 195 int ngx_cdecl |
499 | 196 main(int argc, char *const *argv) |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
197 { |
6187
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
198 ngx_buf_t *b; |
452 | 199 ngx_log_t *log; |
6187
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
200 ngx_uint_t i; |
452 | 201 ngx_cycle_t *cycle, init_cycle; |
6187
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
202 ngx_conf_dump_t *cd; |
452 | 203 ngx_core_conf_t *ccf; |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
204 |
4222
2dd6c7cb211a
FreeBSD's MALLOC_OPTIONS must be set before any malloc() call.
Igor Sysoev <igor@sysoev.ru>
parents:
3798
diff
changeset
|
205 ngx_debug_init(); |
2dd6c7cb211a
FreeBSD's MALLOC_OPTIONS must be set before any malloc() call.
Igor Sysoev <igor@sysoev.ru>
parents:
3798
diff
changeset
|
206 |
3798
61d64ab739a0
move ngx_strerror_init() at the very start
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
207 if (ngx_strerror_init() != NGX_OK) { |
61d64ab739a0
move ngx_strerror_init() at the very start
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
208 return 1; |
61d64ab739a0
move ngx_strerror_init() at the very start
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
209 } |
61d64ab739a0
move ngx_strerror_init() at the very start
Igor Sysoev <igor@sysoev.ru>
parents:
3787
diff
changeset
|
210 |
2730
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
211 if (ngx_get_options(argc, argv) != NGX_OK) { |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
212 return 1; |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
213 } |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
214 |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
215 if (ngx_show_version) { |
6257
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
216 ngx_show_version_info(); |
2730
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
217 |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
218 if (!ngx_test_config) { |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
219 return 0; |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
220 } |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
221 } |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
222 |
108
adc093f880c8
nginx-0.0.1-2003-07-02-09:01:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
223 /* TODO */ ngx_max_sockets = -1; |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
224 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
225 ngx_time_init(); |
221
401154e21826
nginx-0.0.1-2004-01-08-20:08:10 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
226 |
455 | 227 #if (NGX_PCRE) |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
228 ngx_regex_init(); |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
229 #endif |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
230 |
443
33aec431094b
nginx-0.1.0-2004-09-29-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
231 ngx_pid = ngx_getpid(); |
7162
8b84d60ef13d
Fixed "changing binary" when reaper is not init.
Ruslan Ermilov <ru@nginx.com>
parents:
7081
diff
changeset
|
232 ngx_parent = ngx_getppid(); |
443
33aec431094b
nginx-0.1.0-2004-09-29-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
233 |
7744
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
234 log = ngx_log_init(ngx_prefix, ngx_error_log); |
501 | 235 if (log == NULL) { |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
443
diff
changeset
|
236 return 1; |
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
443
diff
changeset
|
237 } |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
238 |
541 | 239 /* STUB */ |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
376
diff
changeset
|
240 #if (NGX_OPENSSL) |
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
376
diff
changeset
|
241 ngx_ssl_init(log); |
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
376
diff
changeset
|
242 #endif |
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
376
diff
changeset
|
243 |
2730
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
244 /* |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
245 * init_cycle->log is required for signal handlers and |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
246 * ngx_process_options() |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
247 */ |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
248 |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
249 ngx_memzero(&init_cycle, sizeof(ngx_cycle_t)); |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
250 init_cycle.log = log; |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
251 ngx_cycle = &init_cycle; |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
252 |
501 | 253 init_cycle.pool = ngx_create_pool(1024, log); |
254 if (init_cycle.pool == NULL) { | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
255 return 1; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
256 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
257 |
611 | 258 if (ngx_save_argv(&init_cycle, argc, argv) != NGX_OK) { |
452 | 259 return 1; |
260 } | |
261 | |
2758 | 262 if (ngx_process_options(&init_cycle) != NGX_OK) { |
263 return 1; | |
264 } | |
448
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
265 |
611 | 266 if (ngx_os_init(log) != NGX_OK) { |
443
33aec431094b
nginx-0.1.0-2004-09-29-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
267 return 1; |
33aec431094b
nginx-0.1.0-2004-09-29-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
268 } |
33aec431094b
nginx-0.1.0-2004-09-29-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
269 |
1694
8c696afe46b3
rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents:
1407
diff
changeset
|
270 /* |
8c696afe46b3
rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents:
1407
diff
changeset
|
271 * ngx_crc32_table_init() requires ngx_cacheline_size set in ngx_os_init() |
8c696afe46b3
rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents:
1407
diff
changeset
|
272 */ |
930
45df22906c12
allocate aligned ngx_crc32_table_short globally
Igor Sysoev <igor@sysoev.ru>
parents:
860
diff
changeset
|
273 |
1694
8c696afe46b3
rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents:
1407
diff
changeset
|
274 if (ngx_crc32_table_init() != NGX_OK) { |
930
45df22906c12
allocate aligned ngx_crc32_table_short globally
Igor Sysoev <igor@sysoev.ru>
parents:
860
diff
changeset
|
275 return 1; |
45df22906c12
allocate aligned ngx_crc32_table_short globally
Igor Sysoev <igor@sysoev.ru>
parents:
860
diff
changeset
|
276 } |
45df22906c12
allocate aligned ngx_crc32_table_short globally
Igor Sysoev <igor@sysoev.ru>
parents:
860
diff
changeset
|
277 |
7081
69f9ee0342db
Slab: fixed initialization on win32.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
278 /* |
69f9ee0342db
Slab: fixed initialization on win32.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
279 * ngx_slab_sizes_init() requires ngx_pagesize set in ngx_os_init() |
69f9ee0342db
Slab: fixed initialization on win32.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
280 */ |
69f9ee0342db
Slab: fixed initialization on win32.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
281 |
69f9ee0342db
Slab: fixed initialization on win32.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
282 ngx_slab_sizes_init(); |
69f9ee0342db
Slab: fixed initialization on win32.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
283 |
611 | 284 if (ngx_add_inherited_sockets(&init_cycle) != NGX_OK) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
285 return 1; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
286 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
287 |
6378
0f203a2af17c
Dynamic modules: moved module-related stuff to separate files.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6335
diff
changeset
|
288 if (ngx_preinit_modules() != NGX_OK) { |
0f203a2af17c
Dynamic modules: moved module-related stuff to separate files.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6335
diff
changeset
|
289 return 1; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
290 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
291 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
292 cycle = ngx_init_cycle(&init_cycle); |
108
adc093f880c8
nginx-0.0.1-2003-07-02-09:01:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
293 if (cycle == NULL) { |
320
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
294 if (ngx_test_config) { |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
295 ngx_log_stderr(0, "configuration file %s test failed", |
2722 | 296 init_cycle.conf_file.data); |
320
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
297 } |
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
298 |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
299 return 1; |
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
300 } |
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
301 |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
302 if (ngx_test_config) { |
3750 | 303 if (!ngx_quiet_mode) { |
304 ngx_log_stderr(0, "configuration file %s test is successful", | |
305 cycle->conf_file.data); | |
306 } | |
307 | |
6187
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
308 if (ngx_dump_config) { |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
309 cd = cycle->config_dump.elts; |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
310 |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
311 for (i = 0; i < cycle->config_dump.nelts; i++) { |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
312 |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
313 ngx_write_stdout("# configuration file "); |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
314 (void) ngx_write_fd(ngx_stdout, cd[i].name.data, |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
315 cd[i].name.len); |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
316 ngx_write_stdout(":" NGX_LINEFEED); |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
317 |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
318 b = cd[i].buffer; |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
319 |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
320 (void) ngx_write_fd(ngx_stdout, b->pos, b->last - b->pos); |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
321 ngx_write_stdout(NGX_LINEFEED); |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
322 } |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
323 } |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
324 |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
325 return 0; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
326 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
327 |
2923
d9c46f98b09f
a signaller process should stop configuration processing just after
Igor Sysoev <igor@sysoev.ru>
parents:
2767
diff
changeset
|
328 if (ngx_signal) { |
d9c46f98b09f
a signaller process should stop configuration processing just after
Igor Sysoev <igor@sysoev.ru>
parents:
2767
diff
changeset
|
329 return ngx_signal_process(cycle, ngx_signal); |
d9c46f98b09f
a signaller process should stop configuration processing just after
Igor Sysoev <igor@sysoev.ru>
parents:
2767
diff
changeset
|
330 } |
d9c46f98b09f
a signaller process should stop configuration processing just after
Igor Sysoev <igor@sysoev.ru>
parents:
2767
diff
changeset
|
331 |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
332 ngx_os_status(cycle->log); |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
333 |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
334 ngx_cycle = cycle; |
113
d7f606e25b99
nginx-0.0.1-2003-07-04-19:10:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
111
diff
changeset
|
335 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
336 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
337 |
2725 | 338 if (ccf->master && ngx_process == NGX_PROCESS_SINGLE) { |
339 ngx_process = NGX_PROCESS_MASTER; | |
340 } | |
220
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
341 |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2735
diff
changeset
|
342 #if !(NGX_WIN32) |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
343 |
611 | 344 if (ngx_init_signals(cycle->log) != NGX_OK) { |
539 | 345 return 1; |
346 } | |
347 | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
348 if (!ngx_inherited && ccf->daemon) { |
611 | 349 if (ngx_daemon(cycle->log) != NGX_OK) { |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
350 return 1; |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
351 } |
366
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
352 |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
353 ngx_daemonized = 1; |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
354 } |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
355 |
4293
3bae3d8fb573
Fixed handling of SIGWINCH/NOACCEPT signal.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4283
diff
changeset
|
356 if (ngx_inherited) { |
3bae3d8fb573
Fixed handling of SIGWINCH/NOACCEPT signal.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4283
diff
changeset
|
357 ngx_daemonized = 1; |
3bae3d8fb573
Fixed handling of SIGWINCH/NOACCEPT signal.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4283
diff
changeset
|
358 } |
3bae3d8fb573
Fixed handling of SIGWINCH/NOACCEPT signal.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4283
diff
changeset
|
359 |
2725 | 360 #endif |
361 | |
611 | 362 if (ngx_create_pidfile(&ccf->pid, cycle->log) != NGX_OK) { |
210
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
363 return 1; |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
364 } |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
365 |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5240
diff
changeset
|
366 if (ngx_log_redirect_stderr(cycle) != NGX_OK) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5240
diff
changeset
|
367 return 1; |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
368 } |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
369 |
3199
b242aaf1dcfa
nginx did not close log file set by --error-log-path,
Igor Sysoev <igor@sysoev.ru>
parents:
3177
diff
changeset
|
370 if (log->file->fd != ngx_stderr) { |
b242aaf1dcfa
nginx did not close log file set by --error-log-path,
Igor Sysoev <igor@sysoev.ru>
parents:
3177
diff
changeset
|
371 if (ngx_close_file(log->file->fd) == NGX_FILE_ERROR) { |
b242aaf1dcfa
nginx did not close log file set by --error-log-path,
Igor Sysoev <igor@sysoev.ru>
parents:
3177
diff
changeset
|
372 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
b242aaf1dcfa
nginx did not close log file set by --error-log-path,
Igor Sysoev <igor@sysoev.ru>
parents:
3177
diff
changeset
|
373 ngx_close_file_n " built-in log failed"); |
b242aaf1dcfa
nginx did not close log file set by --error-log-path,
Igor Sysoev <igor@sysoev.ru>
parents:
3177
diff
changeset
|
374 } |
b242aaf1dcfa
nginx did not close log file set by --error-log-path,
Igor Sysoev <igor@sysoev.ru>
parents:
3177
diff
changeset
|
375 } |
b242aaf1dcfa
nginx did not close log file set by --error-log-path,
Igor Sysoev <igor@sysoev.ru>
parents:
3177
diff
changeset
|
376 |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
377 ngx_use_stderr = 0; |
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
378 |
2725 | 379 if (ngx_process == NGX_PROCESS_SINGLE) { |
380 ngx_single_process_cycle(cycle); | |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
381 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
382 } else { |
2725 | 383 ngx_master_process_cycle(cycle); |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
384 } |
220
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
385 |
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
386 return 0; |
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
387 } |
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
388 |
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
389 |
6257
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
390 static void |
6446
0ff7eff48c7e
Fix build with -Wmissing-prototypes.
Piotr Sikora <piotrsikora@google.com>
parents:
6402
diff
changeset
|
391 ngx_show_version_info(void) |
6257
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
392 { |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
393 ngx_write_stderr("nginx version: " NGINX_VER_BUILD NGX_LINEFEED); |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
394 |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
395 if (ngx_show_help) { |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
396 ngx_write_stderr( |
7744
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
397 "Usage: nginx [-?hvVtTq] [-s signal] [-p prefix]" NGX_LINEFEED |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
398 " [-e filename] [-c filename] [-g directives]" |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
399 NGX_LINEFEED NGX_LINEFEED |
6257
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
400 "Options:" NGX_LINEFEED |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
401 " -?,-h : this help" NGX_LINEFEED |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
402 " -v : show version and exit" NGX_LINEFEED |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
403 " -V : show version and configure options then exit" |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
404 NGX_LINEFEED |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
405 " -t : test configuration and exit" NGX_LINEFEED |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
406 " -T : test configuration, dump it and exit" |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
407 NGX_LINEFEED |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
408 " -q : suppress non-error messages " |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
409 "during configuration testing" NGX_LINEFEED |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
410 " -s signal : send signal to a master process: " |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
411 "stop, quit, reopen, reload" NGX_LINEFEED |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
412 #ifdef NGX_PREFIX |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
413 " -p prefix : set prefix path (default: " NGX_PREFIX ")" |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
414 NGX_LINEFEED |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
415 #else |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
416 " -p prefix : set prefix path (default: NONE)" NGX_LINEFEED |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
417 #endif |
7744
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
418 " -e filename : set error log file (default: " |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
419 #ifdef NGX_ERROR_LOG_STDERR |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
420 "stderr)" NGX_LINEFEED |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
421 #else |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
422 NGX_ERROR_LOG_PATH ")" NGX_LINEFEED |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
423 #endif |
6257
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
424 " -c filename : set configuration file (default: " NGX_CONF_PATH |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
425 ")" NGX_LINEFEED |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
426 " -g directives : set global directives out of configuration " |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
427 "file" NGX_LINEFEED NGX_LINEFEED |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
428 ); |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
429 } |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
430 |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
431 if (ngx_show_configure) { |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
432 |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
433 #ifdef NGX_COMPILER |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
434 ngx_write_stderr("built by " NGX_COMPILER NGX_LINEFEED); |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
435 #endif |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
436 |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
437 #if (NGX_SSL) |
6492
3b77efe05b92
SSL: SSLeay_version() is deprecated in OpenSSL 1.1.0.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
438 if (ngx_strcmp(ngx_ssl_version(), OPENSSL_VERSION_TEXT) == 0) { |
6257
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
439 ngx_write_stderr("built with " OPENSSL_VERSION_TEXT NGX_LINEFEED); |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
440 } else { |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
441 ngx_write_stderr("built with " OPENSSL_VERSION_TEXT |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
442 " (running with "); |
6492
3b77efe05b92
SSL: SSLeay_version() is deprecated in OpenSSL 1.1.0.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6480
diff
changeset
|
443 ngx_write_stderr((char *) (uintptr_t) ngx_ssl_version()); |
6257
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
444 ngx_write_stderr(")" NGX_LINEFEED); |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
445 } |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
446 #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
447 ngx_write_stderr("TLS SNI support enabled" NGX_LINEFEED); |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
448 #else |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
449 ngx_write_stderr("TLS SNI support disabled" NGX_LINEFEED); |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
450 #endif |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
451 #endif |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
452 |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
453 ngx_write_stderr("configure arguments:" NGX_CONFIGURE NGX_LINEFEED); |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
454 } |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
455 } |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
456 |
5eb4d7541107
Extract out version info function.
Kurtis Nusbaum <klnusbaum@gmail.com>
parents:
6187
diff
changeset
|
457 |
499 | 458 static ngx_int_t |
459 ngx_add_inherited_sockets(ngx_cycle_t *cycle) | |
219
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
460 { |
501 | 461 u_char *p, *v, *inherited; |
462 ngx_int_t s; | |
463 ngx_listening_t *ls; | |
219
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
464 |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
289
diff
changeset
|
465 inherited = (u_char *) getenv(NGINX_VAR); |
282
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
466 |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
467 if (inherited == NULL) { |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
468 return NGX_OK; |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
469 } |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
470 |
461 | 471 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, |
282
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
472 "using inherited sockets from \"%s\"", inherited); |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
473 |
461 | 474 if (ngx_array_init(&cycle->listening, cycle->pool, 10, |
745 | 475 sizeof(ngx_listening_t)) |
2536
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2302
diff
changeset
|
476 != NGX_OK) |
461 | 477 { |
478 return NGX_ERROR; | |
479 } | |
282
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
480 |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
481 for (p = inherited, v = p; *p; p++) { |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
482 if (*p == ':' || *p == ';') { |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
483 s = ngx_atoi(v, p - v); |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
484 if (s == NGX_ERROR) { |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
485 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
537 | 486 "invalid socket number \"%s\" in " NGINX_VAR |
487 " environment variable, ignoring the rest" | |
488 " of the variable", v); | |
282
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
489 break; |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
490 } |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
491 |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
289
diff
changeset
|
492 v = p + 1; |
282
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
493 |
501 | 494 ls = ngx_array_push(&cycle->listening); |
495 if (ls == NULL) { | |
282
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
496 return NGX_ERROR; |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
289
diff
changeset
|
497 } |
219
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
498 |
523 | 499 ngx_memzero(ls, sizeof(ngx_listening_t)); |
500 | |
501 | 501 ls->fd = (ngx_socket_t) s; |
7662
9c038f5e0464
Fixed removing of listening UNIX sockets when "changing binary".
Ruslan Ermilov <ru@nginx.com>
parents:
7248
diff
changeset
|
502 ls->inherited = 1; |
219
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
503 } |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
504 } |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
505 |
6399
50fb3fd79f76
Core: improved logging on invalid NGINX variable (ticket #900).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6383
diff
changeset
|
506 if (v != p) { |
50fb3fd79f76
Core: improved logging on invalid NGINX variable (ticket #900).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6383
diff
changeset
|
507 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
50fb3fd79f76
Core: improved logging on invalid NGINX variable (ticket #900).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6383
diff
changeset
|
508 "invalid socket number \"%s\" in " NGINX_VAR |
50fb3fd79f76
Core: improved logging on invalid NGINX variable (ticket #900).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6383
diff
changeset
|
509 " environment variable, ignoring", v); |
50fb3fd79f76
Core: improved logging on invalid NGINX variable (ticket #900).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6383
diff
changeset
|
510 } |
50fb3fd79f76
Core: improved logging on invalid NGINX variable (ticket #900).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6383
diff
changeset
|
511 |
282
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
512 ngx_inherited = 1; |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
513 |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
514 return ngx_set_inherited_sockets(cycle); |
219
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
515 } |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
516 |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
517 |
1069 | 518 char ** |
519 ngx_set_environment(ngx_cycle_t *cycle, ngx_uint_t *last) | |
520 { | |
6822
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
521 char **p, **env; |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
522 ngx_str_t *var; |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
523 ngx_uint_t i, n; |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
524 ngx_core_conf_t *ccf; |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
525 ngx_pool_cleanup_t *cln; |
1069 | 526 |
527 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); | |
528 | |
1080 | 529 if (last == NULL && ccf->environment) { |
530 return ccf->environment; | |
1069 | 531 } |
532 | |
533 var = ccf->env.elts; | |
534 | |
535 for (i = 0; i < ccf->env.nelts; i++) { | |
536 if (ngx_strcmp(var[i].data, "TZ") == 0 | |
537 || ngx_strncmp(var[i].data, "TZ=", 3) == 0) | |
538 { | |
539 goto tz_found; | |
540 } | |
541 } | |
542 | |
543 var = ngx_array_push(&ccf->env); | |
1318 | 544 if (var == NULL) { |
545 return NULL; | |
546 } | |
1069 | 547 |
548 var->len = 2; | |
549 var->data = (u_char *) "TZ"; | |
550 | |
551 var = ccf->env.elts; | |
552 | |
553 tz_found: | |
554 | |
1080 | 555 n = 0; |
556 | |
1069 | 557 for (i = 0; i < ccf->env.nelts; i++) { |
558 | |
559 if (var[i].data[var[i].len] == '=') { | |
560 n++; | |
561 continue; | |
562 } | |
563 | |
564 for (p = ngx_os_environ; *p; p++) { | |
565 | |
566 if (ngx_strncmp(*p, var[i].data, var[i].len) == 0 | |
567 && (*p)[var[i].len] == '=') | |
568 { | |
569 n++; | |
570 break; | |
571 } | |
572 } | |
573 } | |
574 | |
575 if (last) { | |
1080 | 576 env = ngx_alloc((*last + n + 1) * sizeof(char *), cycle->log); |
6822
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
577 if (env == NULL) { |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
578 return NULL; |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
579 } |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
580 |
1069 | 581 *last = n; |
582 | |
583 } else { | |
6822
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
584 cln = ngx_pool_cleanup_add(cycle->pool, 0); |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
585 if (cln == NULL) { |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
586 return NULL; |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
587 } |
1069 | 588 |
6822
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
589 env = ngx_alloc((n + 1) * sizeof(char *), cycle->log); |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
590 if (env == NULL) { |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
591 return NULL; |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
592 } |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
593 |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
594 cln->handler = ngx_cleanup_environment; |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
595 cln->data = env; |
1069 | 596 } |
597 | |
598 n = 0; | |
599 | |
600 for (i = 0; i < ccf->env.nelts; i++) { | |
601 | |
602 if (var[i].data[var[i].len] == '=') { | |
603 env[n++] = (char *) var[i].data; | |
604 continue; | |
605 } | |
606 | |
607 for (p = ngx_os_environ; *p; p++) { | |
608 | |
609 if (ngx_strncmp(*p, var[i].data, var[i].len) == 0 | |
610 && (*p)[var[i].len] == '=') | |
611 { | |
612 env[n++] = *p; | |
613 break; | |
614 } | |
615 } | |
616 } | |
617 | |
618 env[n] = NULL; | |
619 | |
620 if (last == NULL) { | |
621 ccf->environment = env; | |
622 environ = env; | |
623 } | |
624 | |
625 return env; | |
626 } | |
627 | |
628 | |
6822
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
629 static void |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
630 ngx_cleanup_environment(void *data) |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
631 { |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
632 char **env = data; |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
633 |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
634 if (environ == env) { |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
635 |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
636 /* |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
637 * if the environment is still used, as it happens on exit, |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
638 * the only option is to leak it |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
639 */ |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
640 |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
641 return; |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
642 } |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
643 |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
644 ngx_free(env); |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
645 } |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
646 |
c045b4926b2c
Core: fixed environment on exit.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6492
diff
changeset
|
647 |
543 | 648 ngx_pid_t |
649 ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv) | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
650 { |
1069 | 651 char **env, *var; |
652 u_char *p; | |
653 ngx_uint_t i, n; | |
654 ngx_pid_t pid; | |
655 ngx_exec_ctx_t ctx; | |
656 ngx_core_conf_t *ccf; | |
657 ngx_listening_t *ls; | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
658 |
2745
1983932b8075
pass command lines options to workers
Igor Sysoev <igor@sysoev.ru>
parents:
2743
diff
changeset
|
659 ngx_memzero(&ctx, sizeof(ngx_exec_ctx_t)); |
1983932b8075
pass command lines options to workers
Igor Sysoev <igor@sysoev.ru>
parents:
2743
diff
changeset
|
660 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
661 ctx.path = argv[0]; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
662 ctx.name = "new binary process"; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
663 ctx.argv = argv; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
664 |
1069 | 665 n = 2; |
666 env = ngx_set_environment(cycle, &n); | |
667 if (env == NULL) { | |
668 return NGX_INVALID_PID; | |
669 } | |
670 | |
282
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
671 var = ngx_alloc(sizeof(NGINX_VAR) |
501 | 672 + cycle->listening.nelts * (NGX_INT32_LEN + 1) + 2, |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
673 cycle->log); |
5116
4d7027deb1bb
Core: guard against failed allocation during binary upgrade.
Ruslan Ermilov <ru@nginx.com>
parents:
4890
diff
changeset
|
674 if (var == NULL) { |
5122
3450eee1ee8d
Core: fixed resource leak if binary upgrade fails due to no memory.
Ruslan Ermilov <ru@nginx.com>
parents:
5116
diff
changeset
|
675 ngx_free(env); |
5116
4d7027deb1bb
Core: guard against failed allocation during binary upgrade.
Ruslan Ermilov <ru@nginx.com>
parents:
4890
diff
changeset
|
676 return NGX_INVALID_PID; |
4d7027deb1bb
Core: guard against failed allocation during binary upgrade.
Ruslan Ermilov <ru@nginx.com>
parents:
4890
diff
changeset
|
677 } |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
678 |
461 | 679 p = ngx_cpymem(var, NGINX_VAR "=", sizeof(NGINX_VAR)); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
680 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
681 ls = cycle->listening.elts; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
682 for (i = 0; i < cycle->listening.nelts; i++) { |
8676
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
7744
diff
changeset
|
683 if (ls[i].ignore) { |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
7744
diff
changeset
|
684 continue; |
7df607cb2d11
QUIC: ngx_quic_bpf module.
Vladimir Homutov <vl@nginx.com>
parents:
7744
diff
changeset
|
685 } |
461 | 686 p = ngx_sprintf(p, "%ud;", ls[i].fd); |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
687 } |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
688 |
461 | 689 *p = '\0'; |
690 | |
1069 | 691 env[n++] = var; |
452 | 692 |
693 #if (NGX_SETPROCTITLE_USES_ENV) | |
694 | |
461 | 695 /* allocate the spare 300 bytes for the new binary process title */ |
452 | 696 |
1069 | 697 env[n++] = "SPARE=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
698 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |
699 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |
700 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |
701 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; | |
452 | 702 |
703 #endif | |
704 | |
1069 | 705 env[n] = NULL; |
706 | |
707 #if (NGX_DEBUG) | |
708 { | |
709 char **e; | |
710 for (e = env; *e; e++) { | |
711 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0, "env: %s", *e); | |
712 } | |
713 } | |
714 #endif | |
715 | |
716 ctx.envp = (char *const *) env; | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
717 |
543 | 718 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
719 | |
5137
f941cf265cc5
Use NGX_FILE_ERROR for handling file operations errors.
Valentin Bartenev <vbart@nginx.com>
parents:
5122
diff
changeset
|
720 if (ngx_rename_file(ccf->pid.data, ccf->oldpid.data) == NGX_FILE_ERROR) { |
543 | 721 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
722 ngx_rename_file_n " %s to %s failed " | |
723 "before executing new binary process \"%s\"", | |
724 ccf->pid.data, ccf->oldpid.data, argv[0]); | |
725 | |
1069 | 726 ngx_free(env); |
543 | 727 ngx_free(var); |
728 | |
729 return NGX_INVALID_PID; | |
730 } | |
731 | |
279
b79f021a644a
nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
278
diff
changeset
|
732 pid = ngx_execute(cycle, &ctx); |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
733 |
543 | 734 if (pid == NGX_INVALID_PID) { |
5137
f941cf265cc5
Use NGX_FILE_ERROR for handling file operations errors.
Valentin Bartenev <vbart@nginx.com>
parents:
5122
diff
changeset
|
735 if (ngx_rename_file(ccf->oldpid.data, ccf->pid.data) |
f941cf265cc5
Use NGX_FILE_ERROR for handling file operations errors.
Valentin Bartenev <vbart@nginx.com>
parents:
5122
diff
changeset
|
736 == NGX_FILE_ERROR) |
f941cf265cc5
Use NGX_FILE_ERROR for handling file operations errors.
Valentin Bartenev <vbart@nginx.com>
parents:
5122
diff
changeset
|
737 { |
543 | 738 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
1069 | 739 ngx_rename_file_n " %s back to %s failed after " |
4593
834049edae24
Fixed grammar in error messages.
Ruslan Ermilov <ru@nginx.com>
parents:
4549
diff
changeset
|
740 "an attempt to execute new binary process \"%s\"", |
543 | 741 ccf->oldpid.data, ccf->pid.data, argv[0]); |
742 } | |
743 } | |
744 | |
1069 | 745 ngx_free(env); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
746 ngx_free(var); |
226
b0c1e21e68db
nginx-0.0.1-2004-01-14-00:33:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
225
diff
changeset
|
747 |
b0c1e21e68db
nginx-0.0.1-2004-01-14-00:33:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
225
diff
changeset
|
748 return pid; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
749 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
750 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
751 |
543 | 752 static ngx_int_t |
2730
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
753 ngx_get_options(int argc, char *const *argv) |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
754 { |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
755 u_char *p; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
756 ngx_int_t i; |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
757 |
452 | 758 for (i = 1; i < argc; i++) { |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
759 |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
760 p = (u_char *) argv[i]; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
761 |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
762 if (*p++ != '-') { |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
763 ngx_log_stderr(0, "invalid option: \"%s\"", argv[i]); |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
764 return NGX_ERROR; |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
765 } |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
766 |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
767 while (*p) { |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
768 |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
769 switch (*p++) { |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
770 |
2735 | 771 case '?': |
772 case 'h': | |
773 ngx_show_version = 1; | |
774 ngx_show_help = 1; | |
775 break; | |
776 | |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
777 case 'v': |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
778 ngx_show_version = 1; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
779 break; |
639 | 780 |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
781 case 'V': |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
782 ngx_show_version = 1; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
783 ngx_show_configure = 1; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
784 break; |
945 | 785 |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
786 case 't': |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
787 ngx_test_config = 1; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
788 break; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
789 |
6187
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
790 case 'T': |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
791 ngx_test_config = 1; |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
792 ngx_dump_config = 1; |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
793 break; |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6127
diff
changeset
|
794 |
3750 | 795 case 'q': |
796 ngx_quiet_mode = 1; | |
797 break; | |
798 | |
2758 | 799 case 'p': |
800 if (*p) { | |
801 ngx_prefix = p; | |
802 goto next; | |
803 } | |
804 | |
805 if (argv[++i]) { | |
806 ngx_prefix = (u_char *) argv[i]; | |
807 goto next; | |
808 } | |
809 | |
810 ngx_log_stderr(0, "option \"-p\" requires directory name"); | |
811 return NGX_ERROR; | |
812 | |
7744
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
813 case 'e': |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
814 if (*p) { |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
815 ngx_error_log = p; |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
816 |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
817 } else if (argv[++i]) { |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
818 ngx_error_log = (u_char *) argv[i]; |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
819 |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
820 } else { |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
821 ngx_log_stderr(0, "option \"-e\" requires file name"); |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
822 return NGX_ERROR; |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
823 } |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
824 |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
825 if (ngx_strcmp(ngx_error_log, "stderr") == 0) { |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
826 ngx_error_log = (u_char *) ""; |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
827 } |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
828 |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
829 goto next; |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
830 |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
831 case 'c': |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
832 if (*p) { |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
833 ngx_conf_file = p; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
834 goto next; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
835 } |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
836 |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
837 if (argv[++i]) { |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
838 ngx_conf_file = (u_char *) argv[i]; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
839 goto next; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
840 } |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
841 |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
842 ngx_log_stderr(0, "option \"-c\" requires file name"); |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
843 return NGX_ERROR; |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
844 |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
845 case 'g': |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
846 if (*p) { |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
847 ngx_conf_params = p; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
848 goto next; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
849 } |
2073 | 850 |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
851 if (argv[++i]) { |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
852 ngx_conf_params = (u_char *) argv[i]; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
853 goto next; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
854 } |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
855 |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
856 ngx_log_stderr(0, "option \"-g\" requires parameter"); |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
857 return NGX_ERROR; |
2073 | 858 |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
859 case 's': |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
860 if (*p) { |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
861 ngx_signal = (char *) p; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
862 |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
863 } else if (argv[++i]) { |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
864 ngx_signal = argv[i]; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
865 |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
866 } else { |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
867 ngx_log_stderr(0, "option \"-s\" requires parameter"); |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
868 return NGX_ERROR; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
869 } |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
870 |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
871 if (ngx_strcmp(ngx_signal, "stop") == 0 |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
872 || ngx_strcmp(ngx_signal, "quit") == 0 |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
873 || ngx_strcmp(ngx_signal, "reopen") == 0 |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
874 || ngx_strcmp(ngx_signal, "reload") == 0) |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
875 { |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
876 ngx_process = NGX_PROCESS_SIGNALLER; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
877 goto next; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
878 } |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
879 |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
880 ngx_log_stderr(0, "invalid option: \"-s %s\"", ngx_signal); |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
881 return NGX_ERROR; |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
882 |
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
883 default: |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
884 ngx_log_stderr(0, "invalid option: \"%c\"", *(p - 1)); |
2725 | 885 return NGX_ERROR; |
886 } | |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
887 } |
2725 | 888 |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
889 next: |
2725 | 890 |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
891 continue; |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
892 } |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
893 |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
894 return NGX_OK; |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
895 } |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
896 |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
897 |
499 | 898 static ngx_int_t |
899 ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv) | |
452 | 900 { |
501 | 901 #if (NGX_FREEBSD) |
902 | |
903 ngx_os_argv = (char **) argv; | |
904 ngx_argc = argc; | |
905 ngx_argv = (char **) argv; | |
906 | |
907 #else | |
452 | 908 size_t len; |
909 ngx_int_t i; | |
910 | |
911 ngx_os_argv = (char **) argv; | |
912 ngx_argc = argc; | |
913 | |
501 | 914 ngx_argv = ngx_alloc((argc + 1) * sizeof(char *), cycle->log); |
915 if (ngx_argv == NULL) { | |
452 | 916 return NGX_ERROR; |
917 } | |
918 | |
919 for (i = 0; i < argc; i++) { | |
920 len = ngx_strlen(argv[i]) + 1; | |
921 | |
501 | 922 ngx_argv[i] = ngx_alloc(len, cycle->log); |
923 if (ngx_argv[i] == NULL) { | |
452 | 924 return NGX_ERROR; |
925 } | |
926 | |
517 | 927 (void) ngx_cpystrn((u_char *) ngx_argv[i], (u_char *) argv[i], len); |
452 | 928 } |
929 | |
930 ngx_argv[i] = NULL; | |
931 | |
932 #endif | |
933 | |
1069 | 934 ngx_os_environ = environ; |
935 | |
452 | 936 return NGX_OK; |
937 } | |
938 | |
939 | |
2758 | 940 static ngx_int_t |
2730
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
941 ngx_process_options(ngx_cycle_t *cycle) |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
942 { |
2758 | 943 u_char *p; |
944 size_t len; | |
945 | |
946 if (ngx_prefix) { | |
947 len = ngx_strlen(ngx_prefix); | |
948 p = ngx_prefix; | |
949 | |
4783
2220ce29b9d3
Fixed the -p parameter handling.
Ruslan Ermilov <ru@nginx.com>
parents:
4593
diff
changeset
|
950 if (len && !ngx_path_separator(p[len - 1])) { |
2758 | 951 p = ngx_pnalloc(cycle->pool, len + 1); |
952 if (p == NULL) { | |
953 return NGX_ERROR; | |
954 } | |
955 | |
956 ngx_memcpy(p, ngx_prefix, len); | |
957 p[len++] = '/'; | |
958 } | |
959 | |
960 cycle->conf_prefix.len = len; | |
961 cycle->conf_prefix.data = p; | |
962 cycle->prefix.len = len; | |
963 cycle->prefix.data = p; | |
964 | |
965 } else { | |
966 | |
967 #ifndef NGX_PREFIX | |
968 | |
969 p = ngx_pnalloc(cycle->pool, NGX_MAX_PATH); | |
970 if (p == NULL) { | |
971 return NGX_ERROR; | |
972 } | |
973 | |
974 if (ngx_getcwd(p, NGX_MAX_PATH) == 0) { | |
975 ngx_log_stderr(ngx_errno, "[emerg]: " ngx_getcwd_n " failed"); | |
976 return NGX_ERROR; | |
977 } | |
978 | |
979 len = ngx_strlen(p); | |
980 | |
981 p[len++] = '/'; | |
982 | |
983 cycle->conf_prefix.len = len; | |
984 cycle->conf_prefix.data = p; | |
985 cycle->prefix.len = len; | |
986 cycle->prefix.data = p; | |
987 | |
988 #else | |
989 | |
990 #ifdef NGX_CONF_PREFIX | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3480
diff
changeset
|
991 ngx_str_set(&cycle->conf_prefix, NGX_CONF_PREFIX); |
2758 | 992 #else |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3480
diff
changeset
|
993 ngx_str_set(&cycle->conf_prefix, NGX_PREFIX); |
2758 | 994 #endif |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3480
diff
changeset
|
995 ngx_str_set(&cycle->prefix, NGX_PREFIX); |
2758 | 996 |
997 #endif | |
998 } | |
999 | |
2730
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1000 if (ngx_conf_file) { |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1001 cycle->conf_file.len = ngx_strlen(ngx_conf_file); |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
1002 cycle->conf_file.data = ngx_conf_file; |
2730
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1003 |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1004 } else { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3480
diff
changeset
|
1005 ngx_str_set(&cycle->conf_file, NGX_CONF_PATH); |
2730
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1006 } |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1007 |
5330
314c3d7cc3a5
Backed out f1a91825730a and 7094bd12c1ff.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5317
diff
changeset
|
1008 if (ngx_conf_full_name(cycle, &cycle->conf_file, 0) != NGX_OK) { |
2758 | 1009 return NGX_ERROR; |
1010 } | |
1011 | |
1012 for (p = cycle->conf_file.data + cycle->conf_file.len - 1; | |
1013 p > cycle->conf_file.data; | |
1014 p--) | |
1015 { | |
1016 if (ngx_path_separator(*p)) { | |
7248
fdd6a070d518
Improved code readability (closes #1512).
Ruslan Ermilov <ru@nginx.com>
parents:
7162
diff
changeset
|
1017 cycle->conf_prefix.len = p - cycle->conf_file.data + 1; |
fdd6a070d518
Improved code readability (closes #1512).
Ruslan Ermilov <ru@nginx.com>
parents:
7162
diff
changeset
|
1018 cycle->conf_prefix.data = cycle->conf_file.data; |
2758 | 1019 break; |
1020 } | |
1021 } | |
1022 | |
7744
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
1023 if (ngx_error_log) { |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
1024 cycle->error_log.len = ngx_strlen(ngx_error_log); |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
1025 cycle->error_log.data = ngx_error_log; |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
1026 |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
1027 } else { |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
1028 ngx_str_set(&cycle->error_log, NGX_ERROR_LOG_PATH); |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
1029 } |
f18db38a9826
Core: "-e" command line option.
Igor Ippolitov <iippolitov@nginx.com>
parents:
7662
diff
changeset
|
1030 |
2730
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1031 if (ngx_conf_params) { |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1032 cycle->conf_param.len = ngx_strlen(ngx_conf_params); |
2733
edc01cc34b3e
allow condensed command lines options
Igor Sysoev <igor@sysoev.ru>
parents:
2730
diff
changeset
|
1033 cycle->conf_param.data = ngx_conf_params; |
2730
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1034 } |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1035 |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1036 if (ngx_test_config) { |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1037 cycle->log->log_level = NGX_LOG_INFO; |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1038 } |
2758 | 1039 |
1040 return NGX_OK; | |
2730
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1041 } |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1042 |
95a17423afdb
test command line options before ngx_log_init() and issue errors to stderr
Igor Sysoev <igor@sysoev.ru>
parents:
2725
diff
changeset
|
1043 |
499 | 1044 static void * |
1045 ngx_core_module_create_conf(ngx_cycle_t *cycle) | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
1046 { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
1047 ngx_core_conf_t *ccf; |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
1048 |
501 | 1049 ccf = ngx_pcalloc(cycle->pool, sizeof(ngx_core_conf_t)); |
1050 if (ccf == NULL) { | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1051 return NULL; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
1052 } |
479 | 1053 |
1054 /* | |
3480 | 1055 * set by ngx_pcalloc() |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
1056 * |
479 | 1057 * ccf->pid = NULL; |
543 | 1058 * ccf->oldpid = NULL; |
479 | 1059 * ccf->priority = 0; |
6335
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1060 * ccf->cpu_affinity_auto = 0; |
577 | 1061 * ccf->cpu_affinity_n = 0; |
1062 * ccf->cpu_affinity = NULL; | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
1063 */ |
479 | 1064 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1065 ccf->daemon = NGX_CONF_UNSET; |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1066 ccf->master = NGX_CONF_UNSET; |
563 | 1067 ccf->timer_resolution = NGX_CONF_UNSET_MSEC; |
6930
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6822
diff
changeset
|
1068 ccf->shutdown_timeout = NGX_CONF_UNSET_MSEC; |
563 | 1069 |
300
502b03d9d2a3
nginx-0.0.3-2004-03-31-00:31:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1070 ccf->worker_processes = NGX_CONF_UNSET; |
461 | 1071 ccf->debug_points = NGX_CONF_UNSET; |
543 | 1072 |
1073 ccf->rlimit_nofile = NGX_CONF_UNSET; | |
3762
89002ac695e5
worker_rlimit_core should be off_t
Igor Sysoev <igor@sysoev.ru>
parents:
3750
diff
changeset
|
1074 ccf->rlimit_core = NGX_CONF_UNSET; |
543 | 1075 |
517 | 1076 ccf->user = (ngx_uid_t) NGX_CONF_UNSET_UINT; |
1077 ccf->group = (ngx_gid_t) NGX_CONF_UNSET_UINT; | |
543 | 1078 |
1069 | 1079 if (ngx_array_init(&ccf->env, cycle->pool, 1, sizeof(ngx_str_t)) |
1080 != NGX_OK) | |
1081 { | |
1082 return NULL; | |
1083 } | |
1084 | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1085 return ccf; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1086 } |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1087 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1088 |
499 | 1089 static char * |
1090 ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf) | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1091 { |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1092 ngx_core_conf_t *ccf = conf; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1093 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1094 ngx_conf_init_value(ccf->daemon, 1); |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1095 ngx_conf_init_value(ccf->master, 1); |
563 | 1096 ngx_conf_init_msec_value(ccf->timer_resolution, 0); |
6930
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6822
diff
changeset
|
1097 ngx_conf_init_msec_value(ccf->shutdown_timeout, 0); |
563 | 1098 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1099 ngx_conf_init_value(ccf->worker_processes, 1); |
461 | 1100 ngx_conf_init_value(ccf->debug_points, 0); |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1101 |
4549
f31162fefe01
worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
1102 #if (NGX_HAVE_CPU_AFFINITY) |
577 | 1103 |
6335
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1104 if (!ccf->cpu_affinity_auto |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1105 && ccf->cpu_affinity_n |
577 | 1106 && ccf->cpu_affinity_n != 1 |
1107 && ccf->cpu_affinity_n != (ngx_uint_t) ccf->worker_processes) | |
1108 { | |
1109 ngx_log_error(NGX_LOG_WARN, cycle->log, 0, | |
4549
f31162fefe01
worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
1110 "the number of \"worker_processes\" is not equal to " |
f31162fefe01
worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
1111 "the number of \"worker_cpu_affinity\" masks, " |
577 | 1112 "using last mask for remaining worker processes"); |
1113 } | |
1114 | |
1115 #endif | |
1116 | |
2725 | 1117 |
1118 if (ccf->pid.len == 0) { | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3480
diff
changeset
|
1119 ngx_str_set(&ccf->pid, NGX_PID_PATH); |
2725 | 1120 } |
1121 | |
5330
314c3d7cc3a5
Backed out f1a91825730a and 7094bd12c1ff.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5317
diff
changeset
|
1122 if (ngx_conf_full_name(cycle, &ccf->pid, 0) != NGX_OK) { |
2725 | 1123 return NGX_CONF_ERROR; |
1124 } | |
1125 | |
1126 ccf->oldpid.len = ccf->pid.len + sizeof(NGX_OLDPID_EXT); | |
1127 | |
1128 ccf->oldpid.data = ngx_pnalloc(cycle->pool, ccf->oldpid.len); | |
1129 if (ccf->oldpid.data == NULL) { | |
1130 return NGX_CONF_ERROR; | |
1131 } | |
1132 | |
1133 ngx_memcpy(ngx_cpymem(ccf->oldpid.data, ccf->pid.data, ccf->pid.len), | |
1134 NGX_OLDPID_EXT, sizeof(NGX_OLDPID_EXT)); | |
1135 | |
1136 | |
461 | 1137 #if !(NGX_WIN32) |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1138 |
517 | 1139 if (ccf->user == (uid_t) NGX_CONF_UNSET_UINT && geteuid() == 0) { |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1694
diff
changeset
|
1140 struct group *grp; |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1694
diff
changeset
|
1141 struct passwd *pwd; |
440
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1142 |
1288 | 1143 ngx_set_errno(0); |
455 | 1144 pwd = getpwnam(NGX_USER); |
440
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1145 if (pwd == NULL) { |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1146 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
455 | 1147 "getpwnam(\"" NGX_USER "\") failed"); |
440
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1148 return NGX_CONF_ERROR; |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1149 } |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1150 |
473 | 1151 ccf->username = NGX_USER; |
440
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1152 ccf->user = pwd->pw_uid; |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1153 |
1288 | 1154 ngx_set_errno(0); |
455 | 1155 grp = getgrnam(NGX_GROUP); |
440
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1156 if (grp == NULL) { |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1157 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
455 | 1158 "getgrnam(\"" NGX_GROUP "\") failed"); |
440
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1159 return NGX_CONF_ERROR; |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1160 } |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1161 |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1162 ccf->group = grp->gr_gid; |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1163 } |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
1164 |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1165 |
611 | 1166 if (ccf->lock_file.len == 0) { |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3480
diff
changeset
|
1167 ngx_str_set(&ccf->lock_file, NGX_LOCK_PATH); |
611 | 1168 } |
1169 | |
5330
314c3d7cc3a5
Backed out f1a91825730a and 7094bd12c1ff.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5317
diff
changeset
|
1170 if (ngx_conf_full_name(cycle, &ccf->lock_file, 0) != NGX_OK) { |
611 | 1171 return NGX_CONF_ERROR; |
1172 } | |
1173 | |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1694
diff
changeset
|
1174 { |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1694
diff
changeset
|
1175 ngx_str_t lock_file; |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1694
diff
changeset
|
1176 |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1177 lock_file = cycle->old_cycle->lock_file; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1178 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1179 if (lock_file.len) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1180 lock_file.len--; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1181 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1182 if (ccf->lock_file.len != lock_file.len |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1183 || ngx_strncmp(ccf->lock_file.data, lock_file.data, lock_file.len) |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1184 != 0) |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1185 { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1186 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1187 "\"lock_file\" could not be changed, ignored"); |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1188 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1189 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1190 cycle->lock_file.len = lock_file.len + 1; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1191 lock_file.len += sizeof(".accept"); |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1192 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1193 cycle->lock_file.data = ngx_pstrdup(cycle->pool, &lock_file); |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1194 if (cycle->lock_file.data == NULL) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1195 return NGX_CONF_ERROR; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1196 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1197 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1198 } else { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1199 cycle->lock_file.len = ccf->lock_file.len + 1; |
2049 | 1200 cycle->lock_file.data = ngx_pnalloc(cycle->pool, |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1201 ccf->lock_file.len + sizeof(".accept")); |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1202 if (cycle->lock_file.data == NULL) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1203 return NGX_CONF_ERROR; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1204 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1205 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1206 ngx_memcpy(ngx_cpymem(cycle->lock_file.data, ccf->lock_file.data, |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1207 ccf->lock_file.len), |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1208 ".accept", sizeof(".accept")); |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1209 } |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1694
diff
changeset
|
1210 } |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
1211 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1212 #endif |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1213 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1214 return NGX_CONF_OK; |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
1215 } |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1216 |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1217 |
499 | 1218 static char * |
1219 ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1220 { |
461 | 1221 #if (NGX_WIN32) |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
1222 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
1223 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
1224 "\"user\" is not supported, ignored"); |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
1225 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
1226 return NGX_CONF_OK; |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
1227 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
1228 #else |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
1229 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1230 ngx_core_conf_t *ccf = conf; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1231 |
455 | 1232 char *group; |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1233 struct passwd *pwd; |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1234 struct group *grp; |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1235 ngx_str_t *value; |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1236 |
517 | 1237 if (ccf->user != (uid_t) NGX_CONF_UNSET_UINT) { |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1238 return "is duplicate"; |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1239 } |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1240 |
455 | 1241 if (geteuid() != 0) { |
1242 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
1243 "the \"user\" directive makes sense only " | |
1244 "if the master process runs " | |
1245 "with super-user privileges, ignored"); | |
1246 return NGX_CONF_OK; | |
1247 } | |
1248 | |
6264
7ac57369036c
Style: unneeded casts of cf->args->elts removed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6257
diff
changeset
|
1249 value = cf->args->elts; |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1250 |
473 | 1251 ccf->username = (char *) value[1].data; |
1252 | |
1288 | 1253 ngx_set_errno(0); |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
289
diff
changeset
|
1254 pwd = getpwnam((const char *) value[1].data); |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1255 if (pwd == NULL) { |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1256 ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno, |
452 | 1257 "getpwnam(\"%s\") failed", value[1].data); |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1258 return NGX_CONF_ERROR; |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1259 } |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1260 |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1261 ccf->user = pwd->pw_uid; |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1262 |
455 | 1263 group = (char *) ((cf->args->nelts == 2) ? value[1].data : value[2].data); |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1264 |
1288 | 1265 ngx_set_errno(0); |
455 | 1266 grp = getgrnam(group); |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1267 if (grp == NULL) { |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1268 ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno, |
455 | 1269 "getgrnam(\"%s\") failed", group); |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1270 return NGX_CONF_ERROR; |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1271 } |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1272 |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1273 ccf->group = grp->gr_gid; |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1274 |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1275 return NGX_CONF_OK; |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
1276 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
1277 #endif |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
1278 } |
473 | 1279 |
1280 | |
499 | 1281 static char * |
1069 | 1282 ngx_set_env(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
1283 { | |
1284 ngx_core_conf_t *ccf = conf; | |
1285 | |
1286 ngx_str_t *value, *var; | |
1287 ngx_uint_t i; | |
1288 | |
1289 var = ngx_array_push(&ccf->env); | |
1290 if (var == NULL) { | |
1291 return NGX_CONF_ERROR; | |
1292 } | |
1293 | |
1294 value = cf->args->elts; | |
1295 *var = value[1]; | |
1296 | |
1297 for (i = 0; i < value[1].len; i++) { | |
1298 | |
1299 if (value[1].data[i] == '=') { | |
1300 | |
1301 var->len = i; | |
1302 | |
1303 return NGX_CONF_OK; | |
1304 } | |
1305 } | |
1306 | |
1307 return NGX_CONF_OK; | |
1308 } | |
1309 | |
1310 | |
1311 static char * | |
499 | 1312 ngx_set_priority(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
473 | 1313 { |
1314 ngx_core_conf_t *ccf = conf; | |
1315 | |
1316 ngx_str_t *value; | |
1317 ngx_uint_t n, minus; | |
1318 | |
1319 if (ccf->priority != 0) { | |
1320 return "is duplicate"; | |
1321 } | |
1322 | |
1323 value = cf->args->elts; | |
1324 | |
1325 if (value[1].data[0] == '-') { | |
1326 n = 1; | |
1327 minus = 1; | |
1328 | |
1329 } else if (value[1].data[0] == '+') { | |
1330 n = 1; | |
1331 minus = 0; | |
1332 | |
1333 } else { | |
1334 n = 0; | |
1335 minus = 0; | |
1336 } | |
1337 | |
1338 ccf->priority = ngx_atoi(&value[1].data[n], value[1].len - n); | |
1339 if (ccf->priority == NGX_ERROR) { | |
1340 return "invalid number"; | |
1341 } | |
1342 | |
1343 if (minus) { | |
1344 ccf->priority = -ccf->priority; | |
1345 } | |
1346 | |
1347 return NGX_CONF_OK; | |
1348 } | |
577 | 1349 |
1350 | |
1351 static char * | |
1352 ngx_set_cpu_affinity(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1353 { | |
4549
f31162fefe01
worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
1354 #if (NGX_HAVE_CPU_AFFINITY) |
577 | 1355 ngx_core_conf_t *ccf = conf; |
1356 | |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1357 u_char ch, *p; |
577 | 1358 ngx_str_t *value; |
1359 ngx_uint_t i, n; | |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1360 ngx_cpuset_t *mask; |
577 | 1361 |
1362 if (ccf->cpu_affinity) { | |
1363 return "is duplicate"; | |
1364 } | |
1365 | |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1366 mask = ngx_palloc(cf->pool, (cf->args->nelts - 1) * sizeof(ngx_cpuset_t)); |
577 | 1367 if (mask == NULL) { |
1368 return NGX_CONF_ERROR; | |
1369 } | |
1370 | |
1371 ccf->cpu_affinity_n = cf->args->nelts - 1; | |
1372 ccf->cpu_affinity = mask; | |
1373 | |
1374 value = cf->args->elts; | |
1375 | |
6335
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1376 if (ngx_strcmp(value[1].data, "auto") == 0) { |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1377 |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1378 if (cf->args->nelts > 3) { |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1379 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1380 "invalid number of arguments in " |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1381 "\"worker_cpu_affinity\" directive"); |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1382 return NGX_CONF_ERROR; |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1383 } |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1384 |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1385 ccf->cpu_affinity_auto = 1; |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1386 |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1387 CPU_ZERO(&mask[0]); |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1388 for (i = 0; i < (ngx_uint_t) ngx_min(ngx_ncpu, CPU_SETSIZE); i++) { |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1389 CPU_SET(i, &mask[0]); |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1390 } |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1391 |
6335
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1392 n = 2; |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1393 |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1394 } else { |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1395 n = 1; |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1396 } |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1397 |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1398 for ( /* void */ ; n < cf->args->nelts; n++) { |
577 | 1399 |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1400 if (value[n].len > CPU_SETSIZE) { |
577 | 1401 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1402 "\"worker_cpu_affinity\" supports up to %d CPUs only", |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1403 CPU_SETSIZE); |
577 | 1404 return NGX_CONF_ERROR; |
1405 } | |
1406 | |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1407 i = 0; |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1408 CPU_ZERO(&mask[n - 1]); |
577 | 1409 |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1410 for (p = value[n].data + value[n].len - 1; |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1411 p >= value[n].data; |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1412 p--) |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1413 { |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1414 ch = *p; |
577 | 1415 |
1416 if (ch == ' ') { | |
1417 continue; | |
1418 } | |
1419 | |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1420 i++; |
577 | 1421 |
1422 if (ch == '0') { | |
1423 continue; | |
1424 } | |
1425 | |
1426 if (ch == '1') { | |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1427 CPU_SET(i - 1, &mask[n - 1]); |
577 | 1428 continue; |
1429 } | |
1430 | |
1431 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1432 "invalid character \"%c\" in \"worker_cpu_affinity\"", | |
1433 ch); | |
2024 | 1434 return NGX_CONF_ERROR; |
577 | 1435 } |
1436 } | |
1437 | |
1438 #else | |
1439 | |
1440 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
1441 "\"worker_cpu_affinity\" is not supported " | |
1442 "on this platform, ignored"); | |
1443 #endif | |
1444 | |
1445 return NGX_CONF_OK; | |
1446 } | |
1447 | |
1448 | |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1449 ngx_cpuset_t * |
577 | 1450 ngx_get_cpu_affinity(ngx_uint_t n) |
1451 { | |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1452 #if (NGX_HAVE_CPU_AFFINITY) |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1453 ngx_uint_t i, j; |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1454 ngx_cpuset_t *mask; |
577 | 1455 ngx_core_conf_t *ccf; |
1456 | |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1457 static ngx_cpuset_t result; |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1458 |
577 | 1459 ccf = (ngx_core_conf_t *) ngx_get_conf(ngx_cycle->conf_ctx, |
1460 ngx_core_module); | |
1461 | |
1462 if (ccf->cpu_affinity == NULL) { | |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1463 return NULL; |
577 | 1464 } |
1465 | |
6335
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1466 if (ccf->cpu_affinity_auto) { |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1467 mask = &ccf->cpu_affinity[ccf->cpu_affinity_n - 1]; |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1468 |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1469 for (i = 0, j = n; /* void */ ; i++) { |
6335
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1470 |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1471 if (CPU_ISSET(i % CPU_SETSIZE, mask) && j-- == 0) { |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1472 break; |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1473 } |
6335
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1474 |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1475 if (i == CPU_SETSIZE && j == n) { |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1476 /* empty mask */ |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1477 return NULL; |
6335
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1478 } |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1479 |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1480 /* void */ |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1481 } |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1482 |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1483 CPU_ZERO(&result); |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1484 CPU_SET(i % CPU_SETSIZE, &result); |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1485 |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1486 return &result; |
6335
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1487 } |
96c4297375bc
Core: worker_cpu_affinity auto.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6264
diff
changeset
|
1488 |
577 | 1489 if (ccf->cpu_affinity_n > n) { |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1490 return &ccf->cpu_affinity[n]; |
577 | 1491 } |
1492 | |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1493 return &ccf->cpu_affinity[ccf->cpu_affinity_n - 1]; |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1494 |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1495 #else |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1496 |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1497 return NULL; |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1498 |
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6399
diff
changeset
|
1499 #endif |
577 | 1500 } |
4890
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1501 |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1502 |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1503 static char * |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1504 ngx_set_worker_processes(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1505 { |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1506 ngx_str_t *value; |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1507 ngx_core_conf_t *ccf; |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1508 |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1509 ccf = (ngx_core_conf_t *) conf; |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1510 |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1511 if (ccf->worker_processes != NGX_CONF_UNSET) { |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1512 return "is duplicate"; |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1513 } |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1514 |
6264
7ac57369036c
Style: unneeded casts of cf->args->elts removed.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6257
diff
changeset
|
1515 value = cf->args->elts; |
4890
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1516 |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1517 if (ngx_strcmp(value[1].data, "auto") == 0) { |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1518 ccf->worker_processes = ngx_ncpu; |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1519 return NGX_CONF_OK; |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1520 } |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1521 |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1522 ccf->worker_processes = ngx_atoi(value[1].data, value[1].len); |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1523 |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1524 if (ccf->worker_processes == NGX_ERROR) { |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1525 return "invalid value"; |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1526 } |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1527 |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1528 return NGX_CONF_OK; |
173cd5458281
Core: the "auto" parameter of the "worker_processes" directive.
Andrey Belov <defan@nginx.com>
parents:
4783
diff
changeset
|
1529 } |
6383 | 1530 |
1531 | |
1532 static char * | |
1533 ngx_load_module(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1534 { | |
1535 #if (NGX_HAVE_DLOPEN) | |
1536 void *handle; | |
1537 char **names, **order; | |
1538 ngx_str_t *value, file; | |
1539 ngx_uint_t i; | |
1540 ngx_module_t *module, **modules; | |
1541 ngx_pool_cleanup_t *cln; | |
1542 | |
1543 if (cf->cycle->modules_used) { | |
1544 return "is specified too late"; | |
1545 } | |
1546 | |
1547 value = cf->args->elts; | |
1548 | |
1549 file = value[1]; | |
1550 | |
1551 if (ngx_conf_full_name(cf->cycle, &file, 0) != NGX_OK) { | |
1552 return NGX_CONF_ERROR; | |
1553 } | |
1554 | |
1555 cln = ngx_pool_cleanup_add(cf->cycle->pool, 0); | |
1556 if (cln == NULL) { | |
1557 return NGX_CONF_ERROR; | |
1558 } | |
1559 | |
1560 handle = ngx_dlopen(file.data); | |
1561 if (handle == NULL) { | |
1562 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1563 ngx_dlopen_n " \"%s\" failed (%s)", | |
1564 file.data, ngx_dlerror()); | |
1565 return NGX_CONF_ERROR; | |
1566 } | |
1567 | |
1568 cln->handler = ngx_unload_module; | |
1569 cln->data = handle; | |
1570 | |
1571 modules = ngx_dlsym(handle, "ngx_modules"); | |
1572 if (modules == NULL) { | |
1573 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1574 ngx_dlsym_n " \"%V\", \"%s\" failed (%s)", | |
1575 &value[1], "ngx_modules", ngx_dlerror()); | |
1576 return NGX_CONF_ERROR; | |
1577 } | |
1578 | |
1579 names = ngx_dlsym(handle, "ngx_module_names"); | |
1580 if (names == NULL) { | |
1581 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1582 ngx_dlsym_n " \"%V\", \"%s\" failed (%s)", | |
1583 &value[1], "ngx_module_names", ngx_dlerror()); | |
1584 return NGX_CONF_ERROR; | |
1585 } | |
1586 | |
1587 order = ngx_dlsym(handle, "ngx_module_order"); | |
1588 | |
1589 for (i = 0; modules[i]; i++) { | |
1590 module = modules[i]; | |
1591 module->name = names[i]; | |
1592 | |
1593 if (ngx_add_module(cf, &file, module, order) != NGX_OK) { | |
1594 return NGX_CONF_ERROR; | |
1595 } | |
1596 | |
6480 | 1597 ngx_log_debug2(NGX_LOG_DEBUG_CORE, cf->log, 0, "module: %s i:%ui", |
6383 | 1598 module->name, module->index); |
1599 } | |
1600 | |
1601 return NGX_CONF_OK; | |
1602 | |
1603 #else | |
1604 | |
1605 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1606 "\"load_module\" is not supported " | |
1607 "on this platform"); | |
1608 return NGX_CONF_ERROR; | |
1609 | |
1610 #endif | |
1611 } | |
1612 | |
1613 | |
1614 #if (NGX_HAVE_DLOPEN) | |
1615 | |
1616 static void | |
1617 ngx_unload_module(void *data) | |
1618 { | |
1619 void *handle = data; | |
1620 | |
1621 if (ngx_dlclose(handle) != 0) { | |
1622 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, | |
1623 ngx_dlclose_n " failed (%s)", ngx_dlerror()); | |
1624 } | |
1625 } | |
1626 | |
1627 #endif |