Mercurial > hg > nginx
annotate src/os/unix/ngx_process_cycle.c @ 8837:8f0f6407ae23 quic
QUIC: Stateless Reset Token debug logging cleanup.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 24 Aug 2021 14:41:31 +0300 |
parents | f2ff291bbdac |
children | b809f53d3f5b |
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); | |
7802
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
18 static void ngx_pass_open_channel(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
|
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 { |
7802
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
338 ngx_int_t i; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
339 |
477 | 340 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
|
341 |
577 | 342 for (i = 0; i < n; i++) { |
343 | |
4912
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
344 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
|
345 (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
|
346 |
7802
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
347 ngx_pass_open_channel(cycle); |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
348 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
349 } |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
350 |
360
239e37d44a34
nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
357
diff
changeset
|
351 |
501 | 352 static void |
3018 | 353 ngx_start_cache_manager_processes(ngx_cycle_t *cycle, ngx_uint_t respawn) |
467 | 354 { |
7802
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
355 ngx_uint_t i, manager, loader; |
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
356 ngx_path_t **path; |
467 | 357 |
3018 | 358 manager = 0; |
359 loader = 0; | |
360 | |
4870
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4864
diff
changeset
|
361 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
|
362 for (i = 0; i < ngx_cycle->paths.nelts; i++) { |
3018 | 363 |
364 if (path[i]->manager) { | |
365 manager = 1; | |
366 } | |
367 | |
368 if (path[i]->loader) { | |
369 loader = 1; | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
370 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
371 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
372 |
3018 | 373 if (manager == 0) { |
374 return; | |
375 } | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
376 |
3018 | 377 ngx_spawn_process(cycle, ngx_cache_manager_process_cycle, |
378 &ngx_cache_manager_ctx, "cache manager process", | |
379 respawn ? NGX_PROCESS_JUST_RESPAWN : NGX_PROCESS_RESPAWN); | |
467 | 380 |
7802
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
381 ngx_pass_open_channel(cycle); |
3018 | 382 |
383 if (loader == 0) { | |
384 return; | |
385 } | |
386 | |
387 ngx_spawn_process(cycle, ngx_cache_manager_process_cycle, | |
388 &ngx_cache_loader_ctx, "cache loader process", | |
389 respawn ? NGX_PROCESS_JUST_SPAWN : NGX_PROCESS_NORESPAWN); | |
390 | |
7802
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
391 ngx_pass_open_channel(cycle); |
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
392 } |
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
393 |
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
394 |
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
395 static void |
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
396 ngx_pass_open_channel(ngx_cycle_t *cycle) |
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
397 { |
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
398 ngx_int_t i; |
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
399 ngx_channel_t ch; |
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
400 |
7830
f2ff291bbdac
Restored zeroing of ngx_channel_t in ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7802
diff
changeset
|
401 ngx_memzero(&ch, sizeof(ngx_channel_t)); |
f2ff291bbdac
Restored zeroing of ngx_channel_t in ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7802
diff
changeset
|
402 |
3018 | 403 ch.command = NGX_CMD_OPEN_CHANNEL; |
404 ch.pid = ngx_processes[ngx_process_slot].pid; | |
405 ch.slot = ngx_process_slot; | |
406 ch.fd = ngx_processes[ngx_process_slot].channel[0]; | |
407 | |
467 | 408 for (i = 0; i < ngx_last_process; i++) { |
409 | |
410 if (i == ngx_process_slot | |
411 || ngx_processes[i].pid == -1 | |
412 || ngx_processes[i].channel[0] == -1) | |
413 { | |
414 continue; | |
415 } | |
416 | |
417 ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0, | |
6480 | 418 "pass channel s:%i pid:%P fd:%d to s:%i pid:%P fd:%d", |
7802
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
419 ch.slot, ch.pid, ch.fd, |
467 | 420 i, ngx_processes[i].pid, |
421 ngx_processes[i].channel[0]); | |
422 | |
423 /* TODO: NGX_AGAIN */ | |
424 | |
425 ngx_write_channel(ngx_processes[i].channel[0], | |
7802
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
426 &ch, sizeof(ngx_channel_t), cycle->log); |
467 | 427 } |
428 } | |
429 | |
430 | |
501 | 431 static void |
432 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
|
433 { |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
434 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
|
435 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
|
436 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
|
437 |
5245
711fa02afae8
Valgrind: supressed complaints about uninitialized bytes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5137
diff
changeset
|
438 ngx_memzero(&ch, sizeof(ngx_channel_t)); |
711fa02afae8
Valgrind: supressed complaints about uninitialized bytes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5137
diff
changeset
|
439 |
1581
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
440 #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
|
441 |
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
442 ch.command = 0; |
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
443 |
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
444 #else |
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
445 |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
446 switch (signo) { |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
447 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
448 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
|
449 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
|
450 break; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
451 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
452 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
|
453 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
|
454 break; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
455 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
456 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
|
457 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
|
458 break; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
459 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
460 default: |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
461 ch.command = 0; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
462 } |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
463 |
1581
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
464 #endif |
81774dc3db28
Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents:
1578
diff
changeset
|
465 |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
466 ch.fd = -1; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
467 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
468 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
469 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
|
470 |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
471 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
6480 | 472 "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
|
473 i, |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
474 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
|
475 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
|
476 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
|
477 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
|
478 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
|
479 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
|
480 |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
481 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
|
482 continue; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
483 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
484 |
3016
d82993af1da0
introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents:
2616
diff
changeset
|
485 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
|
486 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
|
487 continue; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
488 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
489 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
490 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
|
491 && 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
|
492 { |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
493 continue; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
494 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
495 |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
496 if (ch.command) { |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
497 if (ngx_write_channel(ngx_processes[i].channel[0], |
1132 | 498 &ch, sizeof(ngx_channel_t), cycle->log) |
499 == NGX_OK) | |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
500 { |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
501 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
|
502 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
|
503 } |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
504 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
505 continue; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
506 } |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
507 } |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
508 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
509 ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0, |
5266 | 510 "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
|
511 |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
512 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
|
513 err = ngx_errno; |
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
514 ngx_log_error(NGX_LOG_ALERT, cycle->log, err, |
3047 | 515 "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
|
516 |
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
517 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
|
518 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
|
519 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
|
520 ngx_reap = 1; |
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
521 } |
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
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 continue; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
524 } |
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 (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
|
527 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
|
528 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
529 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
530 } |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
531 |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
315
diff
changeset
|
532 |
501 | 533 static ngx_uint_t |
1565 | 534 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
|
535 { |
543 | 536 ngx_int_t i, n; |
537 ngx_uint_t live; | |
538 ngx_channel_t ch; | |
539 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
|
540 |
5245
711fa02afae8
Valgrind: supressed complaints about uninitialized bytes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5137
diff
changeset
|
541 ngx_memzero(&ch, sizeof(ngx_channel_t)); |
711fa02afae8
Valgrind: supressed complaints about uninitialized bytes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5137
diff
changeset
|
542 |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
543 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
|
544 ch.fd = -1; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
545 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
546 live = 0; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
547 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
|
548 |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
549 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
6480 | 550 "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
|
551 i, |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
552 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
|
553 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
|
554 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
|
555 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
|
556 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
|
557 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
|
558 |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
559 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
|
560 continue; |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
561 } |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
562 |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
563 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
|
564 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
565 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
|
566 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
|
567 |
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].channel[0] = -1; |
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].channel[1] = -1; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
570 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
571 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
|
572 ch.slot = i; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
573 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
574 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
|
575 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
|
576 || 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
|
577 || 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
|
578 { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
579 continue; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
580 } |
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_log_debug3(NGX_LOG_DEBUG_CORE, cycle->log, 0, |
461 | 583 "pass close channel s:%i pid:%P to:%P", |
584 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
|
585 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
586 /* TODO: NGX_AGAIN */ |
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 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
|
589 &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
|
590 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
591 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
592 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
593 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
|
594 && !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
|
595 && !ngx_terminate |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
596 && !ngx_quit) |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
597 { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
598 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
|
599 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
|
600 ngx_processes[i].name, i) |
543 | 601 == 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
|
602 { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
603 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
|
604 "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
|
605 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
|
606 continue; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
607 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
608 |
473 | 609 |
7802
0215ec9aaa8a
Removed "ch" argument from ngx_pass_open_channel().
Ruslan Ermilov <ru@nginx.com>
parents:
7663
diff
changeset
|
610 ngx_pass_open_channel(cycle); |
473 | 611 |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
612 live = 1; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
613 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
614 continue; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
615 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
616 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
617 if (ngx_processes[i].pid == ngx_new_binary) { |
543 | 618 |
619 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, | |
620 ngx_core_module); | |
621 | |
622 if (ngx_rename_file((char *) ccf->oldpid.data, | |
623 (char *) ccf->pid.data) | |
5137
f941cf265cc5
Use NGX_FILE_ERROR for handling file operations errors.
Valentin Bartenev <vbart@nginx.com>
parents:
4917
diff
changeset
|
624 == NGX_FILE_ERROR) |
543 | 625 { |
626 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
627 ngx_rename_file_n " %s back to %s failed " | |
628 "after the new binary process \"%s\" exited", | |
629 ccf->oldpid.data, ccf->pid.data, ngx_argv[0]); | |
630 } | |
631 | |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
632 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
|
633 if (ngx_noaccepting) { |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
634 ngx_restart = 1; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
635 ngx_noaccepting = 0; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
636 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
637 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
638 |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
639 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
|
640 ngx_last_process--; |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
641 |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
642 } else { |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
382
diff
changeset
|
643 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
|
644 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
645 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
646 } 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
|
647 live = 1; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
648 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
649 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
650 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
651 return live; |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
652 } |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
653 |
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
654 |
501 | 655 static void |
573 | 656 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
|
657 { |
571 | 658 ngx_uint_t i; |
659 | |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
309
diff
changeset
|
660 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
|
661 |
477 | 662 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
|
663 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
664 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
|
665 if (cycle->modules[i]->exit_master) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
666 cycle->modules[i]->exit_master(cycle); |
571 | 667 } |
668 } | |
669 | |
3230
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3048
diff
changeset
|
670 ngx_close_listening_sockets(cycle); |
a7491af45540
http listen unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3048
diff
changeset
|
671 |
505 | 672 /* |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
673 * 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
|
674 * 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
|
675 * 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
|
676 * ngx_cycle->pool is already destroyed. |
505 | 677 */ |
678 | |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
679 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5601
diff
changeset
|
680 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
|
681 |
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5601
diff
changeset
|
682 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
|
683 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
|
684 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
|
685 ngx_exit_log.writer = NULL; |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
686 |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
687 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
|
688 ngx_exit_cycle.files = ngx_cycle->files; |
626157fe6f17
Fixed segfault with poll and resolver used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4549
diff
changeset
|
689 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
|
690 ngx_cycle = &ngx_exit_cycle; |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
691 |
322
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
692 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
|
693 |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
694 exit(0); |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
695 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
696 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
697 |
501 | 698 static void |
699 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
|
700 { |
4912
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
701 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
|
702 |
3358
f94e8ff65aa2
add NGX_PROCESS_HELPER process status
Igor Sysoev <igor@sysoev.ru>
parents:
3304
diff
changeset
|
703 ngx_process = NGX_PROCESS_WORKER; |
6151
b4cc553aafeb
Introduced worker number, ngx_worker.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6127
diff
changeset
|
704 ngx_worker = worker; |
3358
f94e8ff65aa2
add NGX_PROCESS_HELPER process status
Igor Sysoev <igor@sysoev.ru>
parents:
3304
diff
changeset
|
705 |
4912
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
706 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
|
707 |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
708 ngx_setproctitle("worker process"); |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
709 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
710 for ( ;; ) { |
1135
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1134
diff
changeset
|
711 |
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1134
diff
changeset
|
712 if (ngx_exiting) { |
6929
3069dd358ba2
Cancelable timers are now preserved if there are other timers.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6727
diff
changeset
|
713 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
|
714 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
|
715 ngx_worker_process_exit(cycle); |
03f1133f24e8
close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents:
1134
diff
changeset
|
716 } |
322
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
717 } |
ab2f8c9a2a45
nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
718 |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
719 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
|
720 |
563 | 721 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
|
722 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
723 if (ngx_terminate) { |
477 | 724 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting"); |
573 | 725 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
|
726 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
727 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
728 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
|
729 ngx_quit = 0; |
477 | 730 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
|
731 "gracefully shutting down"); |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
732 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
|
733 |
326
8733703a37f3
nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
323
diff
changeset
|
734 if (!ngx_exiting) { |
6220
5e6142609e48
Core: idle connections now closed only once on exiting.
Valentin Bartenev <vbart@nginx.com>
parents:
6151
diff
changeset
|
735 ngx_exiting = 1; |
6930
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6929
diff
changeset
|
736 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
|
737 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
|
738 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
|
739 } |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
740 } |
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_reopen) { |
323
ba876b26b76d
nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
322
diff
changeset
|
743 ngx_reopen = 0; |
477 | 744 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
|
745 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
|
746 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
747 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
748 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
749 |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
750 |
501 | 751 static void |
4912
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
752 ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker) |
467 | 753 { |
1069 | 754 sigset_t set; |
755 ngx_int_t n; | |
6651
7d4e33092e2a
Always seed PRNG with PID, seconds, and milliseconds.
Ruslan Ermilov <ru@nginx.com>
parents:
6650
diff
changeset
|
756 ngx_time_t *tp; |
1069 | 757 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
|
758 ngx_cpuset_t *cpu_affinity; |
1069 | 759 struct rlimit rlmt; |
760 ngx_core_conf_t *ccf; | |
761 ngx_listening_t *ls; | |
467 | 762 |
1069 | 763 if (ngx_set_environment(cycle, NULL) == NULL) { |
764 /* fatal */ | |
765 exit(2); | |
766 } | |
767 | |
467 | 768 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
769 | |
4912
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
770 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
|
771 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
|
772 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
|
773 "setpriority(%d) failed", ccf->priority); |
473 | 774 } |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
775 } |
473 | 776 |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
777 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
|
778 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
|
779 rlmt.rlim_max = (rlim_t) ccf->rlimit_nofile; |
543 | 780 |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
781 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
|
782 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
|
783 "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
|
784 ccf->rlimit_nofile); |
543 | 785 } |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
786 } |
543 | 787 |
3762
89002ac695e5
worker_rlimit_core should be off_t
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
788 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
|
789 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
|
790 rlmt.rlim_max = (rlim_t) ccf->rlimit_core; |
589 | 791 |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
792 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
|
793 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
|
794 "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
|
795 ccf->rlimit_core); |
589 | 796 } |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
797 } |
589 | 798 |
1404
df2592d32e49
set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents:
1135
diff
changeset
|
799 if (geteuid() == 0) { |
467 | 800 if (setgid(ccf->group) == -1) { |
801 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
802 "setgid(%d) failed", ccf->group); | |
803 /* fatal */ | |
804 exit(2); | |
805 } | |
806 | |
473 | 807 if (initgroups(ccf->username, ccf->group) == -1) { |
808 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
809 "initgroups(%s, %d) failed", | |
810 ccf->username, ccf->group); | |
811 } | |
812 | |
7174
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
813 #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
|
814 if (ccf->transparent && ccf->user) { |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
815 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
|
816 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
|
817 "prctl(PR_SET_KEEPCAPS, 1) failed"); |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
818 /* fatal */ |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
819 exit(2); |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
820 } |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
821 } |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
822 #endif |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
823 |
467 | 824 if (setuid(ccf->user) == -1) { |
825 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
826 "setuid(%d) failed", ccf->user); | |
827 /* fatal */ | |
828 exit(2); | |
829 } | |
7174
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
830 |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
831 #if (NGX_HAVE_CAPABILITIES) |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
832 if (ccf->transparent && ccf->user) { |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
833 struct __user_cap_data_struct data; |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
834 struct __user_cap_header_struct header; |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
835 |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
836 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
|
837 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
|
838 |
7176
7f28b61c92f0
Fixed capabilities version.
Roman Arutyunyan <arut@nginx.com>
parents:
7175
diff
changeset
|
839 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
|
840 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
|
841 data.permitted = data.effective; |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
842 |
7175
56923e8e01a5
Improved the capabilities feature detection.
Roman Arutyunyan <arut@nginx.com>
parents:
7174
diff
changeset
|
843 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
|
844 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
|
845 "capset() failed"); |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
846 /* fatal */ |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
847 exit(2); |
84e53e4735a4
Retain CAP_NET_RAW capability for transparent proxying.
Roman Arutyunyan <arut@nginx.com>
parents:
7162
diff
changeset
|
848 } |
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 #endif |
467 | 851 } |
852 | |
4912
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
853 if (worker >= 0) { |
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
854 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
|
855 |
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
856 if (cpu_affinity) { |
e8ef31c58d43
Fixed setting of CPU affinity on respawn of dead worker processes.
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
857 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
|
858 } |
577 | 859 } |
860 | |
467 | 861 #if (NGX_HAVE_PR_SET_DUMPABLE) |
862 | |
863 /* allow coredump after setuid() in Linux 2.4.x */ | |
864 | |
865 if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) { | |
866 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
867 "prctl(PR_SET_DUMPABLE) failed"); | |
868 } | |
869 | |
870 #endif | |
871 | |
521 | 872 if (ccf->working_directory.len) { |
523 | 873 if (chdir((char *) ccf->working_directory.data) == -1) { |
521 | 874 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
875 "chdir(\"%s\") failed", ccf->working_directory.data); | |
876 /* fatal */ | |
877 exit(2); | |
878 } | |
879 } | |
880 | |
467 | 881 sigemptyset(&set); |
882 | |
883 if (sigprocmask(SIG_SETMASK, &set, NULL) == -1) { | |
884 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
885 "sigprocmask() failed"); | |
886 } | |
887 | |
6651
7d4e33092e2a
Always seed PRNG with PID, seconds, and milliseconds.
Ruslan Ermilov <ru@nginx.com>
parents:
6650
diff
changeset
|
888 tp = ngx_timeofday(); |
7d4e33092e2a
Always seed PRNG with PID, seconds, and milliseconds.
Ruslan Ermilov <ru@nginx.com>
parents:
6650
diff
changeset
|
889 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
|
890 |
467 | 891 /* |
892 * disable deleting previous events for the listening sockets because | |
893 * in the worker processes there are no events at all at this point | |
577 | 894 */ |
467 | 895 ls = cycle->listening.elts; |
896 for (i = 0; i < cycle->listening.nelts; i++) { | |
543 | 897 ls[i].previous = NULL; |
467 | 898 } |
899 | |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
900 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
|
901 if (cycle->modules[i]->init_process) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
902 if (cycle->modules[i]->init_process(cycle) == NGX_ERROR) { |
467 | 903 /* fatal */ |
904 exit(2); | |
905 } | |
906 } | |
907 } | |
908 | |
909 for (n = 0; n < ngx_last_process; n++) { | |
910 | |
911 if (ngx_processes[n].pid == -1) { | |
912 continue; | |
913 } | |
914 | |
915 if (n == ngx_process_slot) { | |
916 continue; | |
917 } | |
918 | |
919 if (ngx_processes[n].channel[1] == -1) { | |
920 continue; | |
921 } | |
922 | |
923 if (close(ngx_processes[n].channel[1]) == -1) { | |
924 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
925 "close() channel failed"); | |
926 } | |
927 } | |
928 | |
929 if (close(ngx_processes[ngx_process_slot].channel[0]) == -1) { | |
930 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
931 "close() channel failed"); | |
932 } | |
933 | |
934 #if 0 | |
935 ngx_last_process = 0; | |
936 #endif | |
937 | |
938 if (ngx_add_channel_event(cycle, ngx_channel, NGX_READ_EVENT, | |
1133 | 939 ngx_channel_handler) |
940 == NGX_ERROR) | |
467 | 941 { |
942 /* fatal */ | |
943 exit(2); | |
944 } | |
945 } | |
946 | |
947 | |
501 | 948 static void |
573 | 949 ngx_worker_process_exit(ngx_cycle_t *cycle) |
950 { | |
951 ngx_uint_t i; | |
952 ngx_connection_t *c; | |
953 | |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
954 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
|
955 if (cycle->modules[i]->exit_process) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6220
diff
changeset
|
956 cycle->modules[i]->exit_process(cycle); |
573 | 957 } |
958 } | |
959 | |
1905
0cafbfd8112e
left open sockets were not really tested
Igor Sysoev <igor@sysoev.ru>
parents:
1900
diff
changeset
|
960 if (ngx_exiting) { |
587 | 961 c = cycle->connections; |
962 for (i = 0; i < cycle->connection_n; i++) { | |
963 if (c[i].fd != -1 | |
964 && c[i].read | |
965 && !c[i].read->accept | |
1905
0cafbfd8112e
left open sockets were not really tested
Igor Sysoev <igor@sysoev.ru>
parents:
1900
diff
changeset
|
966 && !c[i].read->channel |
0cafbfd8112e
left open sockets were not really tested
Igor Sysoev <igor@sysoev.ru>
parents:
1900
diff
changeset
|
967 && !c[i].read->resolver) |
587 | 968 { |
969 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
|
970 "*%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
|
971 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
|
972 ngx_debug_quit = 1; |
587 | 973 } |
573 | 974 } |
975 | |
587 | 976 if (ngx_debug_quit) { |
3026
f4b5c787fe33
fix debug point for left open sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3019
diff
changeset
|
977 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, "aborting"); |
587 | 978 ngx_debug_point(); |
979 } | |
573 | 980 } |
981 | |
982 /* | |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
983 * 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
|
984 * 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
|
985 * 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
|
986 * ngx_cycle->pool is already destroyed. |
573 | 987 */ |
988 | |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5601
diff
changeset
|
989 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
|
990 |
5702
777202558122
Added syslog support for error_log and access_log directives.
Vladimir Homutov <vl@nginx.com>
parents:
5601
diff
changeset
|
991 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
|
992 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
|
993 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
|
994 ngx_exit_log.writer = NULL; |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
995 |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
996 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
|
997 ngx_exit_cycle.files = ngx_cycle->files; |
626157fe6f17
Fixed segfault with poll and resolver used.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4549
diff
changeset
|
998 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
|
999 ngx_cycle = &ngx_exit_cycle; |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1000 |
573 | 1001 ngx_destroy_pool(cycle->pool); |
1437
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1002 |
e498f4cb1663
destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents:
1404
diff
changeset
|
1003 ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0, "exit"); |
573 | 1004 |
1005 exit(0); | |
1006 } | |
1007 | |
1008 | |
1009 static void | |
501 | 1010 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
|
1011 { |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1012 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
|
1013 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
|
1014 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
|
1015 |
467 | 1016 if (ev->timedout) { |
1017 ev->timedout = 0; | |
1018 return; | |
1019 } | |
1020 | |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1021 c = ev->data; |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1022 |
357
e260514b9ad4
nginx-0.0.7-2004-06-16-23:36:07 import
Igor Sysoev <igor@sysoev.ru>
parents:
355
diff
changeset
|
1023 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
|
1024 |
2031 | 1025 for ( ;; ) { |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1026 |
2031 | 1027 n = ngx_read_channel(c->fd, &ch, sizeof(ngx_channel_t), ev->log); |
1028 | |
1029 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
|
1030 |
2031 | 1031 if (n == NGX_ERROR) { |
1900
55a9d867e3c8
avoid endless loop if epoll is used
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
1032 |
2031 | 1033 if (ngx_event_flags & NGX_USE_EPOLL_EVENT) { |
1034 ngx_del_conn(c, 0); | |
1035 } | |
1036 | |
1037 ngx_close_connection(c); | |
1038 return; | |
1900
55a9d867e3c8
avoid endless loop if epoll is used
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
1039 } |
55a9d867e3c8
avoid endless loop if epoll is used
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
1040 |
2031 | 1041 if (ngx_event_flags & NGX_USE_EVENTPORT_EVENT) { |
1042 if (ngx_add_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) { | |
1043 return; | |
1044 } | |
1045 } | |
461 | 1046 |
2031 | 1047 if (n == NGX_AGAIN) { |
1134
384c92c210f9
worker processes did not exit after reconfiguration and
Igor Sysoev <igor@sysoev.ru>
parents:
1133
diff
changeset
|
1048 return; |
384c92c210f9
worker processes did not exit after reconfiguration and
Igor Sysoev <igor@sysoev.ru>
parents:
1133
diff
changeset
|
1049 } |
2031 | 1050 |
1051 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, | |
6480 | 1052 "channel command: %ui", ch.command); |
1134
384c92c210f9
worker processes did not exit after reconfiguration and
Igor Sysoev <igor@sysoev.ru>
parents:
1133
diff
changeset
|
1053 |
2031 | 1054 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
|
1055 |
2031 | 1056 case NGX_CMD_QUIT: |
1057 ngx_quit = 1; | |
1058 break; | |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1059 |
2031 | 1060 case NGX_CMD_TERMINATE: |
1061 ngx_terminate = 1; | |
1062 break; | |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1063 |
2031 | 1064 case NGX_CMD_REOPEN: |
1065 ngx_reopen = 1; | |
1066 break; | |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1067 |
2031 | 1068 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
|
1069 |
2031 | 1070 ngx_log_debug3(NGX_LOG_DEBUG_CORE, ev->log, 0, |
1071 "get channel s:%i pid:%P fd:%d", | |
1072 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
|
1073 |
2031 | 1074 ngx_processes[ch.slot].pid = ch.pid; |
1075 ngx_processes[ch.slot].channel[0] = ch.fd; | |
1076 break; | |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
1077 |
2031 | 1078 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
|
1079 |
2031 | 1080 ngx_log_debug4(NGX_LOG_DEBUG_CORE, ev->log, 0, |
1081 "close channel s:%i pid:%P our:%P fd:%d", | |
1082 ch.slot, ch.pid, ngx_processes[ch.slot].pid, | |
1083 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
|
1084 |
2031 | 1085 if (close(ngx_processes[ch.slot].channel[0]) == -1) { |
1086 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno, | |
1087 "close() channel failed"); | |
1088 } | |
1089 | |
1090 ngx_processes[ch.slot].channel[0] = -1; | |
1091 break; | |
365
fd24ba70e1b3
nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
362
diff
changeset
|
1092 } |
354
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1093 } |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1094 } |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1095 |
eaf1f651cf86
nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents:
345
diff
changeset
|
1096 |
501 | 1097 static void |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
1098 ngx_cache_manager_process_cycle(ngx_cycle_t *cycle, void *data) |
467 | 1099 { |
3018 | 1100 ngx_cache_manager_ctx_t *ctx = data; |
1101 | |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1102 void *ident[4]; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1103 ngx_event_t ev; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1104 |
4917
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1105 /* |
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1106 * 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
|
1107 * 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
|
1108 */ |
3358
f94e8ff65aa2
add NGX_PROCESS_HELPER process status
Igor Sysoev <igor@sysoev.ru>
parents:
3304
diff
changeset
|
1109 ngx_process = NGX_PROCESS_HELPER; |
f94e8ff65aa2
add NGX_PROCESS_HELPER process status
Igor Sysoev <igor@sysoev.ru>
parents:
3304
diff
changeset
|
1110 |
4917
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1111 ngx_close_listening_sockets(cycle); |
467 | 1112 |
4917
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1113 /* 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
|
1114 cycle->connection_n = 512; |
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1115 |
484aec758d2c
Fixed failure to start cache manager and cache loader processes
Igor Sysoev <igor@sysoev.ru>
parents:
4912
diff
changeset
|
1116 ngx_worker_process_init(cycle, -1); |
467 | 1117 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1118 ngx_memzero(&ev, sizeof(ngx_event_t)); |
3018 | 1119 ev.handler = ctx->handler; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1120 ev.data = ident; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1121 ev.log = cycle->log; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1122 ident[3] = (void *) -1; |
467 | 1123 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1124 ngx_use_accept_mutex = 0; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1125 |
3018 | 1126 ngx_setproctitle(ctx->name); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1127 |
3018 | 1128 ngx_add_timer(&ev, ctx->delay); |
467 | 1129 |
1130 for ( ;; ) { | |
1131 | |
1132 if (ngx_terminate || ngx_quit) { | |
477 | 1133 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting"); |
467 | 1134 exit(0); |
1135 } | |
1136 | |
1137 if (ngx_reopen) { | |
1138 ngx_reopen = 0; | |
477 | 1139 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs"); |
467 | 1140 ngx_reopen_files(cycle, -1); |
1141 } | |
1142 | |
563 | 1143 ngx_process_events_and_timers(cycle); |
467 | 1144 } |
1145 } | |
501 | 1146 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1147 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1148 static void |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
1149 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
|
1150 { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1151 ngx_uint_t i; |
6727
ca709bca4b77
Cache: cache manager limits.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6651
diff
changeset
|
1152 ngx_msec_t next, n; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1153 ngx_path_t **path; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1154 |
6727
ca709bca4b77
Cache: cache manager limits.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6651
diff
changeset
|
1155 next = 60 * 60 * 1000; |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1156 |
4870
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4864
diff
changeset
|
1157 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
|
1158 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
|
1159 |
2616
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
1160 if (path[i]->manager) { |
d19979e0d980
introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents:
2592
diff
changeset
|
1161 n = path[i]->manager(path[i]->data); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1162 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1163 next = (n <= next) ? n : next; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1164 |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
1165 ngx_time_update(); |
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 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1168 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1169 if (next == 0) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1170 next = 1; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1171 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1172 |
6727
ca709bca4b77
Cache: cache manager limits.
Dmitry Volyntsev <xeioex@nginx.com>
parents:
6651
diff
changeset
|
1173 ngx_add_timer(ev, next); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2522
diff
changeset
|
1174 } |
3018 | 1175 |
1176 | |
1177 static void | |
1178 ngx_cache_loader_process_handler(ngx_event_t *ev) | |
1179 { | |
1180 ngx_uint_t i; | |
1181 ngx_path_t **path; | |
1182 ngx_cycle_t *cycle; | |
1183 | |
1184 cycle = (ngx_cycle_t *) ngx_cycle; | |
1185 | |
4870
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4864
diff
changeset
|
1186 path = cycle->paths.elts; |
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4864
diff
changeset
|
1187 for (i = 0; i < cycle->paths.nelts; i++) { |
3018 | 1188 |
1189 if (ngx_terminate || ngx_quit) { | |
1190 break; | |
1191 } | |
1192 | |
1193 if (path[i]->loader) { | |
1194 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
|
1195 ngx_time_update(); |
3018 | 1196 } |
1197 } | |
1198 | |
1199 exit(0); | |
1200 } |