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