Mercurial > hg > nginx
annotate src/os/unix/ngx_process_cycle.c @ 7292:f9661f56c717
Allowed digits, '+', '-', and '.' in scheme names as per RFC 3986.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Thu, 24 May 2018 12:06:35 +0300 |
parents | 7f28b61c92f0 |
children | 7cbf6389194b |
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:
391
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:
391
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:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
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:
391
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
391
diff
changeset
|
6 |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_event.h> |
366
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
11 #include <ngx_channel.h> |
309
2e899477243a
nginx-0.0.3-2004-04-09-20:03:04 import
Igor Sysoev <igor@sysoev.ru>
parents:
305
diff
changeset
|
12 |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
14 static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, |
501 | 15 ngx_int_t type); |
3018 | 16 static void ngx_start_cache_manager_processes(ngx_cycle_t *cycle, |
17 ngx_uint_t respawn); | |
18 static void ngx_pass_open_channel(ngx_cycle_t *cycle, ngx_channel_t *ch); | |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
19 static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo); |
1565 | 20 static ngx_uint_t ngx_reap_children(ngx_cycle_t *cycle); |
573 | 21 static void ngx_master_process_exit(ngx_cycle_t *cycle); |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data); |
4912
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
23 static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker); |
573 | 24 static void ngx_worker_process_exit(ngx_cycle_t *cycle); |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
25 static void ngx_channel_handler(ngx_event_t *ev); |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
26 static void ngx_cache_manager_process_cycle(ngx_cycle_t *cycle, void *data); |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
27 static void ngx_cache_manager_process_handler(ngx_event_t *ev); |
3018 | 28 static void ngx_cache_loader_process_handler(ngx_event_t *ev); |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
29 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
30 |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
31 ngx_uint_t ngx_process; |
6151
b4cc553aafeb
Introduced worker number, ngx_worker.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6127
diff
changeset
|
32 ngx_uint_t ngx_worker; |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
33 ngx_pid_t ngx_pid; |
7162
8b84d60ef13d
Fixed "changing binary" when reaper is not init.
Ruslan Ermilov <ru@nginx.com>
parents:
6931
diff
changeset
|
34 ngx_pid_t ngx_parent; |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
35 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
36 sig_atomic_t ngx_reap; |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
37 sig_atomic_t ngx_sigio; |
3048
846d0e2fa483
twice termination delay only after SIGALRM, otherwise many separate SIGCHLD
Igor Sysoev <igor@sysoev.ru>
parents:
3047
diff
changeset
|
38 sig_atomic_t ngx_sigalrm; |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
39 sig_atomic_t ngx_terminate; |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
40 sig_atomic_t ngx_quit; |
477 | 41 sig_atomic_t ngx_debug_quit; |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
42 ngx_uint_t ngx_exiting; |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 sig_atomic_t ngx_reconfigure; |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
44 sig_atomic_t ngx_reopen; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
45 |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
46 sig_atomic_t ngx_change_binary; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
47 ngx_pid_t ngx_new_binary; |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
48 ngx_uint_t ngx_inherited; |
366
e411b1482ee3
nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents:
365
diff
changeset
|
49 ngx_uint_t ngx_daemonized; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
50 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
51 sig_atomic_t ngx_noaccept; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
52 ngx_uint_t ngx_noaccepting; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
53 ngx_uint_t ngx_restart; |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
54 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
55 |
577 | 56 static u_char master_process[] = "master process"; |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
57 |
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
58 |
3018 | 59 static ngx_cache_manager_ctx_t ngx_cache_manager_ctx = { |
60 ngx_cache_manager_process_handler, "cache manager process", 0 | |
61 }; | |
62 | |
63 static ngx_cache_manager_ctx_t ngx_cache_loader_ctx = { | |
64 ngx_cache_loader_process_handler, "cache loader process", 60000 | |
65 }; | |
66 | |
67 | |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
68 static ngx_cycle_t ngx_exit_cycle; |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
69 static ngx_log_t ngx_exit_log; |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
70 static ngx_open_file_t ngx_exit_log_file; |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
71 |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
72 |
501 | 73 void |
74 ngx_master_process_cycle(ngx_cycle_t *cycle) | |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
75 { |
329
9a0ffa21f193
nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
76 char *title; |
9a0ffa21f193
nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
77 u_char *p; |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
78 size_t size; |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
79 ngx_int_t i; |
3293
8abb88374c6c
Fix a bug introduced in r2032: After a child process has read a terminate
Igor Sysoev <igor@sysoev.ru>
parents:
3230
diff
changeset
|
80 ngx_uint_t n, sigio; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
81 sigset_t set; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
82 struct itimerval itv; |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
83 ngx_uint_t live; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
84 ngx_msec_t delay; |
531 | 85 ngx_listening_t *ls; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
86 ngx_core_conf_t *ccf; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
87 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
88 sigemptyset(&set); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
89 sigaddset(&set, SIGCHLD); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
90 sigaddset(&set, SIGALRM); |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
91 sigaddset(&set, SIGIO); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
92 sigaddset(&set, SIGINT); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
93 sigaddset(&set, ngx_signal_value(NGX_RECONFIGURE_SIGNAL)); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
94 sigaddset(&set, ngx_signal_value(NGX_REOPEN_SIGNAL)); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
95 sigaddset(&set, ngx_signal_value(NGX_NOACCEPT_SIGNAL)); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
96 sigaddset(&set, ngx_signal_value(NGX_TERMINATE_SIGNAL)); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
97 sigaddset(&set, ngx_signal_value(NGX_SHUTDOWN_SIGNAL)); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
98 sigaddset(&set, ngx_signal_value(NGX_CHANGEBIN_SIGNAL)); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
99 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
100 if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) { |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
101 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
102 "sigprocmask() failed"); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
103 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
104 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
105 sigemptyset(&set); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
106 |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
107 |
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
108 size = sizeof(master_process); |
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
109 |
452 | 110 for (i = 0; i < ngx_argc; i++) { |
111 size += ngx_strlen(ngx_argv[i]) + 1; | |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
112 } |
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
113 |
2049 | 114 title = ngx_pnalloc(cycle->pool, size); |
5786
f8764e20fcd7
Core: exit on ngx_pnalloc() failure.
Piotr Sikora <piotr@cloudflare.com>
parents:
5702
diff
changeset
|
115 if (title == NULL) { |
f8764e20fcd7
Core: exit on ngx_pnalloc() failure.
Piotr Sikora <piotr@cloudflare.com>
parents:
5702
diff
changeset
|
116 /* fatal */ |
f8764e20fcd7
Core: exit on ngx_pnalloc() failure.
Piotr Sikora <piotr@cloudflare.com>
parents:
5702
diff
changeset
|
117 exit(2); |
f8764e20fcd7
Core: exit on ngx_pnalloc() failure.
Piotr Sikora <piotr@cloudflare.com>
parents:
5702
diff
changeset
|
118 } |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
119 |
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
120 p = ngx_cpymem(title, master_process, sizeof(master_process) - 1); |
452 | 121 for (i = 0; i < ngx_argc; i++) { |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
122 *p++ = ' '; |
452 | 123 p = ngx_cpystrn(p, (u_char *) ngx_argv[i], size); |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
124 } |
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
125 |
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
126 ngx_setproctitle(title); |
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
127 |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
128 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
129 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
130 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
131 ngx_start_worker_processes(cycle, ccf->worker_processes, |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
132 NGX_PROCESS_RESPAWN); |
3018 | 133 ngx_start_cache_manager_processes(cycle, 0); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
134 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
135 ngx_new_binary = 0; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
136 delay = 0; |
3293
8abb88374c6c
Fix a bug introduced in r2032: After a child process has read a terminate
Igor Sysoev <igor@sysoev.ru>
parents:
3230
diff
changeset
|
137 sigio = 0; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
138 live = 1; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
139 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
140 for ( ;; ) { |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
141 if (delay) { |
3048
846d0e2fa483
twice termination delay only after SIGALRM, otherwise many separate SIGCHLD
Igor Sysoev <igor@sysoev.ru>
parents:
3047
diff
changeset
|
142 if (ngx_sigalrm) { |
3293
8abb88374c6c
Fix a bug introduced in r2032: After a child process has read a terminate
Igor Sysoev <igor@sysoev.ru>
parents:
3230
diff
changeset
|
143 sigio = 0; |
3048
846d0e2fa483
twice termination delay only after SIGALRM, otherwise many separate SIGCHLD
Igor Sysoev <igor@sysoev.ru>
parents:
3047
diff
changeset
|
144 delay *= 2; |
846d0e2fa483
twice termination delay only after SIGALRM, otherwise many separate SIGCHLD
Igor Sysoev <igor@sysoev.ru>
parents:
3047
diff
changeset
|
145 ngx_sigalrm = 0; |
846d0e2fa483
twice termination delay only after SIGALRM, otherwise many separate SIGCHLD
Igor Sysoev <igor@sysoev.ru>
parents:
3047
diff
changeset
|
146 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
147 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
148 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
6480 | 149 "termination cycle: %M", delay); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
150 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
151 itv.it_interval.tv_sec = 0; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
152 itv.it_interval.tv_usec = 0; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
153 itv.it_value.tv_sec = delay / 1000; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
154 itv.it_value.tv_usec = (delay % 1000 ) * 1000; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
155 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
156 if (setitimer(ITIMER_REAL, &itv, NULL) == -1) { |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
157 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
158 "setitimer() failed"); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
159 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
160 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
161 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
162 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "sigsuspend"); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
163 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
164 sigsuspend(&set); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
165 |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
166 ngx_time_update(); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
167 |
3304
6832c7f5e189
fix building without --with-debug, introduced in r3294
Igor Sysoev <igor@sysoev.ru>
parents:
3293
diff
changeset
|
168 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
3293
8abb88374c6c
Fix a bug introduced in r2032: After a child process has read a terminate
Igor Sysoev <igor@sysoev.ru>
parents:
3230
diff
changeset
|
169 "wake up, sigio %i", sigio); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
170 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
171 if (ngx_reap) { |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
172 ngx_reap = 0; |
1565 | 173 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "reap children"); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
174 |
1565 | 175 live = ngx_reap_children(cycle); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
176 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
177 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
178 if (!live && (ngx_terminate || ngx_quit)) { |
573 | 179 ngx_master_process_exit(cycle); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
180 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
181 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
182 if (ngx_terminate) { |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
183 if (delay == 0) { |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
184 delay = 50; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
185 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
186 |
3293
8abb88374c6c
Fix a bug introduced in r2032: After a child process has read a terminate
Igor Sysoev <igor@sysoev.ru>
parents:
3230
diff
changeset
|
187 if (sigio) { |
8abb88374c6c
Fix a bug introduced in r2032: After a child process has read a terminate
Igor Sysoev <igor@sysoev.ru>
parents:
3230
diff
changeset
|
188 sigio--; |
8abb88374c6c
Fix a bug introduced in r2032: After a child process has read a terminate
Igor Sysoev <igor@sysoev.ru>
parents:
3230
diff
changeset
|
189 continue; |
8abb88374c6c
Fix a bug introduced in r2032: After a child process has read a terminate
Igor Sysoev <igor@sysoev.ru>
parents:
3230
diff
changeset
|
190 } |
8abb88374c6c
Fix a bug introduced in r2032: After a child process has read a terminate
Igor Sysoev <igor@sysoev.ru>
parents:
3230
diff
changeset
|
191 |
8abb88374c6c
Fix a bug introduced in r2032: After a child process has read a terminate
Igor Sysoev <igor@sysoev.ru>
parents:
3230
diff
changeset
|
192 sigio = ccf->worker_processes + 2 /* cache processes */; |
8abb88374c6c
Fix a bug introduced in r2032: After a child process has read a terminate
Igor Sysoev <igor@sysoev.ru>
parents:
3230
diff
changeset
|
193 |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
194 if (delay > 1000) { |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
195 ngx_signal_worker_processes(cycle, SIGKILL); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
196 } else { |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
197 ngx_signal_worker_processes(cycle, |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
198 ngx_signal_value(NGX_TERMINATE_SIGNAL)); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
199 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
200 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
201 continue; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
202 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
203 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
204 if (ngx_quit) { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
205 ngx_signal_worker_processes(cycle, |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
206 ngx_signal_value(NGX_SHUTDOWN_SIGNAL)); |
531 | 207 |
208 ls = cycle->listening.elts; | |
209 for (n = 0; n < cycle->listening.nelts; n++) { | |
210 if (ngx_close_socket(ls[n].fd) == -1) { | |
211 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno, | |
212 ngx_close_socket_n " %V failed", | |
213 &ls[n].addr_text); | |
214 } | |
215 } | |
216 cycle->listening.nelts = 0; | |
217 | |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
218 continue; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
219 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
220 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
221 if (ngx_reconfigure) { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
222 ngx_reconfigure = 0; |
329
9a0ffa21f193
nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
223 |
9a0ffa21f193
nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
224 if (ngx_new_binary) { |
9a0ffa21f193
nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
225 ngx_start_worker_processes(cycle, ccf->worker_processes, |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
226 NGX_PROCESS_RESPAWN); |
3018 | 227 ngx_start_cache_manager_processes(cycle, 0); |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
228 ngx_noaccepting = 0; |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
229 |
329
9a0ffa21f193
nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
230 continue; |
9a0ffa21f193
nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
231 } |
9a0ffa21f193
nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
327
diff
changeset
|
232 |
477 | 233 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reconfiguring"); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
234 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
235 cycle = ngx_init_cycle(cycle); |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
236 if (cycle == NULL) { |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
237 cycle = (ngx_cycle_t *) ngx_cycle; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
238 continue; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
239 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
240 |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
241 ngx_cycle = cycle; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
242 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
243 ngx_core_module); |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
244 ngx_start_worker_processes(cycle, ccf->worker_processes, |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
245 NGX_PROCESS_JUST_RESPAWN); |
3018 | 246 ngx_start_cache_manager_processes(cycle, 1); |
4500
9dfe02dd0f11
Added msleep() on reload to allow new processes to start.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
247 |
9dfe02dd0f11
Added msleep() on reload to allow new processes to start.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
248 /* allow new processes to start */ |
9dfe02dd0f11
Added msleep() on reload to allow new processes to start.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
249 ngx_msleep(100); |
9dfe02dd0f11
Added msleep() on reload to allow new processes to start.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
250 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
251 live = 1; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
252 ngx_signal_worker_processes(cycle, |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
253 ngx_signal_value(NGX_SHUTDOWN_SIGNAL)); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
254 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
255 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
256 if (ngx_restart) { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
257 ngx_restart = 0; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
258 ngx_start_worker_processes(cycle, ccf->worker_processes, |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
259 NGX_PROCESS_RESPAWN); |
3018 | 260 ngx_start_cache_manager_processes(cycle, 0); |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
261 live = 1; |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
262 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
263 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
264 if (ngx_reopen) { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
265 ngx_reopen = 0; |
477 | 266 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs"); |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
267 ngx_reopen_files(cycle, ccf->user); |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
268 ngx_signal_worker_processes(cycle, |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
269 ngx_signal_value(NGX_REOPEN_SIGNAL)); |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
270 } |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
271 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
272 if (ngx_change_binary) { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
273 ngx_change_binary = 0; |
477 | 274 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "changing binary"); |
452 | 275 ngx_new_binary = ngx_exec_new_binary(cycle, ngx_argv); |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
276 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
277 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
278 if (ngx_noaccept) { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
279 ngx_noaccept = 0; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
280 ngx_noaccepting = 1; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
281 ngx_signal_worker_processes(cycle, |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
282 ngx_signal_value(NGX_SHUTDOWN_SIGNAL)); |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
283 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
284 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
285 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
286 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
287 |
501 | 288 void |
289 ngx_single_process_cycle(ngx_cycle_t *cycle) | |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
290 { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
291 ngx_uint_t i; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
292 |
3826
6843e7c492b7
allow "env" to work in the single process mode
Igor Sysoev <igor@sysoev.ru>
parents:
3762
diff
changeset
|
293 if (ngx_set_environment(cycle, NULL) == NULL) { |
6843e7c492b7
allow "env" to work in the single process mode
Igor Sysoev <igor@sysoev.ru>
parents:
3762
diff
changeset
|
294 /* fatal */ |
6843e7c492b7
allow "env" to work in the single process mode
Igor Sysoev <igor@sysoev.ru>
parents:
3762
diff
changeset
|
295 exit(2); |
6843e7c492b7
allow "env" to work in the single process mode
Igor Sysoev <igor@sysoev.ru>
parents:
3762
diff
changeset
|
296 } |
6843e7c492b7
allow "env" to work in the single process mode
Igor Sysoev <igor@sysoev.ru>
parents:
3762
diff
changeset
|
297 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
298 for (i = 0; cycle->modules[i]; i++) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
299 if (cycle->modules[i]->init_process) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
300 if (cycle->modules[i]->init_process(cycle) == NGX_ERROR) { |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
301 /* fatal */ |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
302 exit(2); |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
303 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
304 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
305 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
306 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
307 for ( ;; ) { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
308 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle"); |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
309 |
563 | 310 ngx_process_events_and_timers(cycle); |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
311 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
312 if (ngx_terminate || ngx_quit) { |
571 | 313 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
314 for (i = 0; cycle->modules[i]; i++) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
315 if (cycle->modules[i]->exit_process) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
316 cycle->modules[i]->exit_process(cycle); |
571 | 317 } |
318 } | |
319 | |
573 | 320 ngx_master_process_exit(cycle); |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
321 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
322 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
323 if (ngx_reconfigure) { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
324 ngx_reconfigure = 0; |
477 | 325 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reconfiguring"); |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
326 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
327 cycle = ngx_init_cycle(cycle); |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
328 if (cycle == NULL) { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
329 cycle = (ngx_cycle_t *) ngx_cycle; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
330 continue; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
331 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
332 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
333 ngx_cycle = cycle; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
334 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
335 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
336 if (ngx_reopen) { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
337 ngx_reopen = 0; |
477 | 338 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs"); |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
339 ngx_reopen_files(cycle, (ngx_uid_t) -1); |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
340 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
341 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
342 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
343 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
344 |
501 | 345 static void |
346 ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type) | |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
347 { |
3018 | 348 ngx_int_t i; |
557 | 349 ngx_channel_t ch; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
350 |
477 | 351 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start worker processes"); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
352 |
5245
711fa02afae8
Valgrind: supressed complaints about uninitialized bytes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5137
diff
changeset
|
353 ngx_memzero(&ch, sizeof(ngx_channel_t)); |
711fa02afae8
Valgrind: supressed complaints about uninitialized bytes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5137
diff
changeset
|
354 |
360
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
357
diff
changeset
|
355 ch.command = NGX_CMD_OPEN_CHANNEL; |
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
357
diff
changeset
|
356 |
577 | 357 for (i = 0; i < n; i++) { |
358 | |
4912
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
359 ngx_spawn_process(cycle, ngx_worker_process_cycle, |
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
360 (void *) (intptr_t) i, "worker process", type); |
360
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
357
diff
changeset
|
361 |
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
357
diff
changeset
|
362 ch.pid = ngx_processes[ngx_process_slot].pid; |
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
357
diff
changeset
|
363 ch.slot = ngx_process_slot; |
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
357
diff
changeset
|
364 ch.fd = ngx_processes[ngx_process_slot].channel[0]; |
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
357
diff
changeset
|
365 |
3018 | 366 ngx_pass_open_channel(cycle, &ch); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
367 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
368 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
369 |
360
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
357
diff
changeset
|
370 |
501 | 371 static void |
3018 | 372 ngx_start_cache_manager_processes(ngx_cycle_t *cycle, ngx_uint_t respawn) |
467 | 373 { |
3018 | 374 ngx_uint_t i, manager, loader; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
375 ngx_path_t **path; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
376 ngx_channel_t ch; |
467 | 377 |
3018 | 378 manager = 0; |
379 loader = 0; | |
380 | |
4870
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4864
diff
changeset
|
381 path = ngx_cycle->paths.elts; |
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4864
diff
changeset
|
382 for (i = 0; i < ngx_cycle->paths.nelts; i++) { |
3018 | 383 |
384 if (path[i]->manager) { | |
385 manager = 1; | |
386 } | |
387 | |
388 if (path[i]->loader) { | |
389 loader = 1; | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
390 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
391 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
392 |
3018 | 393 if (manager == 0) { |
394 return; | |
395 } | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
396 |
3018 | 397 ngx_spawn_process(cycle, ngx_cache_manager_process_cycle, |
398 &ngx_cache_manager_ctx, "cache manager process", | |
399 respawn ? NGX_PROCESS_JUST_RESPAWN : NGX_PROCESS_RESPAWN); | |
467 | 400 |
5245
711fa02afae8
Valgrind: supressed complaints about uninitialized bytes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5137
diff
changeset
|
401 ngx_memzero(&ch, sizeof(ngx_channel_t)); |
711fa02afae8
Valgrind: supressed complaints about uninitialized bytes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5137
diff
changeset
|
402 |
467 | 403 ch.command = NGX_CMD_OPEN_CHANNEL; |
404 ch.pid = ngx_processes[ngx_process_slot].pid; | |
405 ch.slot = ngx_process_slot; | |
406 ch.fd = ngx_processes[ngx_process_slot].channel[0]; | |
407 | |
3018 | 408 ngx_pass_open_channel(cycle, &ch); |
409 | |
410 if (loader == 0) { | |
411 return; | |
412 } | |
413 | |
414 ngx_spawn_process(cycle, ngx_cache_manager_process_cycle, | |
415 &ngx_cache_loader_ctx, "cache loader process", | |
416 respawn ? NGX_PROCESS_JUST_SPAWN : NGX_PROCESS_NORESPAWN); | |
417 | |
418 ch.command = NGX_CMD_OPEN_CHANNEL; | |
419 ch.pid = ngx_processes[ngx_process_slot].pid; | |
420 ch.slot = ngx_process_slot; | |
421 ch.fd = ngx_processes[ngx_process_slot].channel[0]; | |
422 | |
423 ngx_pass_open_channel(cycle, &ch); | |
424 } | |
425 | |
426 | |
427 static void | |
428 ngx_pass_open_channel(ngx_cycle_t *cycle, ngx_channel_t *ch) | |
429 { | |
430 ngx_int_t i; | |
431 | |
467 | 432 for (i = 0; i < ngx_last_process; i++) { |
433 | |
434 if (i == ngx_process_slot | |
435 || ngx_processes[i].pid == -1 | |
436 || ngx_processes[i].channel[0] == -1) | |
437 { | |
438 continue; | |
439 } | |
440 | |
441 ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0, | |
6480 | 442 "pass channel s:%i pid:%P fd:%d to s:%i pid:%P fd:%d", |
3018 | 443 ch->slot, ch->pid, ch->fd, |
467 | 444 i, ngx_processes[i].pid, |
445 ngx_processes[i].channel[0]); | |
446 | |
447 /* TODO: NGX_AGAIN */ | |
448 | |
449 ngx_write_channel(ngx_processes[i].channel[0], | |
3018 | 450 ch, sizeof(ngx_channel_t), cycle->log); |
467 | 451 } |
452 } | |
453 | |
454 | |
501 | 455 static void |
456 ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo) | |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
457 { |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
458 ngx_int_t i; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
459 ngx_err_t err; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
460 ngx_channel_t ch; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
461 |
5245
711fa02afae8
Valgrind: supressed complaints about uninitialized bytes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5137
diff
changeset
|
462 ngx_memzero(&ch, sizeof(ngx_channel_t)); |
711fa02afae8
Valgrind: supressed complaints about uninitialized bytes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5137
diff
changeset
|
463 |
1581
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
464 #if (NGX_BROKEN_SCM_RIGHTS) |
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
465 |
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
466 ch.command = 0; |
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
467 |
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
468 #else |
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
469 |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
470 switch (signo) { |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
471 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
472 case ngx_signal_value(NGX_SHUTDOWN_SIGNAL): |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
473 ch.command = NGX_CMD_QUIT; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
474 break; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
475 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
476 case ngx_signal_value(NGX_TERMINATE_SIGNAL): |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
477 ch.command = NGX_CMD_TERMINATE; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
478 break; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
479 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
480 case ngx_signal_value(NGX_REOPEN_SIGNAL): |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
481 ch.command = NGX_CMD_REOPEN; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
482 break; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
483 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
484 default: |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
485 ch.command = 0; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
486 } |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
487 |
1581
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
488 #endif |
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
489 |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
490 ch.fd = -1; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
491 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
492 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
493 for (i = 0; i < ngx_last_process; i++) { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
494 |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
495 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
6480 | 496 "child: %i %P e:%d t:%d d:%d r:%d j:%d", |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
497 i, |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
498 ngx_processes[i].pid, |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
499 ngx_processes[i].exiting, |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
500 ngx_processes[i].exited, |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
501 ngx_processes[i].detached, |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
502 ngx_processes[i].respawn, |
3016
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2616
diff
changeset
|
503 ngx_processes[i].just_spawn); |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
504 |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
505 if (ngx_processes[i].detached || ngx_processes[i].pid == -1) { |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
506 continue; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
507 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
508 |
3016
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2616
diff
changeset
|
509 if (ngx_processes[i].just_spawn) { |
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2616
diff
changeset
|
510 ngx_processes[i].just_spawn = 0; |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
511 continue; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
512 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
513 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
514 if (ngx_processes[i].exiting |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
515 && signo == ngx_signal_value(NGX_SHUTDOWN_SIGNAL)) |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
516 { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
517 continue; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
518 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
519 |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
520 if (ch.command) { |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
521 if (ngx_write_channel(ngx_processes[i].channel[0], |
1132 | 522 &ch, sizeof(ngx_channel_t), cycle->log) |
523 == NGX_OK) | |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
524 { |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
525 if (signo != ngx_signal_value(NGX_REOPEN_SIGNAL)) { |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
526 ngx_processes[i].exiting = 1; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
527 } |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
528 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
529 continue; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
530 } |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
531 } |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
532 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
533 ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0, |
5266 | 534 "kill (%P, %d)", ngx_processes[i].pid, signo); |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
535 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
536 if (kill(ngx_processes[i].pid, signo) == -1) { |
322
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
537 err = ngx_errno; |
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
538 ngx_log_error(NGX_LOG_ALERT, cycle->log, err, |
3047 | 539 "kill(%P, %d) failed", ngx_processes[i].pid, signo); |
322
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
540 |
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
541 if (err == NGX_ESRCH) { |
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
542 ngx_processes[i].exited = 1; |
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
543 ngx_processes[i].exiting = 0; |
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
544 ngx_reap = 1; |
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
545 } |
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
546 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
547 continue; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
548 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
549 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
550 if (signo != ngx_signal_value(NGX_REOPEN_SIGNAL)) { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
551 ngx_processes[i].exiting = 1; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
552 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
553 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
554 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
555 |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
556 |
501 | 557 static ngx_uint_t |
1565 | 558 ngx_reap_children(ngx_cycle_t *cycle) |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
559 { |
543 | 560 ngx_int_t i, n; |
561 ngx_uint_t live; | |
562 ngx_channel_t ch; | |
563 ngx_core_conf_t *ccf; | |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
564 |
5245
711fa02afae8
Valgrind: supressed complaints about uninitialized bytes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5137
diff
changeset
|
565 ngx_memzero(&ch, sizeof(ngx_channel_t)); |
711fa02afae8
Valgrind: supressed complaints about uninitialized bytes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5137
diff
changeset
|
566 |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
567 ch.command = NGX_CMD_CLOSE_CHANNEL; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
568 ch.fd = -1; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
569 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
570 live = 0; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
571 for (i = 0; i < ngx_last_process; i++) { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
572 |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
573 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
6480 | 574 "child: %i %P e:%d t:%d d:%d r:%d j:%d", |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
575 i, |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
576 ngx_processes[i].pid, |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
577 ngx_processes[i].exiting, |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
578 ngx_processes[i].exited, |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
579 ngx_processes[i].detached, |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
580 ngx_processes[i].respawn, |
3016
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2616
diff
changeset
|
581 ngx_processes[i].just_spawn); |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
582 |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
583 if (ngx_processes[i].pid == -1) { |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
584 continue; |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
585 } |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
586 |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
587 if (ngx_processes[i].exited) { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
588 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
589 if (!ngx_processes[i].detached) { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
590 ngx_close_channel(ngx_processes[i].channel, cycle->log); |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
591 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
592 ngx_processes[i].channel[0] = -1; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
593 ngx_processes[i].channel[1] = -1; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
594 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
595 ch.pid = ngx_processes[i].pid; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
596 ch.slot = i; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
597 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
598 for (n = 0; n < ngx_last_process; n++) { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
599 if (ngx_processes[n].exited |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
600 || ngx_processes[n].pid == -1 |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
601 || ngx_processes[n].channel[0] == -1) |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
602 { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
603 continue; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
604 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
605 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
606 ngx_log_debug3(NGX_LOG_DEBUG_CORE, cycle->log, 0, |
461 | 607 "pass close channel s:%i pid:%P to:%P", |
608 ch.slot, ch.pid, ngx_processes[n].pid); | |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
609 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
610 /* TODO: NGX_AGAIN */ |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
611 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
612 ngx_write_channel(ngx_processes[n].channel[0], |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
613 &ch, sizeof(ngx_channel_t), cycle->log); |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
614 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
615 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
616 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
617 if (ngx_processes[i].respawn |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
618 && !ngx_processes[i].exiting |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
619 && !ngx_terminate |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
620 && !ngx_quit) |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
621 { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
622 if (ngx_spawn_process(cycle, ngx_processes[i].proc, |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
623 ngx_processes[i].data, |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
624 ngx_processes[i].name, i) |
543 | 625 == NGX_INVALID_PID) |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
626 { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
627 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
4133
59b99f217c6d
Replaced "can not" with "cannot" and "could not" in a bunch of places.
Ruslan Ermilov <ru@nginx.com>
parents:
3826
diff
changeset
|
628 "could not respawn %s", |
59b99f217c6d
Replaced "can not" with "cannot" and "could not" in a bunch of places.
Ruslan Ermilov <ru@nginx.com>
parents:
3826
diff
changeset
|
629 ngx_processes[i].name); |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
630 continue; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
631 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
632 |
473 | 633 |
634 ch.command = NGX_CMD_OPEN_CHANNEL; | |
635 ch.pid = ngx_processes[ngx_process_slot].pid; | |
636 ch.slot = ngx_process_slot; | |
637 ch.fd = ngx_processes[ngx_process_slot].channel[0]; | |
638 | |
3018 | 639 ngx_pass_open_channel(cycle, &ch); |
473 | 640 |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
641 live = 1; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
642 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
643 continue; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
644 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
645 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
646 if (ngx_processes[i].pid == ngx_new_binary) { |
543 | 647 |
648 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, | |
649 ngx_core_module); | |
650 | |
651 if (ngx_rename_file((char *) ccf->oldpid.data, | |
652 (char *) ccf->pid.data) | |
5137
f941cf265cc5
Use NGX_FILE_ERROR for handling file operations errors.
Valentin Bartenev <vbart@nginx.com>
parents:
4917
diff
changeset
|
653 == NGX_FILE_ERROR) |
543 | 654 { |
655 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
656 ngx_rename_file_n " %s back to %s failed " | |
657 "after the new binary process \"%s\" exited", | |
658 ccf->oldpid.data, ccf->pid.data, ngx_argv[0]); | |
659 } | |
660 | |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
661 ngx_new_binary = 0; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
662 if (ngx_noaccepting) { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
663 ngx_restart = 1; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
664 ngx_noaccepting = 0; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
665 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
666 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
667 |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
668 if (i == ngx_last_process - 1) { |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
669 ngx_last_process--; |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
670 |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
671 } else { |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
672 ngx_processes[i].pid = -1; |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
673 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
674 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
675 } else if (ngx_processes[i].exiting || !ngx_processes[i].detached) { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
676 live = 1; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
677 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
678 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
679 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
680 return live; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
681 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
682 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
683 |
501 | 684 static void |
573 | 685 ngx_master_process_exit(ngx_cycle_t *cycle) |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
686 { |
571 | 687 ngx_uint_t i; |
688 | |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
689 ngx_delete_pidfile(cycle); |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
690 |
477 | 691 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exit"); |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
692 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
693 for (i = 0; cycle->modules[i]; i++) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
694 if (cycle->modules[i]->exit_master) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
695 cycle->modules[i]->exit_master(cycle); |
571 | 696 } |
697 } | |
698 | |
3230
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3048
diff
changeset
|
699 ngx_close_listening_sockets(cycle); |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3048
diff
changeset
|
700 |
505 | 701 /* |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
702 * Copy ngx_cycle->log related data to the special static exit cycle, |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
703 * log, and log file structures enough to allow a signal handler to log. |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
704 * The handler may be called when standard ngx_cycle->log allocated from |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
705 * ngx_cycle->pool is already destroyed. |
505 | 706 */ |
707 | |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
708 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5601
diff
changeset
|
709 ngx_exit_log = *ngx_log_get_file_log(ngx_cycle->log); |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5601
diff
changeset
|
710 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5601
diff
changeset
|
711 ngx_exit_log_file.fd = ngx_exit_log.file->fd; |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
712 ngx_exit_log.file = &ngx_exit_log_file; |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5245
diff
changeset
|
713 ngx_exit_log.next = NULL; |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5601
diff
changeset
|
714 ngx_exit_log.writer = NULL; |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
715 |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
716 ngx_exit_cycle.log = &ngx_exit_log; |
4691
626157fe6f17
Fixed segfault with poll and resolver used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4549
diff
changeset
|
717 ngx_exit_cycle.files = ngx_cycle->files; |
626157fe6f17
Fixed segfault with poll and resolver used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4549
diff
changeset
|
718 ngx_exit_cycle.files_n = ngx_cycle->files_n; |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
719 ngx_cycle = &ngx_exit_cycle; |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
720 |
322
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
721 ngx_destroy_pool(cycle->pool); |
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
722 |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
723 exit(0); |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
724 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
725 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
726 |
501 | 727 static void |
728 ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) | |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
729 { |
4912
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
730 ngx_int_t worker = (intptr_t) data; |
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
731 |
3358
f94e8ff65aa2
add NGX_PROCESS_HELPER process status
Igor Sysoev <igor@sysoev.ru>
parents:
3304
diff
changeset
|
732 ngx_process = NGX_PROCESS_WORKER; |
6151
b4cc553aafeb
Introduced worker number, ngx_worker.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6127
diff
changeset
|
733 ngx_worker = worker; |
3358
f94e8ff65aa2
add NGX_PROCESS_HELPER process status
Igor Sysoev <igor@sysoev.ru>
parents:
3304
diff
changeset
|
734 |
4912
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
735 ngx_worker_process_init(cycle, worker); |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
736 |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
737 ngx_setproctitle("worker process"); |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
738 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
739 for ( ;; ) { |
1135
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1134
diff
changeset
|
740 |
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1134
diff
changeset
|
741 if (ngx_exiting) { |
6929
3069dd358ba2
Cancelable timers are now preserved if there are other timers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6727
diff
changeset
|
742 if (ngx_event_no_timers_left() == NGX_OK) { |
1135
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1134
diff
changeset
|
743 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting"); |
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1134
diff
changeset
|
744 ngx_worker_process_exit(cycle); |
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1134
diff
changeset
|
745 } |
322
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
746 } |
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
747 |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
748 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle"); |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
749 |
563 | 750 ngx_process_events_and_timers(cycle); |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
751 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
752 if (ngx_terminate) { |
477 | 753 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting"); |
573 | 754 ngx_worker_process_exit(cycle); |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
755 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
756 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
757 if (ngx_quit) { |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
322
diff
changeset
|
758 ngx_quit = 0; |
477 | 759 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
760 "gracefully shutting down"); |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
761 ngx_setproctitle("worker process is shutting down"); |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
762 |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
763 if (!ngx_exiting) { |
6220
5e6142609e48
Core: idle connections now closed only once on exiting.
Valentin Bartenev <vbart@nginx.com>
parents:
6151
diff
changeset
|
764 ngx_exiting = 1; |
6930
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6929
diff
changeset
|
765 ngx_set_shutdown_timer(cycle); |
322
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
766 ngx_close_listening_sockets(cycle); |
6220
5e6142609e48
Core: idle connections now closed only once on exiting.
Valentin Bartenev <vbart@nginx.com>
parents:
6151
diff
changeset
|
767 ngx_close_idle_connections(cycle); |
322
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
768 } |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
769 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
770 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
771 if (ngx_reopen) { |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
322
diff
changeset
|
772 ngx_reopen = 0; |
477 | 773 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs"); |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
774 ngx_reopen_files(cycle, -1); |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
775 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
776 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
777 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
778 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
779 |
501 | 780 static void |
4912
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
781 ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker) |
467 | 782 { |
1069 | 783 sigset_t set; |
784 ngx_int_t n; | |
6651
7d4e33092e2a
Always seed PRNG with PID, seconds, and milliseconds.
Ruslan Ermilov <ru@nginx.com>
parents:
6650
diff
changeset
|
785 ngx_time_t *tp; |
1069 | 786 ngx_uint_t i; |
6402
7296b38f6416
Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents:
6379
diff
changeset
|
787 ngx_cpuset_t *cpu_affinity; |
1069 | 788 struct rlimit rlmt; |
789 ngx_core_conf_t *ccf; | |
790 ngx_listening_t *ls; | |
467 | 791 |
1069 | 792 if (ngx_set_environment(cycle, NULL) == NULL) { |
793 /* fatal */ | |
794 exit(2); | |
795 } | |
796 | |
467 | 797 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
798 | |
4912
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
799 if (worker >= 0 && ccf->priority != 0) { |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
800 if (setpriority(PRIO_PROCESS, 0, ccf->priority) == -1) { |
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
801 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
802 "setpriority(%d) failed", ccf->priority); |
473 | 803 } |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
804 } |
473 | 805 |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
806 if (ccf->rlimit_nofile != NGX_CONF_UNSET) { |
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
807 rlmt.rlim_cur = (rlim_t) ccf->rlimit_nofile; |
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
808 rlmt.rlim_max = (rlim_t) ccf->rlimit_nofile; |
543 | 809 |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
810 if (setrlimit(RLIMIT_NOFILE, &rlmt) == -1) { |
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
811 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
812 "setrlimit(RLIMIT_NOFILE, %i) failed", |
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
813 ccf->rlimit_nofile); |
543 | 814 } |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
815 } |
543 | 816 |
3762
89002ac695e5
worker_rlimit_core should be off_t
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
817 if (ccf->rlimit_core != NGX_CONF_UNSET) { |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
818 rlmt.rlim_cur = (rlim_t) ccf->rlimit_core; |
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
819 rlmt.rlim_max = (rlim_t) ccf->rlimit_core; |
589 | 820 |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
821 if (setrlimit(RLIMIT_CORE, &rlmt) == -1) { |
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
822 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
3762
89002ac695e5
worker_rlimit_core should be off_t
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
823 "setrlimit(RLIMIT_CORE, %O) failed", |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
824 ccf->rlimit_core); |
589 | 825 } |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
826 } |
589 | 827 |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
828 if (geteuid() == 0) { |
467 | 829 if (setgid(ccf->group) == -1) { |
830 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
831 "setgid(%d) failed", ccf->group); | |
832 /* fatal */ | |
833 exit(2); | |
834 } | |
835 | |
473 | 836 if (initgroups(ccf->username, ccf->group) == -1) { |
837 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
838 "initgroups(%s, %d) failed", | |
839 ccf->username, ccf->group); | |
840 } | |
841 | |
7174
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
842 #if (NGX_HAVE_PR_SET_KEEPCAPS && NGX_HAVE_CAPABILITIES) |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
843 if (ccf->transparent && ccf->user) { |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
844 if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) == -1) { |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
845 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
846 "prctl(PR_SET_KEEPCAPS, 1) failed"); |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
847 /* fatal */ |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
848 exit(2); |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
849 } |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
850 } |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
851 #endif |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
852 |
467 | 853 if (setuid(ccf->user) == -1) { |
854 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
855 "setuid(%d) failed", ccf->user); | |
856 /* fatal */ | |
857 exit(2); | |
858 } | |
7174
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
859 |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
860 #if (NGX_HAVE_CAPABILITIES) |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
861 if (ccf->transparent && ccf->user) { |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
862 struct __user_cap_data_struct data; |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
863 struct __user_cap_header_struct header; |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
864 |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
865 ngx_memzero(&header, sizeof(struct __user_cap_header_struct)); |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
866 ngx_memzero(&data, sizeof(struct __user_cap_data_struct)); |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
867 |
7176
7f28b61c92f0
Fixed capabilities version.
Roman Arutyunyan <arut@nginx.com>
parents:
7175
diff
changeset
|
868 header.version = _LINUX_CAPABILITY_VERSION_1; |
7174
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
869 data.effective = CAP_TO_MASK(CAP_NET_RAW); |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
870 data.permitted = data.effective; |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
871 |
7175
56923e8e01a5
Improved the capabilities feature detection.
Roman Arutyunyan <arut@nginx.com>
parents:
7174
diff
changeset
|
872 if (syscall(SYS_capset, &header, &data) == -1) { |
7174
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
873 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
874 "capset() failed"); |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
875 /* fatal */ |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
876 exit(2); |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
877 } |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
878 } |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
879 #endif |
467 | 880 } |
881 | |
4912
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
882 if (worker >= 0) { |
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
883 cpu_affinity = ngx_get_cpu_affinity(worker); |
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
884 |
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
885 if (cpu_affinity) { |
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
886 ngx_setaffinity(cpu_affinity, cycle->log); |
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
887 } |
577 | 888 } |
889 | |
467 | 890 #if (NGX_HAVE_PR_SET_DUMPABLE) |
891 | |
892 /* allow coredump after setuid() in Linux 2.4.x */ | |
893 | |
894 if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) { | |
895 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
896 "prctl(PR_SET_DUMPABLE) failed"); | |
897 } | |
898 | |
899 #endif | |
900 | |
521 | 901 if (ccf->working_directory.len) { |
523 | 902 if (chdir((char *) ccf->working_directory.data) == -1) { |
521 | 903 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
904 "chdir(\"%s\") failed", ccf->working_directory.data); | |
905 /* fatal */ | |
906 exit(2); | |
907 } | |
908 } | |
909 | |
467 | 910 sigemptyset(&set); |
911 | |
912 if (sigprocmask(SIG_SETMASK, &set, NULL) == -1) { | |
913 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
914 "sigprocmask() failed"); | |
915 } | |
916 | |
6651
7d4e33092e2a
Always seed PRNG with PID, seconds, and milliseconds.
Ruslan Ermilov <ru@nginx.com>
parents:
6650
diff
changeset
|
917 tp = ngx_timeofday(); |
7d4e33092e2a
Always seed PRNG with PID, seconds, and milliseconds.
Ruslan Ermilov <ru@nginx.com>
parents:
6650
diff
changeset
|
918 srandom(((unsigned) ngx_pid << 16) ^ tp->sec ^ tp->msec); |
5499
b91bcba29351
Added per-process random seeding (ticket #456).
Maxim Dounin <mdounin@mdounin.ru>
parents:
5266
diff
changeset
|
919 |
467 | 920 /* |
921 * disable deleting previous events for the listening sockets because | |
922 * in the worker processes there are no events at all at this point | |
577 | 923 */ |
467 | 924 ls = cycle->listening.elts; |
925 for (i = 0; i < cycle->listening.nelts; i++) { | |
543 | 926 ls[i].previous = NULL; |
467 | 927 } |
928 | |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
929 for (i = 0; cycle->modules[i]; i++) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
930 if (cycle->modules[i]->init_process) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
931 if (cycle->modules[i]->init_process(cycle) == NGX_ERROR) { |
467 | 932 /* fatal */ |
933 exit(2); | |
934 } | |
935 } | |
936 } | |
937 | |
938 for (n = 0; n < ngx_last_process; n++) { | |
939 | |
940 if (ngx_processes[n].pid == -1) { | |
941 continue; | |
942 } | |
943 | |
944 if (n == ngx_process_slot) { | |
945 continue; | |
946 } | |
947 | |
948 if (ngx_processes[n].channel[1] == -1) { | |
949 continue; | |
950 } | |
951 | |
952 if (close(ngx_processes[n].channel[1]) == -1) { | |
953 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
954 "close() channel failed"); | |
955 } | |
956 } | |
957 | |
958 if (close(ngx_processes[ngx_process_slot].channel[0]) == -1) { | |
959 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
960 "close() channel failed"); | |
961 } | |
962 | |
963 #if 0 | |
964 ngx_last_process = 0; | |
965 #endif | |
966 | |
967 if (ngx_add_channel_event(cycle, ngx_channel, NGX_READ_EVENT, | |
1133 | 968 ngx_channel_handler) |
969 == NGX_ERROR) | |
467 | 970 { |
971 /* fatal */ | |
972 exit(2); | |
973 } | |
974 } | |
975 | |
976 | |
501 | 977 static void |
573 | 978 ngx_worker_process_exit(ngx_cycle_t *cycle) |
979 { | |
980 ngx_uint_t i; | |
981 ngx_connection_t *c; | |
982 | |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
983 for (i = 0; cycle->modules[i]; i++) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
984 if (cycle->modules[i]->exit_process) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
985 cycle->modules[i]->exit_process(cycle); |
573 | 986 } |
987 } | |
988 | |
1905
0cafbfd8112e
left open sockets were not really tested
Igor Sysoev <igor@sysoev.ru>
parents:
1900
diff
changeset
|
989 if (ngx_exiting) { |
587 | 990 c = cycle->connections; |
991 for (i = 0; i < cycle->connection_n; i++) { | |
992 if (c[i].fd != -1 | |
993 && c[i].read | |
994 && !c[i].read->accept | |
1905
0cafbfd8112e
left open sockets were not really tested
Igor Sysoev <igor@sysoev.ru>
parents:
1900
diff
changeset
|
995 && !c[i].read->channel |
0cafbfd8112e
left open sockets were not really tested
Igor Sysoev <igor@sysoev.ru>
parents:
1900
diff
changeset
|
996 && !c[i].read->resolver) |
587 | 997 { |
998 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, | |
5601
e45fa57ef725
Added connection serial number in logging of left open sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5499
diff
changeset
|
999 "*%uA open socket #%d left in connection %ui", |
e45fa57ef725
Added connection serial number in logging of left open sockets.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5499
diff
changeset
|
1000 c[i].number, c[i].fd, i); |
3026
f4b5c787fe33
fix debug point for left open sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3019
diff
changeset
|
1001 ngx_debug_quit = 1; |
587 | 1002 } |
573 | 1003 } |
1004 | |
587 | 1005 if (ngx_debug_quit) { |
3026
f4b5c787fe33
fix debug point for left open sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3019
diff
changeset
|
1006 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, "aborting"); |
587 | 1007 ngx_debug_point(); |
1008 } | |
573 | 1009 } |
1010 | |
1011 /* | |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1012 * Copy ngx_cycle->log related data to the special static exit cycle, |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1013 * log, and log file structures enough to allow a signal handler to log. |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1014 * The handler may be called when standard ngx_cycle->log allocated from |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1015 * ngx_cycle->pool is already destroyed. |
573 | 1016 */ |
1017 | |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5601
diff
changeset
|
1018 ngx_exit_log = *ngx_log_get_file_log(ngx_cycle->log); |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1019 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5601
diff
changeset
|
1020 ngx_exit_log_file.fd = ngx_exit_log.file->fd; |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1021 ngx_exit_log.file = &ngx_exit_log_file; |
5254
7ecaa9e4bf1b
Core: support several "error_log" directives.
Vladimir Homutov <vl@nginx.com>
parents:
5245
diff
changeset
|
1022 ngx_exit_log.next = NULL; |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5601
diff
changeset
|
1023 ngx_exit_log.writer = NULL; |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1024 |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1025 ngx_exit_cycle.log = &ngx_exit_log; |
4691
626157fe6f17
Fixed segfault with poll and resolver used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4549
diff
changeset
|
1026 ngx_exit_cycle.files = ngx_cycle->files; |
626157fe6f17
Fixed segfault with poll and resolver used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4549
diff
changeset
|
1027 ngx_exit_cycle.files_n = ngx_cycle->files_n; |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1028 ngx_cycle = &ngx_exit_cycle; |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1029 |
573 | 1030 ngx_destroy_pool(cycle->pool); |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1031 |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1032 ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0, "exit"); |
573 | 1033 |
1034 exit(0); | |
1035 } | |
1036 | |
1037 | |
1038 static void | |
501 | 1039 ngx_channel_handler(ngx_event_t *ev) |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1040 { |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1041 ngx_int_t n; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1042 ngx_channel_t ch; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1043 ngx_connection_t *c; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1044 |
467 | 1045 if (ev->timedout) { |
1046 ev->timedout = 0; | |
1047 return; | |
1048 } | |
1049 | |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1050 c = ev->data; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1051 |
357
e260514b9ad4
nginx-0.0.7-2004-06-16-23:36:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
355
diff
changeset
|
1052 ngx_log_debug0(NGX_LOG_DEBUG_CORE, ev->log, 0, "channel handler"); |
e260514b9ad4
nginx-0.0.7-2004-06-16-23:36:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
355
diff
changeset
|
1053 |
2031 | 1054 for ( ;; ) { |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1055 |
2031 | 1056 n = ngx_read_channel(c->fd, &ch, sizeof(ngx_channel_t), ev->log); |
1057 | |
1058 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, "channel: %i", n); | |
357
e260514b9ad4
nginx-0.0.7-2004-06-16-23:36:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
355
diff
changeset
|
1059 |
2031 | 1060 if (n == NGX_ERROR) { |
1900
55a9d867e3c8
avoid endless loop if epoll is used
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
1061 |
2031 | 1062 if (ngx_event_flags & NGX_USE_EPOLL_EVENT) { |
1063 ngx_del_conn(c, 0); | |
1064 } | |
1065 | |
1066 ngx_close_connection(c); | |
1067 return; | |
1900
55a9d867e3c8
avoid endless loop if epoll is used
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
1068 } |
55a9d867e3c8
avoid endless loop if epoll is used
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
1069 |
2031 | 1070 if (ngx_event_flags & NGX_USE_EVENTPORT_EVENT) { |
1071 if (ngx_add_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) { | |
1072 return; | |
1073 } | |
1074 } | |
461 | 1075 |
2031 | 1076 if (n == NGX_AGAIN) { |
1134
384c92c210f9
worker processes did not exit after reconfiguration and
Igor Sysoev <igor@sysoev.ru>
parents:
1133
diff
changeset
|
1077 return; |
384c92c210f9
worker processes did not exit after reconfiguration and
Igor Sysoev <igor@sysoev.ru>
parents:
1133
diff
changeset
|
1078 } |
2031 | 1079 |
1080 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, | |
6480 | 1081 "channel command: %ui", ch.command); |
1134
384c92c210f9
worker processes did not exit after reconfiguration and
Igor Sysoev <igor@sysoev.ru>
parents:
1133
diff
changeset
|
1082 |
2031 | 1083 switch (ch.command) { |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1084 |
2031 | 1085 case NGX_CMD_QUIT: |
1086 ngx_quit = 1; | |
1087 break; | |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1088 |
2031 | 1089 case NGX_CMD_TERMINATE: |
1090 ngx_terminate = 1; | |
1091 break; | |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1092 |
2031 | 1093 case NGX_CMD_REOPEN: |
1094 ngx_reopen = 1; | |
1095 break; | |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1096 |
2031 | 1097 case NGX_CMD_OPEN_CHANNEL: |
360
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
357
diff
changeset
|
1098 |
2031 | 1099 ngx_log_debug3(NGX_LOG_DEBUG_CORE, ev->log, 0, |
1100 "get channel s:%i pid:%P fd:%d", | |
1101 ch.slot, ch.pid, ch.fd); | |
360
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
357
diff
changeset
|
1102 |
2031 | 1103 ngx_processes[ch.slot].pid = ch.pid; |
1104 ngx_processes[ch.slot].channel[0] = ch.fd; | |
1105 break; | |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
1106 |
2031 | 1107 case NGX_CMD_CLOSE_CHANNEL: |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
1108 |
2031 | 1109 ngx_log_debug4(NGX_LOG_DEBUG_CORE, ev->log, 0, |
1110 "close channel s:%i pid:%P our:%P fd:%d", | |
1111 ch.slot, ch.pid, ngx_processes[ch.slot].pid, | |
1112 ngx_processes[ch.slot].channel[0]); | |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
1113 |
2031 | 1114 if (close(ngx_processes[ch.slot].channel[0]) == -1) { |
1115 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno, | |
1116 "close() channel failed"); | |
1117 } | |
1118 | |
1119 ngx_processes[ch.slot].channel[0] = -1; | |
1120 break; | |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
1121 } |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1122 } |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1123 } |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1124 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1125 |
501 | 1126 static void |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
1127 ngx_cache_manager_process_cycle(ngx_cycle_t *cycle, void *data) |
467 | 1128 { |
3018 | 1129 ngx_cache_manager_ctx_t *ctx = data; |
1130 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1131 void *ident[4]; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1132 ngx_event_t ev; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1133 |
4917
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1134 /* |
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1135 * Set correct process type since closing listening Unix domain socket |
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1136 * in a master process also removes the Unix domain socket file. |
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1137 */ |
3358
f94e8ff65aa2
add NGX_PROCESS_HELPER process status
Igor Sysoev <igor@sysoev.ru>
parents:
3304
diff
changeset
|
1138 ngx_process = NGX_PROCESS_HELPER; |
f94e8ff65aa2
add NGX_PROCESS_HELPER process status
Igor Sysoev <igor@sysoev.ru>
parents:
3304
diff
changeset
|
1139 |
4917
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1140 ngx_close_listening_sockets(cycle); |
467 | 1141 |
4917
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1142 /* Set a moderate number of connections for a helper process. */ |
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1143 cycle->connection_n = 512; |
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1144 |
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1145 ngx_worker_process_init(cycle, -1); |
467 | 1146 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1147 ngx_memzero(&ev, sizeof(ngx_event_t)); |
3018 | 1148 ev.handler = ctx->handler; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1149 ev.data = ident; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1150 ev.log = cycle->log; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1151 ident[3] = (void *) -1; |
467 | 1152 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1153 ngx_use_accept_mutex = 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1154 |
3018 | 1155 ngx_setproctitle(ctx->name); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1156 |
3018 | 1157 ngx_add_timer(&ev, ctx->delay); |
467 | 1158 |
1159 for ( ;; ) { | |
1160 | |
1161 if (ngx_terminate || ngx_quit) { | |
477 | 1162 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting"); |
467 | 1163 exit(0); |
1164 } | |
1165 | |
1166 if (ngx_reopen) { | |
1167 ngx_reopen = 0; | |
477 | 1168 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs"); |
467 | 1169 ngx_reopen_files(cycle, -1); |
1170 } | |
1171 | |
563 | 1172 ngx_process_events_and_timers(cycle); |
467 | 1173 } |
1174 } | |
501 | 1175 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1176 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1177 static void |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
1178 ngx_cache_manager_process_handler(ngx_event_t *ev) |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1179 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1180 ngx_uint_t i; |
6727
ca709bca4b77
Cache: cache manager limits.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6651
diff
changeset
|
1181 ngx_msec_t next, n; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1182 ngx_path_t **path; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1183 |
6727
ca709bca4b77
Cache: cache manager limits.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6651
diff
changeset
|
1184 next = 60 * 60 * 1000; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1185 |
4870
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4864
diff
changeset
|
1186 path = ngx_cycle->paths.elts; |
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4864
diff
changeset
|
1187 for (i = 0; i < ngx_cycle->paths.nelts; i++) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1188 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
1189 if (path[i]->manager) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
1190 n = path[i]->manager(path[i]->data); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1191 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1192 next = (n <= next) ? n : next; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1193 |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
1194 ngx_time_update(); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1195 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1196 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1197 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1198 if (next == 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1199 next = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1200 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1201 |
6727
ca709bca4b77
Cache: cache manager limits.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6651
diff
changeset
|
1202 ngx_add_timer(ev, next); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1203 } |
3018 | 1204 |
1205 | |
1206 static void | |
1207 ngx_cache_loader_process_handler(ngx_event_t *ev) | |
1208 { | |
1209 ngx_uint_t i; | |
1210 ngx_path_t **path; | |
1211 ngx_cycle_t *cycle; | |
1212 | |
1213 cycle = (ngx_cycle_t *) ngx_cycle; | |
1214 | |
4870
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4864
diff
changeset
|
1215 path = cycle->paths.elts; |
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4864
diff
changeset
|
1216 for (i = 0; i < cycle->paths.nelts; i++) { |
3018 | 1217 |
1218 if (ngx_terminate || ngx_quit) { | |
1219 break; | |
1220 } | |
1221 | |
1222 if (path[i]->loader) { | |
1223 path[i]->loader(path[i]->data); | |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
1224 ngx_time_update(); |
3018 | 1225 } |
1226 } | |
1227 | |
1228 exit(0); | |
1229 } |