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