comparison src/os/unix/ngx_process_cycle.c @ 326:8733703a37f3

nginx-0.0.3-2004-04-26-00:13:21 import
author Igor Sysoev <igor@sysoev.ru>
date Sun, 25 Apr 2004 20:13:21 +0000
parents ba876b26b76d
children e0f3f238db09
comparison
equal deleted inserted replaced
325:7c3323909107 326:8733703a37f3
14 #if (NGX_THREADS) 14 #if (NGX_THREADS)
15 static int ngx_worker_thread_cycle(void *data); 15 static int ngx_worker_thread_cycle(void *data);
16 #endif 16 #endif
17 17
18 18
19 ngx_int_t ngx_process; 19 ngx_uint_t ngx_process;
20 ngx_pid_t ngx_pid; 20 ngx_pid_t ngx_pid;
21 ngx_int_t ngx_threaded; 21 ngx_uint_t ngx_threaded;
22 22
23 sig_atomic_t ngx_reap; 23 sig_atomic_t ngx_reap;
24 sig_atomic_t ngx_timer; 24 sig_atomic_t ngx_timer;
25 sig_atomic_t ngx_terminate; 25 sig_atomic_t ngx_terminate;
26 sig_atomic_t ngx_quit; 26 sig_atomic_t ngx_quit;
27 ngx_uint_t ngx_exiting;
27 sig_atomic_t ngx_reconfigure; 28 sig_atomic_t ngx_reconfigure;
28 sig_atomic_t ngx_reopen; 29 sig_atomic_t ngx_reopen;
29 30
30 sig_atomic_t ngx_change_binary; 31 sig_atomic_t ngx_change_binary;
31 ngx_pid_t ngx_new_binary; 32 ngx_pid_t ngx_new_binary;
32 ngx_int_t ngx_inherited; 33 ngx_uint_t ngx_inherited;
33 34
34 sig_atomic_t ngx_noaccept; 35 sig_atomic_t ngx_noaccept;
35 ngx_uint_t ngx_noaccepting; 36 ngx_uint_t ngx_noaccepting;
36 ngx_uint_t ngx_restart; 37 ngx_uint_t ngx_restart;
37 38
38 39
40 u_char master_process[] = "master process";
41
42
39 void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx) 43 void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
40 { 44 {
45 char *title, *p;
46 size_t size;
47 ngx_int_t n;
41 ngx_uint_t i; 48 ngx_uint_t i;
42 sigset_t set; 49 sigset_t set;
43 struct timeval tv; 50 struct timeval tv;
44 struct itimerval itv; 51 struct itimerval itv;
45 ngx_uint_t live; 52 ngx_uint_t live;
62 "sigprocmask() failed"); 69 "sigprocmask() failed");
63 } 70 }
64 71
65 sigemptyset(&set); 72 sigemptyset(&set);
66 73
67 ngx_setproctitle("master process"); 74
75 size = sizeof(master_process);
76
77 for (n = 0; n < ctx->argc; n++) {
78 size += ngx_strlen(ctx->argv[n]) + 1;
79 }
80
81 title = ngx_palloc(cycle->pool, size);
82
83 p = ngx_cpymem(title, master_process, sizeof(master_process) - 1);
84 for (n = 0; n < ctx->argc; n++) {
85 *p++ = ' ';
86 p = ngx_cpystrn(p, ctx->argv[n], size);
87 }
88
89 ngx_setproctitle(title);
90
68 91
69 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); 92 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
70 93
71 ngx_start_worker_processes(cycle, ccf->worker_processes, 94 ngx_start_worker_processes(cycle, ccf->worker_processes,
72 NGX_PROCESS_RESPAWN); 95 NGX_PROCESS_RESPAWN);
384 407
385 408
386 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) 409 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
387 { 410 {
388 sigset_t set; 411 sigset_t set;
389 ngx_uint_t i, exiting; 412 ngx_uint_t i;
390 ngx_listening_t *ls; 413 ngx_listening_t *ls;
391 ngx_core_conf_t *ccf; 414 ngx_core_conf_t *ccf;
392 #if (NGX_THREADS) 415 #if (NGX_THREADS)
393 ngx_tid_t tid; 416 ngx_tid_t tid;
394 #endif 417 #endif
472 } 495 }
473 } 496 }
474 497
475 #endif 498 #endif
476 499
477 exiting = 0;
478
479 for ( ;; ) { 500 for ( ;; ) {
480 if (exiting && ngx_event_timer_rbtree == &ngx_event_timer_sentinel) { 501 if (ngx_exiting
502 && ngx_event_timer_rbtree == &ngx_event_timer_sentinel)
503 {
481 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting"); 504 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting");
482 ngx_destroy_pool(cycle->pool); 505 ngx_destroy_pool(cycle->pool);
483 exit(0); 506 exit(0);
484 } 507 }
485 508
497 ngx_quit = 0; 520 ngx_quit = 0;
498 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, 521 ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
499 "gracefully shutting down"); 522 "gracefully shutting down");
500 ngx_setproctitle("worker process is shutting down"); 523 ngx_setproctitle("worker process is shutting down");
501 524
502 if (!exiting) { 525 if (!ngx_exiting) {
503 ngx_close_listening_sockets(cycle); 526 ngx_close_listening_sockets(cycle);
504 exiting = 1; 527 ngx_exiting = 1;
505 } 528 }
506 } 529 }
507 530
508 if (ngx_reopen) { 531 if (ngx_reopen) {
509 ngx_reopen = 0; 532 ngx_reopen = 0;