Mercurial > hg > nginx-quic
annotate src/core/nginx.c @ 2488:ac695b3e981c
avoid deep nested calls, flatten call tree
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 31 Jan 2009 20:34:26 +0000 |
parents | 2abf14c952a2 |
children | a6d6d762c554 |
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 |
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
|
4 */ |
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 |
98
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
6 |
c9b243802a17
nginx-0.0.1-2003-05-30-18:27:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
97
diff
changeset
|
7 #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
|
8 #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
|
9 #include <nginx.h> |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
282
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
12 static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle); |
452 | 13 static ngx_int_t ngx_getopt(ngx_cycle_t *cycle, int argc, char *const *argv); |
14 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
|
15 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
|
16 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
|
17 static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
1069 | 18 static char *ngx_set_env(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
473 | 19 static char *ngx_set_priority(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
577 | 20 static char *ngx_set_cpu_affinity(ngx_conf_t *cf, ngx_command_t *cmd, |
21 void *conf); | |
3
34a521b1a148
nginx-0.0.1-2002-08-20-18:48:28 import
Igor Sysoev <igor@sysoev.ru>
parents:
2
diff
changeset
|
22 |
117
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
23 |
461 | 24 static ngx_conf_enum_t ngx_debug_points[] = { |
25 { ngx_string("stop"), NGX_DEBUG_POINTS_STOP }, | |
26 { ngx_string("abort"), NGX_DEBUG_POINTS_ABORT }, | |
27 { ngx_null_string, 0 } | |
577 | 28 }; |
461 | 29 |
30 | |
117
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
31 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
|
32 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
33 { ngx_string("daemon"), |
563 | 34 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
|
35 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
|
36 0, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
37 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
|
38 NULL }, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
39 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
40 { ngx_string("master_process"), |
563 | 41 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
|
42 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
|
43 0, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
44 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
|
45 NULL }, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
46 |
563 | 47 { ngx_string("timer_resolution"), |
48 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
49 ngx_conf_set_msec_slot, | |
50 0, | |
51 offsetof(ngx_core_conf_t, timer_resolution), | |
52 NULL }, | |
53 | |
543 | 54 { ngx_string("pid"), |
55 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
56 ngx_conf_set_str_slot, | |
57 0, | |
58 offsetof(ngx_core_conf_t, pid), | |
59 NULL }, | |
60 | |
611 | 61 { ngx_string("lock_file"), |
62 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
63 ngx_conf_set_str_slot, | |
64 0, | |
65 offsetof(ngx_core_conf_t, lock_file), | |
66 NULL }, | |
67 | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
68 { 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
|
69 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
|
70 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
|
71 0, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
72 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
|
73 NULL }, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
74 |
461 | 75 { ngx_string("debug_points"), |
76 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
77 ngx_conf_set_enum_slot, | |
78 0, | |
79 offsetof(ngx_core_conf_t, debug_points), | |
80 &ngx_debug_points }, | |
81 | |
543 | 82 { ngx_string("user"), |
83 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE12, | |
84 ngx_set_user, | |
85 0, | |
86 0, | |
87 NULL }, | |
88 | |
89 { ngx_string("worker_priority"), | |
90 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
91 ngx_set_priority, | |
92 0, | |
93 0, | |
94 NULL }, | |
95 | |
577 | 96 { ngx_string("worker_cpu_affinity"), |
97 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_1MORE, | |
98 ngx_set_cpu_affinity, | |
99 0, | |
100 0, | |
101 NULL }, | |
102 | |
543 | 103 { ngx_string("worker_rlimit_nofile"), |
104 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
105 ngx_conf_set_num_slot, | |
106 0, | |
107 offsetof(ngx_core_conf_t, rlimit_nofile), | |
108 NULL }, | |
109 | |
589 | 110 { ngx_string("worker_rlimit_core"), |
111 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
949
d1d8cde9aab9
worker_rlimit_core supports size in K, M, and G
Igor Sysoev <igor@sysoev.ru>
parents:
947
diff
changeset
|
112 ngx_conf_set_size_slot, |
589 | 113 0, |
114 offsetof(ngx_core_conf_t, rlimit_core), | |
115 NULL }, | |
116 | |
543 | 117 { ngx_string("worker_rlimit_sigpending"), |
118 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
119 ngx_conf_set_num_slot, | |
120 0, | |
121 offsetof(ngx_core_conf_t, rlimit_sigpending), | |
122 NULL }, | |
123 | |
124 { ngx_string("working_directory"), | |
125 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
126 ngx_conf_set_str_slot, | |
127 0, | |
128 offsetof(ngx_core_conf_t, working_directory), | |
129 NULL }, | |
130 | |
1069 | 131 { ngx_string("env"), |
132 NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1, | |
133 ngx_set_env, | |
134 0, | |
135 0, | |
136 NULL }, | |
137 | |
376
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
138 #if (NGX_THREADS) |
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
139 |
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
140 { 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
|
141 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
|
142 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
|
143 0, |
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
144 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
|
145 NULL }, |
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
146 |
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
147 { 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
|
148 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
|
149 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
|
150 0, |
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
151 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
|
152 NULL }, |
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
153 |
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
154 #endif |
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
155 |
209
e1c815be05ae
nginx-0.0.1-2003-12-09-18:08:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
207
diff
changeset
|
156 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
|
157 }; |
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
158 |
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
159 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
160 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
|
161 ngx_string("core"), |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
162 ngx_core_module_create_conf, |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
163 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
|
164 }; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
165 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
166 |
117
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
167 ngx_module_t ngx_core_module = { |
509 | 168 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
|
169 &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
|
170 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
|
171 NGX_CORE_MODULE, /* module type */ |
541 | 172 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
|
173 NULL, /* init module */ |
541 | 174 NULL, /* init process */ |
175 NULL, /* init thread */ | |
176 NULL, /* exit thread */ | |
177 NULL, /* exit process */ | |
178 NULL, /* exit master */ | |
179 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
|
180 }; |
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
181 |
f6e3c5d019b6
nginx-0.0.1-2003-07-11-19:17:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
115
diff
changeset
|
182 |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
183 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
|
184 |
639 | 185 static ngx_uint_t ngx_show_version; |
945 | 186 static ngx_uint_t ngx_show_configure; |
639 | 187 |
1069 | 188 static char **ngx_os_environ; |
601 | 189 |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
190 |
503 | 191 int ngx_cdecl |
499 | 192 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
|
193 { |
2302
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
194 char *p; |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
195 ssize_t n; |
452 | 196 ngx_int_t i; |
197 ngx_log_t *log; | |
198 ngx_cycle_t *cycle, init_cycle; | |
199 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
|
200 |
455 | 201 #if (NGX_FREEBSD) |
207
6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
201
diff
changeset
|
202 ngx_debug_init(); |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
203 #endif |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
204 |
108
adc093f880c8
nginx-0.0.1-2003-07-02-09:01:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
107
diff
changeset
|
205 /* 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
|
206 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
207 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
|
208 |
455 | 209 #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
|
210 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
|
211 #endif |
182
3c49eaf3f522
nginx-0.0.1-2003-11-13-09:14:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
144
diff
changeset
|
212 |
443
33aec431094b
nginx-0.1.0-2004-09-29-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
213 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
|
214 |
501 | 215 log = ngx_log_init(); |
216 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
|
217 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
|
218 } |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
219 |
541 | 220 /* STUB */ |
393
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
376
diff
changeset
|
221 #if (NGX_OPENSSL) |
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
376
diff
changeset
|
222 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
|
223 #endif |
5659d773cfa8
nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents:
376
diff
changeset
|
224 |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
225 /* init_cycle->log is required for signal handlers and ngx_getopt() */ |
212
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
226 |
679f60139863
nginx-0.0.1-2003-12-19-11:15:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
210
diff
changeset
|
227 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
|
228 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
|
229 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
|
230 |
501 | 231 init_cycle.pool = ngx_create_pool(1024, log); |
232 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
|
233 return 1; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
234 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
235 |
611 | 236 if (ngx_save_argv(&init_cycle, argc, argv) != NGX_OK) { |
452 | 237 return 1; |
238 } | |
239 | |
611 | 240 if (ngx_getopt(&init_cycle, argc, ngx_argv) != NGX_OK) { |
440
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
241 return 1; |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
242 } |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
243 |
639 | 244 if (ngx_show_version) { |
2302
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
245 |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
246 p = "nginx version: " NGINX_VER CRLF; |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
247 n = sizeof("nginx version: " NGINX_VER CRLF) - 1; |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
248 |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
249 if (ngx_write_fd(ngx_stderr_fileno, p, n) != n) { |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
250 return 1; |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
251 } |
639 | 252 |
945 | 253 if (ngx_show_configure) { |
639 | 254 #ifdef NGX_COMPILER |
2302
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
255 p = "built by " NGX_COMPILER CRLF; |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
256 n = sizeof("built by " NGX_COMPILER CRLF) - 1; |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
257 |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
258 if (ngx_write_fd(ngx_stderr_fileno, p, n) != n) { |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
259 return 1; |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
260 } |
639 | 261 #endif |
945 | 262 |
2302
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
263 p = "configure arguments: " NGX_CONFIGURE CRLF; |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
264 n = sizeof("configure arguments :" NGX_CONFIGURE CRLF) - 1; |
947 | 265 |
2302
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
266 if (ngx_write_fd(ngx_stderr_fileno, p, n) != n) { |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
267 return 1; |
2abf14c952a2
compatibility with glibc 2.3, warn_unused_result attribute for write()
Igor Sysoev <igor@sysoev.ru>
parents:
2233
diff
changeset
|
268 } |
945 | 269 } |
270 | |
641 | 271 if (!ngx_test_config) { |
272 return 0; | |
273 } | |
639 | 274 } |
275 | |
448
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
276 if (ngx_test_config) { |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
277 log->log_level = NGX_LOG_INFO; |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
278 } |
241dc8092a33
nginx-0.1.0-2004-10-01-19:53:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
444
diff
changeset
|
279 |
611 | 280 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
|
281 return 1; |
33aec431094b
nginx-0.1.0-2004-09-29-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
282 } |
33aec431094b
nginx-0.1.0-2004-09-29-00:09:22 import
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
283 |
1694
8c696afe46b3
rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents:
1407
diff
changeset
|
284 /* |
8c696afe46b3
rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents:
1407
diff
changeset
|
285 * 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
|
286 */ |
930
45df22906c12
allocate aligned ngx_crc32_table_short globally
Igor Sysoev <igor@sysoev.ru>
parents:
860
diff
changeset
|
287 |
1694
8c696afe46b3
rename ngx_crc32_init() to ngx_crc32_table_init()
Igor Sysoev <igor@sysoev.ru>
parents:
1407
diff
changeset
|
288 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
|
289 return 1; |
45df22906c12
allocate aligned ngx_crc32_table_short globally
Igor Sysoev <igor@sysoev.ru>
parents:
860
diff
changeset
|
290 } |
45df22906c12
allocate aligned ngx_crc32_table_short globally
Igor Sysoev <igor@sysoev.ru>
parents:
860
diff
changeset
|
291 |
611 | 292 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
|
293 return 1; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
294 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
295 |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
296 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
|
297 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
|
298 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
|
299 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
300 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
301 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
|
302 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
|
303 if (ngx_test_config) { |
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
304 ngx_log_error(NGX_LOG_EMERG, log, 0, |
557 | 305 "the configuration file %s test failed", |
320
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
306 init_cycle.conf_file.data); |
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
307 } |
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
308 |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
309 return 1; |
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
310 } |
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
311 |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
312 if (ngx_test_config) { |
320
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
313 ngx_log_error(NGX_LOG_INFO, log, 0, |
557 | 314 "the configuration file %s was tested successfully", |
455 | 315 cycle->conf_file.data); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
316 return 0; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
317 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
318 |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
319 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
|
320 |
114
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
321 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
|
322 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
323 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
|
324 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
325 ngx_process = ccf->master ? NGX_PROCESS_MASTER : NGX_PROCESS_SINGLE; |
220
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
326 |
461 | 327 #if (NGX_WIN32) |
220
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
328 |
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
329 #if 0 |
366
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
330 |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
331 TODO: |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
332 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
333 if (ccf->run_as_service) { |
611 | 334 if (ngx_service(cycle->log) != NGX_OK) { |
220
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
335 return 1; |
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
336 } |
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
337 |
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
338 return 0; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
339 } |
220
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
340 #endif |
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
341 |
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
342 #else |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
343 |
611 | 344 if (ngx_init_signals(cycle->log) != NGX_OK) { |
539 | 345 return 1; |
346 } | |
347 | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
348 if (!ngx_inherited && ccf->daemon) { |
611 | 349 if (ngx_daemon(cycle->log) != NGX_OK) { |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
350 return 1; |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
351 } |
366
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
352 |
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
353 ngx_daemonized = 1; |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
354 } |
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
355 |
611 | 356 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
|
357 return 1; |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
358 } |
00cafae0bdf1
nginx-0.0.1-2003-12-14-23:10:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
209
diff
changeset
|
359 |
115
be27f922b9a2
nginx-0.0.1-2003-07-10-20:26:57 import
Igor Sysoev <igor@sysoev.ru>
parents:
114
diff
changeset
|
360 #endif |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
106
diff
changeset
|
361 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
362 if (ngx_process == NGX_PROCESS_MASTER) { |
452 | 363 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
|
364 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
365 } else { |
452 | 366 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
|
367 } |
220
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
368 |
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
369 return 0; |
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
370 } |
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
371 |
4f81b931e9ff
nginx-0.0.1-2004-01-08-11:47:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
219
diff
changeset
|
372 |
499 | 373 static ngx_int_t |
374 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
|
375 { |
501 | 376 u_char *p, *v, *inherited; |
377 ngx_int_t s; | |
378 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
|
379 |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
289
diff
changeset
|
380 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
|
381 |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
382 if (inherited == NULL) { |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
383 return NGX_OK; |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
384 } |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
385 |
461 | 386 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
|
387 "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
|
388 |
461 | 389 if (ngx_array_init(&cycle->listening, cycle->pool, 10, |
745 | 390 sizeof(ngx_listening_t)) |
391 == NGX_ERROR) | |
461 | 392 { |
393 return NGX_ERROR; | |
394 } | |
282
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
395 |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
396 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
|
397 if (*p == ':' || *p == ';') { |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
398 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
|
399 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
|
400 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
537 | 401 "invalid socket number \"%s\" in " NGINX_VAR |
402 " environment variable, ignoring the rest" | |
403 " 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
|
404 break; |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
405 } |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
406 |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
289
diff
changeset
|
407 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
|
408 |
501 | 409 ls = ngx_array_push(&cycle->listening); |
410 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
|
411 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
|
412 } |
219
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
413 |
523 | 414 ngx_memzero(ls, sizeof(ngx_listening_t)); |
415 | |
501 | 416 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
|
417 } |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
418 } |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
419 |
282
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
420 ngx_inherited = 1; |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
421 |
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
422 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
|
423 } |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
424 |
f57597ec5249
nginx-0.0.1-2004-01-06-19:49:34 import
Igor Sysoev <igor@sysoev.ru>
parents:
218
diff
changeset
|
425 |
1069 | 426 char ** |
427 ngx_set_environment(ngx_cycle_t *cycle, ngx_uint_t *last) | |
428 { | |
429 char **p, **env; | |
430 ngx_str_t *var; | |
431 ngx_uint_t i, n; | |
432 ngx_core_conf_t *ccf; | |
433 | |
434 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); | |
435 | |
1080 | 436 if (last == NULL && ccf->environment) { |
437 return ccf->environment; | |
1069 | 438 } |
439 | |
440 var = ccf->env.elts; | |
441 | |
442 for (i = 0; i < ccf->env.nelts; i++) { | |
443 if (ngx_strcmp(var[i].data, "TZ") == 0 | |
444 || ngx_strncmp(var[i].data, "TZ=", 3) == 0) | |
445 { | |
446 goto tz_found; | |
447 } | |
448 } | |
449 | |
450 var = ngx_array_push(&ccf->env); | |
1318 | 451 if (var == NULL) { |
452 return NULL; | |
453 } | |
1069 | 454 |
455 var->len = 2; | |
456 var->data = (u_char *) "TZ"; | |
457 | |
458 var = ccf->env.elts; | |
459 | |
460 tz_found: | |
461 | |
1080 | 462 n = 0; |
463 | |
1069 | 464 for (i = 0; i < ccf->env.nelts; i++) { |
465 | |
466 if (var[i].data[var[i].len] == '=') { | |
467 n++; | |
468 continue; | |
469 } | |
470 | |
471 for (p = ngx_os_environ; *p; p++) { | |
472 | |
473 if (ngx_strncmp(*p, var[i].data, var[i].len) == 0 | |
474 && (*p)[var[i].len] == '=') | |
475 { | |
476 n++; | |
477 break; | |
478 } | |
479 } | |
480 } | |
481 | |
482 if (last) { | |
1080 | 483 env = ngx_alloc((*last + n + 1) * sizeof(char *), cycle->log); |
1069 | 484 *last = n; |
485 | |
486 } else { | |
487 env = ngx_palloc(cycle->pool, (n + 1) * sizeof(char *)); | |
488 } | |
489 | |
490 if (env == NULL) { | |
491 return NULL; | |
492 } | |
493 | |
494 n = 0; | |
495 | |
496 for (i = 0; i < ccf->env.nelts; i++) { | |
497 | |
498 if (var[i].data[var[i].len] == '=') { | |
499 env[n++] = (char *) var[i].data; | |
500 continue; | |
501 } | |
502 | |
503 for (p = ngx_os_environ; *p; p++) { | |
504 | |
505 if (ngx_strncmp(*p, var[i].data, var[i].len) == 0 | |
506 && (*p)[var[i].len] == '=') | |
507 { | |
508 env[n++] = *p; | |
509 break; | |
510 } | |
511 } | |
512 } | |
513 | |
514 env[n] = NULL; | |
515 | |
516 if (last == NULL) { | |
517 ccf->environment = env; | |
518 environ = env; | |
519 } | |
520 | |
521 return env; | |
522 } | |
523 | |
524 | |
543 | 525 ngx_pid_t |
526 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
|
527 { |
1069 | 528 char **env, *var; |
529 u_char *p; | |
530 ngx_uint_t i, n; | |
531 ngx_pid_t pid; | |
532 ngx_exec_ctx_t ctx; | |
533 ngx_core_conf_t *ccf; | |
534 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
|
535 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
536 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
|
537 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
|
538 ctx.argv = argv; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
539 |
1069 | 540 n = 2; |
541 env = ngx_set_environment(cycle, &n); | |
542 if (env == NULL) { | |
543 return NGX_INVALID_PID; | |
544 } | |
545 | |
282
30310107dbc9
nginx-0.0.2-2004-03-09-22:47:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
279
diff
changeset
|
546 var = ngx_alloc(sizeof(NGINX_VAR) |
501 | 547 + 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
|
548 cycle->log); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
549 |
461 | 550 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
|
551 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
552 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
|
553 for (i = 0; i < cycle->listening.nelts; i++) { |
461 | 554 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
|
555 } |
ac69ab96328d
nginx-0.0.1-2003-07-07-10:11:50 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
556 |
461 | 557 *p = '\0'; |
558 | |
1069 | 559 env[n++] = var; |
452 | 560 |
561 #if (NGX_SETPROCTITLE_USES_ENV) | |
562 | |
461 | 563 /* allocate the spare 300 bytes for the new binary process title */ |
452 | 564 |
1069 | 565 env[n++] = "SPARE=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
566 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |
567 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |
568 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | |
569 "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; | |
452 | 570 |
571 #endif | |
572 | |
1069 | 573 env[n] = NULL; |
574 | |
575 #if (NGX_DEBUG) | |
576 { | |
577 char **e; | |
578 for (e = env; *e; e++) { | |
579 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0, "env: %s", *e); | |
580 } | |
581 } | |
582 #endif | |
583 | |
584 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
|
585 |
543 | 586 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
587 | |
1069 | 588 if (ngx_rename_file(ccf->pid.data, ccf->oldpid.data) != NGX_OK) { |
543 | 589 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
590 ngx_rename_file_n " %s to %s failed " | |
591 "before executing new binary process \"%s\"", | |
592 ccf->pid.data, ccf->oldpid.data, argv[0]); | |
593 | |
1069 | 594 ngx_free(env); |
543 | 595 ngx_free(var); |
596 | |
597 return NGX_INVALID_PID; | |
598 } | |
599 | |
279
b79f021a644a
nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents:
278
diff
changeset
|
600 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
|
601 |
543 | 602 if (pid == NGX_INVALID_PID) { |
1069 | 603 if (ngx_rename_file(ccf->oldpid.data, ccf->pid.data) != NGX_OK) { |
543 | 604 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
1069 | 605 ngx_rename_file_n " %s back to %s failed after " |
606 "the try to execute the new binary process \"%s\"", | |
543 | 607 ccf->oldpid.data, ccf->pid.data, argv[0]); |
608 } | |
609 } | |
610 | |
1069 | 611 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
|
612 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
|
613 |
b0c1e21e68db
nginx-0.0.1-2004-01-14-00:33:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
225
diff
changeset
|
614 return pid; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
615 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
616 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
617 |
543 | 618 static ngx_int_t |
619 ngx_getopt(ngx_cycle_t *cycle, 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
|
620 { |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
621 ngx_int_t i; |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
622 |
452 | 623 for (i = 1; i < argc; i++) { |
624 if (argv[i][0] != '-') { | |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
625 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
452 | 626 "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
|
627 return NGX_ERROR; |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
628 } |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
629 |
452 | 630 switch (argv[i][1]) { |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
631 |
639 | 632 case 'v': |
633 ngx_show_version = 1; | |
634 break; | |
635 | |
945 | 636 case 'V': |
637 ngx_show_version = 1; | |
638 ngx_show_configure = 1; | |
639 break; | |
640 | |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
641 case 't': |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
642 ngx_test_config = 1; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
643 break; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
644 |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
645 case 'c': |
452 | 646 if (argv[i + 1] == NULL) { |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
647 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
2073 | 648 "the option \"-c\" requires file name"); |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
649 return NGX_ERROR; |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
650 } |
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
314
diff
changeset
|
651 |
452 | 652 cycle->conf_file.data = (u_char *) argv[++i]; |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
653 cycle->conf_file.len = ngx_strlen(cycle->conf_file.data); |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
654 break; |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
655 |
2073 | 656 case 'g': |
657 if (argv[i + 1] == NULL) { | |
658 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, | |
659 "the option \"-g\" requires parameter"); | |
660 return NGX_ERROR; | |
661 } | |
662 | |
663 cycle->conf_param.data = (u_char *) argv[++i]; | |
664 cycle->conf_param.len = ngx_strlen(cycle->conf_param.data); | |
665 break; | |
666 | |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
667 default: |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
668 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
452 | 669 "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
|
670 return NGX_ERROR; |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
671 } |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
672 } |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
673 |
256
8e39cab6abd5
nginx-0.0.2-2004-02-10-19:23:38 import
Igor Sysoev <igor@sysoev.ru>
parents:
255
diff
changeset
|
674 if (cycle->conf_file.data == NULL) { |
337
4feff829a849
nginx-0.0.3-2004-05-19-00:28:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
326
diff
changeset
|
675 cycle->conf_file.len = sizeof(NGX_CONF_PATH) - 1; |
4feff829a849
nginx-0.0.3-2004-05-19-00:28:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
326
diff
changeset
|
676 cycle->conf_file.data = (u_char *) NGX_CONF_PATH; |
255
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 |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
679 return NGX_OK; |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
680 } |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
681 |
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
253
diff
changeset
|
682 |
499 | 683 static ngx_int_t |
684 ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv) | |
452 | 685 { |
501 | 686 #if (NGX_FREEBSD) |
687 | |
688 ngx_os_argv = (char **) argv; | |
689 ngx_argc = argc; | |
690 ngx_argv = (char **) argv; | |
691 | |
692 #else | |
452 | 693 size_t len; |
694 ngx_int_t i; | |
695 | |
696 ngx_os_argv = (char **) argv; | |
697 ngx_argc = argc; | |
698 | |
501 | 699 ngx_argv = ngx_alloc((argc + 1) * sizeof(char *), cycle->log); |
700 if (ngx_argv == NULL) { | |
452 | 701 return NGX_ERROR; |
702 } | |
703 | |
704 for (i = 0; i < argc; i++) { | |
705 len = ngx_strlen(argv[i]) + 1; | |
706 | |
501 | 707 ngx_argv[i] = ngx_alloc(len, cycle->log); |
708 if (ngx_argv[i] == NULL) { | |
452 | 709 return NGX_ERROR; |
710 } | |
711 | |
517 | 712 (void) ngx_cpystrn((u_char *) ngx_argv[i], (u_char *) argv[i], len); |
452 | 713 } |
714 | |
715 ngx_argv[i] = NULL; | |
716 | |
717 #endif | |
718 | |
1069 | 719 ngx_os_environ = environ; |
720 | |
452 | 721 return NGX_OK; |
722 } | |
723 | |
724 | |
499 | 725 static void * |
726 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
|
727 { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
728 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
|
729 |
501 | 730 ccf = ngx_pcalloc(cycle->pool, sizeof(ngx_core_conf_t)); |
731 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
|
732 return NULL; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
733 } |
479 | 734 |
735 /* | |
736 * set by pcalloc() | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
737 * |
479 | 738 * ccf->pid = NULL; |
543 | 739 * ccf->oldpid = NULL; |
479 | 740 * ccf->priority = 0; |
577 | 741 * ccf->cpu_affinity_n = 0; |
742 * 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
|
743 */ |
479 | 744 |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
745 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
|
746 ccf->master = NGX_CONF_UNSET; |
563 | 747 ccf->timer_resolution = NGX_CONF_UNSET_MSEC; |
748 | |
300
502b03d9d2a3
nginx-0.0.3-2004-03-31-00:31:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
749 ccf->worker_processes = NGX_CONF_UNSET; |
461 | 750 ccf->debug_points = NGX_CONF_UNSET; |
543 | 751 |
752 ccf->rlimit_nofile = NGX_CONF_UNSET; | |
949
d1d8cde9aab9
worker_rlimit_core supports size in K, M, and G
Igor Sysoev <igor@sysoev.ru>
parents:
947
diff
changeset
|
753 ccf->rlimit_core = NGX_CONF_UNSET_SIZE; |
543 | 754 ccf->rlimit_sigpending = NGX_CONF_UNSET; |
755 | |
517 | 756 ccf->user = (ngx_uid_t) NGX_CONF_UNSET_UINT; |
757 ccf->group = (ngx_gid_t) NGX_CONF_UNSET_UINT; | |
543 | 758 |
376
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
759 #if (NGX_THREADS) |
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
760 ccf->worker_threads = NGX_CONF_UNSET; |
461 | 761 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
|
762 #endif |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
763 |
1069 | 764 if (ngx_array_init(&ccf->env, cycle->pool, 1, sizeof(ngx_str_t)) |
765 != NGX_OK) | |
766 { | |
767 return NULL; | |
768 } | |
769 | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
770 return ccf; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
771 } |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
772 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
773 |
499 | 774 static char * |
775 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
|
776 { |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
777 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
|
778 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
779 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
|
780 ngx_conf_init_value(ccf->master, 1); |
563 | 781 ngx_conf_init_msec_value(ccf->timer_resolution, 0); |
782 | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
783 ngx_conf_init_value(ccf->worker_processes, 1); |
461 | 784 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
|
785 |
577 | 786 #if (NGX_HAVE_SCHED_SETAFFINITY) |
787 | |
788 if (ccf->cpu_affinity_n | |
789 && ccf->cpu_affinity_n != 1 | |
790 && ccf->cpu_affinity_n != (ngx_uint_t) ccf->worker_processes) | |
791 { | |
792 ngx_log_error(NGX_LOG_WARN, cycle->log, 0, | |
793 "number of the \"worker_processes\" is not equal to " | |
794 "the number of the \"worker_cpu_affinity\" mask, " | |
795 "using last mask for remaining worker processes"); | |
796 } | |
797 | |
798 #endif | |
799 | |
376
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
800 #if (NGX_THREADS) |
577 | 801 |
376
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
802 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
|
803 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
|
804 ngx_conf_init_size_value(ccf->thread_stack_size, 2 * 1024 * 1024); |
577 | 805 |
376
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
806 #endif |
d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
366
diff
changeset
|
807 |
461 | 808 #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
|
809 |
517 | 810 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
|
811 struct group *grp; |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1694
diff
changeset
|
812 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
|
813 |
1288 | 814 ngx_set_errno(0); |
455 | 815 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
|
816 if (pwd == NULL) { |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
817 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
455 | 818 "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
|
819 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
|
820 } |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
821 |
473 | 822 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
|
823 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
|
824 |
1288 | 825 ngx_set_errno(0); |
455 | 826 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
|
827 if (grp == NULL) { |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
828 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
455 | 829 "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
|
830 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
|
831 } |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
832 |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
833 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
|
834 } |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
217
diff
changeset
|
835 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
836 if (ccf->pid.len == 0) { |
337
4feff829a849
nginx-0.0.3-2004-05-19-00:28:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
326
diff
changeset
|
837 ccf->pid.len = sizeof(NGX_PID_PATH) - 1; |
452 | 838 ccf->pid.data = (u_char *) NGX_PID_PATH; |
440
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
839 } |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
840 |
1352 | 841 if (ngx_conf_full_name(cycle, &ccf->pid, 0) == NGX_ERROR) { |
440
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
842 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
|
843 } |
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
844 |
543 | 845 ccf->oldpid.len = ccf->pid.len + sizeof(NGX_OLDPID_EXT); |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
846 |
2049 | 847 ccf->oldpid.data = ngx_pnalloc(cycle->pool, ccf->oldpid.len); |
543 | 848 if (ccf->oldpid.data == NULL) { |
440
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
849 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
|
850 } |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
851 |
543 | 852 ngx_memcpy(ngx_cpymem(ccf->oldpid.data, ccf->pid.data, ccf->pid.len), |
853 NGX_OLDPID_EXT, sizeof(NGX_OLDPID_EXT)); | |
440
f390d1775430
nginx-0.1.0-2004-09-27-20:03:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
854 |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
855 |
611 | 856 if (ccf->lock_file.len == 0) { |
857 ccf->lock_file.len = sizeof(NGX_LOCK_PATH) - 1; | |
858 ccf->lock_file.data = (u_char *) NGX_LOCK_PATH; | |
859 } | |
860 | |
1352 | 861 if (ngx_conf_full_name(cycle, &ccf->lock_file, 0) == NGX_ERROR) { |
611 | 862 return NGX_CONF_ERROR; |
863 } | |
864 | |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1694
diff
changeset
|
865 { |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1694
diff
changeset
|
866 ngx_str_t lock_file; |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1694
diff
changeset
|
867 |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
868 lock_file = cycle->old_cycle->lock_file; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
869 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
870 if (lock_file.len) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
871 lock_file.len--; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
872 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
873 if (ccf->lock_file.len != lock_file.len |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
874 || 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
|
875 != 0) |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
876 { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
877 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
878 "\"lock_file\" could not be changed, ignored"); |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
879 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
880 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
881 cycle->lock_file.len = lock_file.len + 1; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
882 lock_file.len += sizeof(".accept"); |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
883 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
884 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
|
885 if (cycle->lock_file.data == NULL) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
886 return NGX_CONF_ERROR; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
887 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
888 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
889 } else { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
890 cycle->lock_file.len = ccf->lock_file.len + 1; |
2049 | 891 cycle->lock_file.data = ngx_pnalloc(cycle->pool, |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
892 ccf->lock_file.len + sizeof(".accept")); |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
893 if (cycle->lock_file.data == NULL) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
894 return NGX_CONF_ERROR; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
895 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
896 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
897 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
|
898 ccf->lock_file.len), |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
899 ".accept", sizeof(".accept")); |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
900 } |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1694
diff
changeset
|
901 } |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
796
diff
changeset
|
902 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
903 #endif |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
904 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
905 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
|
906 } |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
907 |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
908 |
499 | 909 static char * |
910 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
|
911 { |
461 | 912 #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
|
913 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
914 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
|
915 "\"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
|
916 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
917 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
|
918 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
919 #else |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
920 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
921 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
|
922 |
455 | 923 char *group; |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
924 struct passwd *pwd; |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
925 struct group *grp; |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
926 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
|
927 |
517 | 928 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
|
929 return "is duplicate"; |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
930 } |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
931 |
455 | 932 if (geteuid() != 0) { |
933 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
934 "the \"user\" directive makes sense only " | |
935 "if the master process runs " | |
936 "with super-user privileges, ignored"); | |
937 return NGX_CONF_OK; | |
938 } | |
939 | |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
940 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
|
941 |
473 | 942 ccf->username = (char *) value[1].data; |
943 | |
1288 | 944 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
|
945 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
|
946 if (pwd == NULL) { |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
947 ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno, |
452 | 948 "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
|
949 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
|
950 } |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
951 |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
952 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
|
953 |
455 | 954 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
|
955 |
1288 | 956 ngx_set_errno(0); |
455 | 957 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
|
958 if (grp == NULL) { |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
959 ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno, |
455 | 960 "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
|
961 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
|
962 } |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
963 |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
964 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
|
965 |
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
966 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
|
967 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
270
diff
changeset
|
968 #endif |
234
cd71b95716b4
nginx-0.0.1-2004-01-20-23:40:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
231
diff
changeset
|
969 } |
473 | 970 |
971 | |
499 | 972 static char * |
1069 | 973 ngx_set_env(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
974 { | |
975 ngx_core_conf_t *ccf = conf; | |
976 | |
977 ngx_str_t *value, *var; | |
978 ngx_uint_t i; | |
979 | |
980 var = ngx_array_push(&ccf->env); | |
981 if (var == NULL) { | |
982 return NGX_CONF_ERROR; | |
983 } | |
984 | |
985 value = cf->args->elts; | |
986 *var = value[1]; | |
987 | |
988 for (i = 0; i < value[1].len; i++) { | |
989 | |
990 if (value[1].data[i] == '=') { | |
991 | |
992 var->len = i; | |
993 | |
994 return NGX_CONF_OK; | |
995 } | |
996 } | |
997 | |
998 return NGX_CONF_OK; | |
999 } | |
1000 | |
1001 | |
1002 static char * | |
499 | 1003 ngx_set_priority(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
473 | 1004 { |
1005 ngx_core_conf_t *ccf = conf; | |
1006 | |
1007 ngx_str_t *value; | |
1008 ngx_uint_t n, minus; | |
1009 | |
1010 if (ccf->priority != 0) { | |
1011 return "is duplicate"; | |
1012 } | |
1013 | |
1014 value = cf->args->elts; | |
1015 | |
1016 if (value[1].data[0] == '-') { | |
1017 n = 1; | |
1018 minus = 1; | |
1019 | |
1020 } else if (value[1].data[0] == '+') { | |
1021 n = 1; | |
1022 minus = 0; | |
1023 | |
1024 } else { | |
1025 n = 0; | |
1026 minus = 0; | |
1027 } | |
1028 | |
1029 ccf->priority = ngx_atoi(&value[1].data[n], value[1].len - n); | |
1030 if (ccf->priority == NGX_ERROR) { | |
1031 return "invalid number"; | |
1032 } | |
1033 | |
1034 if (minus) { | |
1035 ccf->priority = -ccf->priority; | |
1036 } | |
1037 | |
1038 return NGX_CONF_OK; | |
1039 } | |
577 | 1040 |
1041 | |
1042 static char * | |
1043 ngx_set_cpu_affinity(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
1044 { | |
1045 #if (NGX_HAVE_SCHED_SETAFFINITY) | |
1046 ngx_core_conf_t *ccf = conf; | |
1047 | |
1048 u_char ch; | |
1049 u_long *mask; | |
1050 ngx_str_t *value; | |
1051 ngx_uint_t i, n; | |
1052 | |
1053 if (ccf->cpu_affinity) { | |
1054 return "is duplicate"; | |
1055 } | |
1056 | |
1057 mask = ngx_palloc(cf->pool, (cf->args->nelts - 1) * sizeof(long)); | |
1058 if (mask == NULL) { | |
1059 return NGX_CONF_ERROR; | |
1060 } | |
1061 | |
1062 ccf->cpu_affinity_n = cf->args->nelts - 1; | |
1063 ccf->cpu_affinity = mask; | |
1064 | |
1065 value = cf->args->elts; | |
1066 | |
1067 for (n = 1; n < cf->args->nelts; n++) { | |
1068 | |
1069 if (value[n].len > 32) { | |
1070 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1071 "\"worker_cpu_affinity\" supports up to 32 CPU only"); | |
1072 return NGX_CONF_ERROR; | |
1073 } | |
1074 | |
1075 mask[n - 1] = 0; | |
1076 | |
1077 for (i = 0; i < value[n].len; i++) { | |
1078 | |
1079 ch = value[n].data[i]; | |
1080 | |
1081 if (ch == ' ') { | |
1082 continue; | |
1083 } | |
1084 | |
1085 mask[n - 1] <<= 1; | |
1086 | |
1087 if (ch == '0') { | |
1088 continue; | |
1089 } | |
1090 | |
1091 if (ch == '1') { | |
1092 mask[n - 1] |= 1; | |
1093 continue; | |
1094 } | |
1095 | |
1096 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1097 "invalid character \"%c\" in \"worker_cpu_affinity\"", | |
1098 ch); | |
2024 | 1099 return NGX_CONF_ERROR; |
577 | 1100 } |
1101 } | |
1102 | |
1103 #else | |
1104 | |
1105 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | |
1106 "\"worker_cpu_affinity\" is not supported " | |
1107 "on this platform, ignored"); | |
1108 #endif | |
1109 | |
1110 return NGX_CONF_OK; | |
1111 } | |
1112 | |
1113 | |
1114 u_long | |
1115 ngx_get_cpu_affinity(ngx_uint_t n) | |
1116 { | |
1117 ngx_core_conf_t *ccf; | |
1118 | |
1119 ccf = (ngx_core_conf_t *) ngx_get_conf(ngx_cycle->conf_ctx, | |
1120 ngx_core_module); | |
1121 | |
1122 if (ccf->cpu_affinity == NULL) { | |
1123 return 0; | |
1124 } | |
1125 | |
1126 if (ccf->cpu_affinity_n > n) { | |
1127 return ccf->cpu_affinity[n]; | |
1128 } | |
1129 | |
1130 return ccf->cpu_affinity[ccf->cpu_affinity_n - 1]; | |
1131 } |