Mercurial > hg > nginx
comparison src/os/unix/ngx_process_cycle.c @ 477:ad1e9ebf93bb release-0.1.13
nginx-0.1.13-RELEASE import
*) Feature: the server_names_hash and server_names_hash_threshold
directives.
*) Bugfix: the *.domain.tld names in the "server_name" directive did
not work.
*) Bugfix: the %request_length log parameter logged the incorrect
length.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 21 Dec 2004 12:30:30 +0000 |
parents | 8e8f3af115b5 |
children | c52408583801 |
comparison
equal
deleted
inserted
replaced
476:7e8b84ab09e9 | 477:ad1e9ebf93bb |
---|---|
33 sig_atomic_t ngx_reap; | 33 sig_atomic_t ngx_reap; |
34 sig_atomic_t ngx_timer; | 34 sig_atomic_t ngx_timer; |
35 sig_atomic_t ngx_sigio; | 35 sig_atomic_t ngx_sigio; |
36 sig_atomic_t ngx_terminate; | 36 sig_atomic_t ngx_terminate; |
37 sig_atomic_t ngx_quit; | 37 sig_atomic_t ngx_quit; |
38 sig_atomic_t ngx_debug_quit; | |
38 ngx_uint_t ngx_exiting; | 39 ngx_uint_t ngx_exiting; |
39 sig_atomic_t ngx_reconfigure; | 40 sig_atomic_t ngx_reconfigure; |
40 sig_atomic_t ngx_reopen; | 41 sig_atomic_t ngx_reopen; |
41 | 42 |
42 sig_atomic_t ngx_change_binary; | 43 sig_atomic_t ngx_change_binary; |
192 | 193 |
193 if (ngx_reconfigure) { | 194 if (ngx_reconfigure) { |
194 ngx_reconfigure = 0; | 195 ngx_reconfigure = 0; |
195 | 196 |
196 if (ngx_new_binary) { | 197 if (ngx_new_binary) { |
197 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "start new workers"); | |
198 | |
199 ngx_start_worker_processes(cycle, ccf->worker_processes, | 198 ngx_start_worker_processes(cycle, ccf->worker_processes, |
200 NGX_PROCESS_RESPAWN); | 199 NGX_PROCESS_RESPAWN); |
201 ngx_start_garbage_collector(cycle, NGX_PROCESS_RESPAWN); | 200 ngx_start_garbage_collector(cycle, NGX_PROCESS_RESPAWN); |
202 ngx_noaccepting = 0; | 201 ngx_noaccepting = 0; |
203 | 202 |
204 continue; | 203 continue; |
205 } | 204 } |
206 | 205 |
207 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reconfiguring"); | 206 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reconfiguring"); |
208 | 207 |
209 cycle = ngx_init_cycle(cycle); | 208 cycle = ngx_init_cycle(cycle); |
210 if (cycle == NULL) { | 209 if (cycle == NULL) { |
211 cycle = (ngx_cycle_t *) ngx_cycle; | 210 cycle = (ngx_cycle_t *) ngx_cycle; |
212 continue; | 211 continue; |
231 live = 1; | 230 live = 1; |
232 } | 231 } |
233 | 232 |
234 if (ngx_reopen) { | 233 if (ngx_reopen) { |
235 ngx_reopen = 0; | 234 ngx_reopen = 0; |
236 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopening logs"); | 235 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs"); |
237 ngx_reopen_files(cycle, ccf->user); | 236 ngx_reopen_files(cycle, ccf->user); |
238 ngx_signal_worker_processes(cycle, | 237 ngx_signal_worker_processes(cycle, |
239 ngx_signal_value(NGX_REOPEN_SIGNAL)); | 238 ngx_signal_value(NGX_REOPEN_SIGNAL)); |
240 } | 239 } |
241 | 240 |
242 if (ngx_change_binary) { | 241 if (ngx_change_binary) { |
243 ngx_change_binary = 0; | 242 ngx_change_binary = 0; |
244 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "changing binary"); | 243 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "changing binary"); |
245 ngx_new_binary = ngx_exec_new_binary(cycle, ngx_argv); | 244 ngx_new_binary = ngx_exec_new_binary(cycle, ngx_argv); |
246 } | 245 } |
247 | 246 |
248 if (ngx_noaccept) { | 247 if (ngx_noaccept) { |
249 ngx_noaccept = 0; | 248 ngx_noaccept = 0; |
279 ngx_master_exit(cycle); | 278 ngx_master_exit(cycle); |
280 } | 279 } |
281 | 280 |
282 if (ngx_reconfigure) { | 281 if (ngx_reconfigure) { |
283 ngx_reconfigure = 0; | 282 ngx_reconfigure = 0; |
284 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reconfiguring"); | 283 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reconfiguring"); |
285 | 284 |
286 cycle = ngx_init_cycle(cycle); | 285 cycle = ngx_init_cycle(cycle); |
287 if (cycle == NULL) { | 286 if (cycle == NULL) { |
288 cycle = (ngx_cycle_t *) ngx_cycle; | 287 cycle = (ngx_cycle_t *) ngx_cycle; |
289 continue; | 288 continue; |
292 ngx_cycle = cycle; | 291 ngx_cycle = cycle; |
293 } | 292 } |
294 | 293 |
295 if (ngx_reopen) { | 294 if (ngx_reopen) { |
296 ngx_reopen = 0; | 295 ngx_reopen = 0; |
297 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopening logs"); | 296 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs"); |
298 ngx_reopen_files(cycle, (ngx_uid_t) -1); | 297 ngx_reopen_files(cycle, (ngx_uid_t) -1); |
299 } | 298 } |
300 } | 299 } |
301 } | 300 } |
302 | 301 |
306 { | 305 { |
307 ngx_int_t i; | 306 ngx_int_t i; |
308 ngx_channel_t ch; | 307 ngx_channel_t ch; |
309 struct itimerval itv; | 308 struct itimerval itv; |
310 | 309 |
311 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "start worker processes"); | 310 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start worker processes"); |
312 | 311 |
313 ch.command = NGX_CMD_OPEN_CHANNEL; | 312 ch.command = NGX_CMD_OPEN_CHANNEL; |
314 | 313 |
315 while (n--) { | 314 while (n--) { |
316 ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL, | 315 ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL, |
365 ngx_int_t i; | 364 ngx_int_t i; |
366 ngx_channel_t ch; | 365 ngx_channel_t ch; |
367 | 366 |
368 return; | 367 return; |
369 | 368 |
370 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "start garbage collector"); | 369 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start garbage collector"); |
371 | 370 |
372 ch.command = NGX_CMD_OPEN_CHANNEL; | 371 ch.command = NGX_CMD_OPEN_CHANNEL; |
373 | 372 |
374 ngx_spawn_process(cycle, ngx_garbage_collector_cycle, NULL, | 373 ngx_spawn_process(cycle, ngx_garbage_collector_cycle, NULL, |
375 "garbage collector", type); | 374 "garbage collector", type); |
622 | 621 |
623 static void ngx_master_exit(ngx_cycle_t *cycle) | 622 static void ngx_master_exit(ngx_cycle_t *cycle) |
624 { | 623 { |
625 ngx_delete_pidfile(cycle); | 624 ngx_delete_pidfile(cycle); |
626 | 625 |
627 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exit"); | 626 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exit"); |
628 | 627 |
629 ngx_destroy_pool(cycle->pool); | 628 ngx_destroy_pool(cycle->pool); |
630 | 629 |
631 exit(0); | 630 exit(0); |
632 } | 631 } |
688 | 687 |
689 for ( ;; ) { | 688 for ( ;; ) { |
690 if (ngx_exiting | 689 if (ngx_exiting |
691 && ngx_event_timer_rbtree == &ngx_event_timer_sentinel) | 690 && ngx_event_timer_rbtree == &ngx_event_timer_sentinel) |
692 { | 691 { |
693 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting"); | 692 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting"); |
694 | 693 |
695 | 694 |
696 #if (NGX_THREADS) | 695 #if (NGX_THREADS) |
697 ngx_terminate = 1; | 696 ngx_terminate = 1; |
698 | 697 |
699 ngx_wakeup_worker_threads(cycle); | 698 ngx_wakeup_worker_threads(cycle); |
700 #endif | 699 #endif |
700 | |
701 if (ngx_debug_quit) { | |
702 ngx_debug_point(); | |
703 } | |
701 | 704 |
702 /* | 705 /* |
703 * we do not destroy cycle->pool here because a signal handler | 706 * we do not destroy cycle->pool here because a signal handler |
704 * that uses cycle->log can be called at this point | 707 * that uses cycle->log can be called at this point |
705 */ | 708 */ |
709 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle"); | 712 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle"); |
710 | 713 |
711 ngx_process_events(cycle); | 714 ngx_process_events(cycle); |
712 | 715 |
713 if (ngx_terminate) { | 716 if (ngx_terminate) { |
714 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting"); | 717 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting"); |
715 | 718 |
716 #if (NGX_THREADS) | 719 #if (NGX_THREADS) |
717 ngx_wakeup_worker_threads(cycle); | 720 ngx_wakeup_worker_threads(cycle); |
718 #endif | 721 #endif |
719 | 722 |
724 exit(0); | 727 exit(0); |
725 } | 728 } |
726 | 729 |
727 if (ngx_quit) { | 730 if (ngx_quit) { |
728 ngx_quit = 0; | 731 ngx_quit = 0; |
729 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, | 732 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, |
730 "gracefully shutting down"); | 733 "gracefully shutting down"); |
731 ngx_setproctitle("worker process is shutting down"); | 734 ngx_setproctitle("worker process is shutting down"); |
732 | 735 |
733 if (!ngx_exiting) { | 736 if (!ngx_exiting) { |
734 ngx_close_listening_sockets(cycle); | 737 ngx_close_listening_sockets(cycle); |
736 } | 739 } |
737 } | 740 } |
738 | 741 |
739 if (ngx_reopen) { | 742 if (ngx_reopen) { |
740 ngx_reopen = 0; | 743 ngx_reopen = 0; |
741 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopen logs"); | 744 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs"); |
742 ngx_reopen_files(cycle, -1); | 745 ngx_reopen_files(cycle, -1); |
743 } | 746 } |
744 } | 747 } |
745 } | 748 } |
746 | 749 |
1094 #endif | 1097 #endif |
1095 | 1098 |
1096 for ( ;; ) { | 1099 for ( ;; ) { |
1097 | 1100 |
1098 if (ngx_terminate || ngx_quit) { | 1101 if (ngx_terminate || ngx_quit) { |
1099 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting"); | 1102 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting"); |
1100 exit(0); | 1103 exit(0); |
1101 } | 1104 } |
1102 | 1105 |
1103 if (ngx_reopen) { | 1106 if (ngx_reopen) { |
1104 ngx_reopen = 0; | 1107 ngx_reopen = 0; |
1105 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopen logs"); | 1108 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs"); |
1106 ngx_reopen_files(cycle, -1); | 1109 ngx_reopen_files(cycle, -1); |
1107 } | 1110 } |
1108 | 1111 |
1109 path = cycle->pathes.elts; | 1112 path = cycle->pathes.elts; |
1110 for (i = 0; i < cycle->pathes.nelts; i++) { | 1113 for (i = 0; i < cycle->pathes.nelts; i++) { |