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