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