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