Mercurial > hg > nginx-vendor-0-8
comparison src/core/nginx.c @ 480:549994537f15 NGINX_0_7_52
nginx 0.7.52
*) Feature: the first native Windows binary release.
*) Bugfix: in processing HEAD method while caching.
*) Bugfix: in processing the "If-Modified-Since", "If-Range", etc.
client request header lines while caching.
*) Bugfix: now the "Set-Cookie" and "P3P" header lines are hidden in
cacheable responses.
*) Bugfix: if nginx was built with the ngx_http_perl_module and with a
perl which supports threads, then during a master process exit the
message "panic: MUTEX_LOCK" might be issued.
*) Bugfix: nginx could not be built --without-http-cache; the bug had
appeared in 0.7.48.
*) Bugfix: nginx could not be built on platforms different from i386,
amd64, sparc, and ppc; the bug had appeared in 0.7.42.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 20 Apr 2009 00:00:00 +0400 |
parents | a8424ffa495c |
children | 392c16f2d858 |
comparison
equal
deleted
inserted
replaced
479:eb4fdebda673 | 480:549994537f15 |
---|---|
178 NULL, /* exit master */ | 178 NULL, /* exit master */ |
179 NGX_MODULE_V1_PADDING | 179 NGX_MODULE_V1_PADDING |
180 }; | 180 }; |
181 | 181 |
182 | 182 |
183 ngx_uint_t ngx_max_module; | 183 ngx_uint_t ngx_max_module; |
184 | 184 |
185 static ngx_uint_t ngx_show_version; | 185 static ngx_uint_t ngx_show_version; |
186 static ngx_uint_t ngx_show_configure; | 186 static ngx_uint_t ngx_show_configure; |
187 #if (NGX_WIN32) | |
188 static char *ngx_signal; | |
189 #endif | |
190 | |
187 | 191 |
188 static char **ngx_os_environ; | 192 static char **ngx_os_environ; |
189 | 193 |
190 | 194 |
191 int ngx_cdecl | 195 int ngx_cdecl |
192 main(int argc, char *const *argv) | 196 main(int argc, char *const *argv) |
193 { | 197 { |
194 char *p; | |
195 ssize_t n; | |
196 ngx_int_t i; | 198 ngx_int_t i; |
197 ngx_log_t *log; | 199 ngx_log_t *log; |
198 ngx_cycle_t *cycle, init_cycle; | 200 ngx_cycle_t *cycle, init_cycle; |
199 ngx_core_conf_t *ccf; | 201 ngx_core_conf_t *ccf; |
200 | 202 |
241 return 1; | 243 return 1; |
242 } | 244 } |
243 | 245 |
244 if (ngx_show_version) { | 246 if (ngx_show_version) { |
245 | 247 |
246 p = "nginx version: " NGINX_VER CRLF; | 248 ngx_log_stderr("nginx version: " NGINX_VER); |
247 n = sizeof("nginx version: " NGINX_VER CRLF) - 1; | |
248 | |
249 if (ngx_write_fd(ngx_stderr_fileno, p, n) != n) { | |
250 return 1; | |
251 } | |
252 | 249 |
253 if (ngx_show_configure) { | 250 if (ngx_show_configure) { |
254 #ifdef NGX_COMPILER | 251 #ifdef NGX_COMPILER |
255 p = "built by " NGX_COMPILER CRLF; | 252 ngx_log_stderr("built by " NGX_COMPILER); |
256 n = sizeof("built by " NGX_COMPILER CRLF) - 1; | 253 #endif |
257 | 254 |
258 if (ngx_write_fd(ngx_stderr_fileno, p, n) != n) { | 255 ngx_log_stderr("configure arguments: " NGX_CONFIGURE); |
259 return 1; | |
260 } | |
261 #endif | |
262 | |
263 p = "configure arguments: " NGX_CONFIGURE CRLF; | |
264 n = sizeof("configure arguments :" NGX_CONFIGURE CRLF) - 1; | |
265 | |
266 if (ngx_write_fd(ngx_stderr_fileno, p, n) != n) { | |
267 return 1; | |
268 } | |
269 } | 256 } |
270 | 257 |
271 if (!ngx_test_config) { | 258 if (!ngx_test_config) { |
272 return 0; | 259 return 0; |
273 } | 260 } |
299 } | 286 } |
300 | 287 |
301 cycle = ngx_init_cycle(&init_cycle); | 288 cycle = ngx_init_cycle(&init_cycle); |
302 if (cycle == NULL) { | 289 if (cycle == NULL) { |
303 if (ngx_test_config) { | 290 if (ngx_test_config) { |
304 ngx_log_error(NGX_LOG_EMERG, log, 0, | 291 ngx_log_stderr("the configuration file %s test failed", |
305 "the configuration file %s test failed", | 292 init_cycle.conf_file.data); |
306 init_cycle.conf_file.data); | |
307 } | 293 } |
308 | 294 |
309 return 1; | 295 return 1; |
310 } | 296 } |
311 | 297 |
312 if (ngx_test_config) { | 298 if (ngx_test_config) { |
313 ngx_log_error(NGX_LOG_INFO, log, 0, | 299 ngx_log_stderr("the configuration file %s was tested successfully", |
314 "the configuration file %s was tested successfully", | 300 cycle->conf_file.data); |
315 cycle->conf_file.data); | |
316 return 0; | 301 return 0; |
317 } | 302 } |
318 | 303 |
319 ngx_os_status(cycle->log); | 304 ngx_os_status(cycle->log); |
320 | 305 |
321 ngx_cycle = cycle; | 306 ngx_cycle = cycle; |
322 | 307 |
323 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); | 308 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
324 | 309 |
325 ngx_process = ccf->master ? NGX_PROCESS_MASTER : NGX_PROCESS_SINGLE; | 310 if (ccf->master && ngx_process == NGX_PROCESS_SINGLE) { |
311 ngx_process = NGX_PROCESS_MASTER; | |
312 } | |
326 | 313 |
327 #if (NGX_WIN32) | 314 #if (NGX_WIN32) |
328 | 315 |
329 #if 0 | 316 if (ngx_signal) { |
330 | 317 return ngx_signal_process(cycle, ngx_signal); |
331 TODO: | 318 } |
332 | |
333 if (ccf->run_as_service) { | |
334 if (ngx_service(cycle->log) != NGX_OK) { | |
335 return 1; | |
336 } | |
337 | |
338 return 0; | |
339 } | |
340 #endif | |
341 | 319 |
342 #else | 320 #else |
343 | 321 |
344 if (ngx_init_signals(cycle->log) != NGX_OK) { | 322 if (ngx_init_signals(cycle->log) != NGX_OK) { |
345 return 1; | 323 return 1; |
351 } | 329 } |
352 | 330 |
353 ngx_daemonized = 1; | 331 ngx_daemonized = 1; |
354 } | 332 } |
355 | 333 |
334 #endif | |
335 | |
356 if (ngx_create_pidfile(&ccf->pid, cycle->log) != NGX_OK) { | 336 if (ngx_create_pidfile(&ccf->pid, cycle->log) != NGX_OK) { |
357 return 1; | 337 return 1; |
358 } | 338 } |
359 | 339 |
360 #endif | 340 if (ngx_process == NGX_PROCESS_SINGLE) { |
361 | 341 ngx_single_process_cycle(cycle); |
362 if (ngx_process == NGX_PROCESS_MASTER) { | 342 |
343 } else { | |
363 ngx_master_process_cycle(cycle); | 344 ngx_master_process_cycle(cycle); |
364 | |
365 } else { | |
366 ngx_single_process_cycle(cycle); | |
367 } | 345 } |
368 | 346 |
369 return 0; | 347 return 0; |
370 } | 348 } |
371 | 349 |
662 | 640 |
663 cycle->conf_param.data = (u_char *) argv[++i]; | 641 cycle->conf_param.data = (u_char *) argv[++i]; |
664 cycle->conf_param.len = ngx_strlen(cycle->conf_param.data); | 642 cycle->conf_param.len = ngx_strlen(cycle->conf_param.data); |
665 break; | 643 break; |
666 | 644 |
645 #if (NGX_WIN32) | |
646 case 's': | |
647 if (argv[++i] == NULL) { | |
648 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, | |
649 "the option \"-s\" requires parameter"); | |
650 return NGX_ERROR; | |
651 } | |
652 | |
653 if (ngx_strcmp(argv[i], "stop") == 0 | |
654 || ngx_strcmp(argv[i], "quit") == 0 | |
655 || ngx_strcmp(argv[i], "reopen") == 0 | |
656 || ngx_strcmp(argv[i], "reload") == 0) | |
657 { | |
658 ngx_process = NGX_PROCESS_SIGNALLER; | |
659 ngx_signal = argv[i]; | |
660 break; | |
661 } | |
662 | |
663 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, | |
664 "invalid option: \"-s %s\"", argv[i]); | |
665 return NGX_ERROR; | |
666 #endif | |
667 | |
667 default: | 668 default: |
668 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, | 669 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
669 "invalid option: \"%s\"", argv[i]); | 670 "invalid option: \"%s\"", argv[i]); |
670 return NGX_ERROR; | 671 return NGX_ERROR; |
671 } | 672 } |
803 ngx_threads_n = ccf->worker_threads; | 804 ngx_threads_n = ccf->worker_threads; |
804 ngx_conf_init_size_value(ccf->thread_stack_size, 2 * 1024 * 1024); | 805 ngx_conf_init_size_value(ccf->thread_stack_size, 2 * 1024 * 1024); |
805 | 806 |
806 #endif | 807 #endif |
807 | 808 |
809 | |
810 if (ccf->pid.len == 0) { | |
811 ccf->pid.len = sizeof(NGX_PID_PATH) - 1; | |
812 ccf->pid.data = (u_char *) NGX_PID_PATH; | |
813 } | |
814 | |
815 if (ngx_conf_full_name(cycle, &ccf->pid, 0) != NGX_OK) { | |
816 return NGX_CONF_ERROR; | |
817 } | |
818 | |
819 ccf->oldpid.len = ccf->pid.len + sizeof(NGX_OLDPID_EXT); | |
820 | |
821 ccf->oldpid.data = ngx_pnalloc(cycle->pool, ccf->oldpid.len); | |
822 if (ccf->oldpid.data == NULL) { | |
823 return NGX_CONF_ERROR; | |
824 } | |
825 | |
826 ngx_memcpy(ngx_cpymem(ccf->oldpid.data, ccf->pid.data, ccf->pid.len), | |
827 NGX_OLDPID_EXT, sizeof(NGX_OLDPID_EXT)); | |
828 | |
829 | |
808 #if !(NGX_WIN32) | 830 #if !(NGX_WIN32) |
809 | 831 |
810 if (ccf->user == (uid_t) NGX_CONF_UNSET_UINT && geteuid() == 0) { | 832 if (ccf->user == (uid_t) NGX_CONF_UNSET_UINT && geteuid() == 0) { |
811 struct group *grp; | 833 struct group *grp; |
812 struct passwd *pwd; | 834 struct passwd *pwd; |
831 } | 853 } |
832 | 854 |
833 ccf->group = grp->gr_gid; | 855 ccf->group = grp->gr_gid; |
834 } | 856 } |
835 | 857 |
836 if (ccf->pid.len == 0) { | |
837 ccf->pid.len = sizeof(NGX_PID_PATH) - 1; | |
838 ccf->pid.data = (u_char *) NGX_PID_PATH; | |
839 } | |
840 | |
841 if (ngx_conf_full_name(cycle, &ccf->pid, 0) != NGX_OK) { | |
842 return NGX_CONF_ERROR; | |
843 } | |
844 | |
845 ccf->oldpid.len = ccf->pid.len + sizeof(NGX_OLDPID_EXT); | |
846 | |
847 ccf->oldpid.data = ngx_pnalloc(cycle->pool, ccf->oldpid.len); | |
848 if (ccf->oldpid.data == NULL) { | |
849 return NGX_CONF_ERROR; | |
850 } | |
851 | |
852 ngx_memcpy(ngx_cpymem(ccf->oldpid.data, ccf->pid.data, ccf->pid.len), | |
853 NGX_OLDPID_EXT, sizeof(NGX_OLDPID_EXT)); | |
854 | |
855 | 858 |
856 if (ccf->lock_file.len == 0) { | 859 if (ccf->lock_file.len == 0) { |
857 ccf->lock_file.len = sizeof(NGX_LOCK_PATH) - 1; | 860 ccf->lock_file.len = sizeof(NGX_LOCK_PATH) - 1; |
858 ccf->lock_file.data = (u_char *) NGX_LOCK_PATH; | 861 ccf->lock_file.data = (u_char *) NGX_LOCK_PATH; |
859 } | 862 } |