annotate src/os/unix/ngx_process_cycle.c @ 3048:846d0e2fa483

twice termination delay only after SIGALRM, otherwise many separate SIGCHLD and SIGIO signals quickly increase delay to the level when SIGKILL is sent
author Igor Sysoev <igor@sysoev.ru>
date Wed, 26 Aug 2009 15:12:28 +0000
parents d02b6123b4dc
children a7491af45540
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
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
4 */
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
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
6
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
7 #include <ngx_config.h>
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 #include <ngx_core.h>
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 #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
10 #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
11
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
12
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
13 static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n,
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
14 ngx_int_t type);
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
15 static void ngx_start_cache_manager_processes(ngx_cycle_t *cycle,
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
16 ngx_uint_t respawn);
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
17 static void ngx_pass_open_channel(ngx_cycle_t *cycle, ngx_channel_t *ch);
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
18 static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo);
1565
4c43e25d11ea fix English grammar
Igor Sysoev <igor@sysoev.ru>
parents: 1437
diff changeset
19 static ngx_uint_t ngx_reap_children(ngx_cycle_t *cycle);
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
20 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
21 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
22 static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority);
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
23 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
24 static void ngx_channel_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
25 #if (NGX_THREADS)
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
26 static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle);
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
27 static ngx_thread_value_t ngx_worker_thread_cycle(void *data);
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
28 #endif
2616
d19979e0d980 introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents: 2592
diff changeset
29 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
30 static void ngx_cache_manager_process_handler(ngx_event_t *ev);
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
31 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
32
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
33
326
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
34 ngx_uint_t ngx_process;
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
35 ngx_pid_t ngx_pid;
326
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
36 ngx_uint_t ngx_threaded;
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
37
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
38 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
39 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
40 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
41 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
42 sig_atomic_t ngx_quit;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
43 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
44 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
45 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
46 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
47
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
48 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
49 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
50 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
51 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
52
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
53 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
54 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
55 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
56
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
57
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
58 #if (NGX_THREADS)
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
59 volatile ngx_thread_t ngx_threads[NGX_MAX_THREADS];
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
60 ngx_int_t ngx_threads_n;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
61 #endif
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
62
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
63
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
64 u_long cpu_affinity;
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
65 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
66
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
67
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
68 static ngx_cache_manager_ctx_t ngx_cache_manager_ctx = {
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
69 ngx_cache_manager_process_handler, "cache manager process", 0
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
70 };
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
71
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
72 static ngx_cache_manager_ctx_t ngx_cache_loader_ctx = {
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
73 ngx_cache_loader_process_handler, "cache loader process", 60000
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
74 };
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
75
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
76
1437
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
77 static ngx_cycle_t ngx_exit_cycle;
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
78 static ngx_log_t ngx_exit_log;
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
79 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
80
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
81
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
82 void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
83 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
84 {
329
9a0ffa21f193 nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 327
diff changeset
85 char *title;
9a0ffa21f193 nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 327
diff changeset
86 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
87 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
88 ngx_int_t i;
531
c3bd8cdabb8f nginx-0.1.40-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 523
diff changeset
89 ngx_uint_t n;
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
90 sigset_t set;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
91 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
92 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
93 ngx_msec_t delay;
531
c3bd8cdabb8f nginx-0.1.40-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 523
diff changeset
94 ngx_listening_t *ls;
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
95 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
96
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
97 sigemptyset(&set);
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
98 sigaddset(&set, SIGCHLD);
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
99 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
100 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
101 sigaddset(&set, SIGINT);
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
102 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
103 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
104 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
105 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
106 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
107 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
108
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
109 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
110 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
111 "sigprocmask() failed");
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
112 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
113
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
114 sigemptyset(&set);
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
115
326
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
116
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
117 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
118
452
23fb87bddda1 nginx-0.1.1-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 449
diff changeset
119 for (i = 0; i < ngx_argc; i++) {
23fb87bddda1 nginx-0.1.1-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 449
diff changeset
120 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
121 }
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
122
2049
2a92804f4109 *) back out r2040
Igor Sysoev <igor@sysoev.ru>
parents: 2031
diff changeset
123 title = ngx_pnalloc(cycle->pool, size);
326
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
124
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
125 p = ngx_cpymem(title, master_process, sizeof(master_process) - 1);
452
23fb87bddda1 nginx-0.1.1-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 449
diff changeset
126 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
127 *p++ = ' ';
452
23fb87bddda1 nginx-0.1.1-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 449
diff changeset
128 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
129 }
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
130
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
131 ngx_setproctitle(title);
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
132
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 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
135
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
136 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
137 NGX_PROCESS_RESPAWN);
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
138 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
139
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
140 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
141 delay = 0;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
142 live = 1;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
143
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
144 for ( ;; ) {
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
145 if (delay) {
3048
846d0e2fa483 twice termination delay only after SIGALRM, otherwise many separate SIGCHLD
Igor Sysoev <igor@sysoev.ru>
parents: 3047
diff changeset
146 if (ngx_sigalrm) {
846d0e2fa483 twice termination delay only after SIGALRM, otherwise many separate SIGCHLD
Igor Sysoev <igor@sysoev.ru>
parents: 3047
diff changeset
147 delay *= 2;
846d0e2fa483 twice termination delay only after SIGALRM, otherwise many separate SIGCHLD
Igor Sysoev <igor@sysoev.ru>
parents: 3047
diff changeset
148 ngx_sigalrm = 0;
846d0e2fa483 twice termination delay only after SIGALRM, otherwise many separate SIGCHLD
Igor Sysoev <igor@sysoev.ru>
parents: 3047
diff changeset
149 }
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
150
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
151 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
3046
52e984126b2c fix typo
Igor Sysoev <igor@sysoev.ru>
parents: 3035
diff changeset
152 "termination cycle: %d", delay);
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
153
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
154 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
155 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
156 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
157 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
158
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
159 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
160 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
161 "setitimer() failed");
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 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
164
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
165 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
166
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
167 sigsuspend(&set);
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
168
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
169 ngx_time_update(0, 0);
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
170
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
171 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "wake up");
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
172
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
173 if (ngx_reap) {
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
174 ngx_reap = 0;
1565
4c43e25d11ea fix English grammar
Igor Sysoev <igor@sysoev.ru>
parents: 1437
diff changeset
175 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
176
1565
4c43e25d11ea fix English grammar
Igor Sysoev <igor@sysoev.ru>
parents: 1437
diff changeset
177 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
178 }
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 if (!live && (ngx_terminate || ngx_quit)) {
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
181 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
182 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
183
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
184 if (ngx_terminate) {
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
185 if (delay == 0) {
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
186 delay = 50;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
187 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
188
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
189 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
190 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
191 } else {
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
192 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
193 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
194 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
195
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
196 continue;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
197 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
198
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
199 if (ngx_quit) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
200 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
201 ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
531
c3bd8cdabb8f nginx-0.1.40-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 523
diff changeset
202
c3bd8cdabb8f nginx-0.1.40-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 523
diff changeset
203 ls = cycle->listening.elts;
c3bd8cdabb8f nginx-0.1.40-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 523
diff changeset
204 for (n = 0; n < cycle->listening.nelts; n++) {
c3bd8cdabb8f nginx-0.1.40-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 523
diff changeset
205 if (ngx_close_socket(ls[n].fd) == -1) {
c3bd8cdabb8f nginx-0.1.40-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 523
diff changeset
206 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
c3bd8cdabb8f nginx-0.1.40-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 523
diff changeset
207 ngx_close_socket_n " %V failed",
c3bd8cdabb8f nginx-0.1.40-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 523
diff changeset
208 &ls[n].addr_text);
c3bd8cdabb8f nginx-0.1.40-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 523
diff changeset
209 }
c3bd8cdabb8f nginx-0.1.40-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 523
diff changeset
210 }
c3bd8cdabb8f nginx-0.1.40-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 523
diff changeset
211 cycle->listening.nelts = 0;
c3bd8cdabb8f nginx-0.1.40-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 523
diff changeset
212
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
213 continue;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
214 }
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
215
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
216 if (ngx_reconfigure) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
217 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
218
9a0ffa21f193 nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 327
diff changeset
219 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
220 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
221 NGX_PROCESS_RESPAWN);
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
222 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
223 ngx_noaccepting = 0;
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 448
diff changeset
224
329
9a0ffa21f193 nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 327
diff changeset
225 continue;
9a0ffa21f193 nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 327
diff changeset
226 }
9a0ffa21f193 nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 327
diff changeset
227
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
228 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
229
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
230 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
231 if (cycle == NULL) {
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
232 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
233 continue;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
234 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
235
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
236 ngx_cycle = cycle;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
237 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
238 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
239 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
240 NGX_PROCESS_JUST_RESPAWN);
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
241 ngx_start_cache_manager_processes(cycle, 1);
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
242 live = 1;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
243 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
244 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
245 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
246
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
247 if (ngx_restart) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
248 ngx_restart = 0;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
249 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
250 NGX_PROCESS_RESPAWN);
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
251 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
252 live = 1;
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
253 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
254
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
255 if (ngx_reopen) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
256 ngx_reopen = 0;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
257 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
258 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
259 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
260 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
261 }
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
262
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
263 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
264 ngx_change_binary = 0;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
265 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "changing binary");
452
23fb87bddda1 nginx-0.1.1-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 449
diff changeset
266 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
267 }
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
268
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
269 if (ngx_noaccept) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
270 ngx_noaccept = 0;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
271 ngx_noaccepting = 1;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
272 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
273 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
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
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
278
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
279 void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
280 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
281 {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
282 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
283
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
284 for (i = 0; ngx_modules[i]; i++) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
285 if (ngx_modules[i]->init_process) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
286 if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
287 /* fatal */
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
288 exit(2);
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
289 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
290 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
291 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
292
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
293 for ( ;; ) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
294 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
295
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
296 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
297
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
298 if (ngx_terminate || ngx_quit) {
571
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
299
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
300 for (i = 0; ngx_modules[i]; i++) {
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
301 if (ngx_modules[i]->exit_process) {
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
302 ngx_modules[i]->exit_process(cycle);
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
303 }
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
304 }
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
305
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
306 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
307 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
308
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
309 if (ngx_reconfigure) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
310 ngx_reconfigure = 0;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
311 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
312
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
313 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
314 if (cycle == NULL) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
315 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
316 continue;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
317 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
319 ngx_cycle = cycle;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
320 }
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 if (ngx_reopen) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
323 ngx_reopen = 0;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
324 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
325 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
326 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
327 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
328 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
329
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
330
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
331 static void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
332 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
333 {
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
334 ngx_int_t i;
557
ecd9c160f25b nginx-0.3.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 543
diff changeset
335 ngx_channel_t ch;
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
336
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
337 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
338
360
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
339 ch.command = NGX_CMD_OPEN_CHANNEL;
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
340
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
341 for (i = 0; i < n; i++) {
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
342
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
343 cpu_affinity = ngx_get_cpu_affinity(i);
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
344
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
345 ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL,
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
346 "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
347
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
348 ch.pid = ngx_processes[ngx_process_slot].pid;
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
349 ch.slot = ngx_process_slot;
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
350 ch.fd = ngx_processes[ngx_process_slot].channel[0];
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
351
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
352 ngx_pass_open_channel(cycle, &ch);
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
353 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
354 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
355
360
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
356
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
357 static void
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
358 ngx_start_cache_manager_processes(ngx_cycle_t *cycle, ngx_uint_t respawn)
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
359 {
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
360 ngx_uint_t i, manager, loader;
2592
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
361 ngx_path_t **path;
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
362 ngx_channel_t ch;
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
363
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
364 manager = 0;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
365 loader = 0;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
366
2592
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
367 path = ngx_cycle->pathes.elts;
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
368 for (i = 0; i < ngx_cycle->pathes.nelts; i++) {
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
369
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
370 if (path[i]->manager) {
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
371 manager = 1;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
372 }
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
373
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
374 if (path[i]->loader) {
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
375 loader = 1;
2592
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
376 }
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
377 }
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
378
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
379 if (manager == 0) {
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
380 return;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
381 }
2592
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
382
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
383 ngx_spawn_process(cycle, ngx_cache_manager_process_cycle,
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
384 &ngx_cache_manager_ctx, "cache manager process",
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
385 respawn ? NGX_PROCESS_JUST_RESPAWN : NGX_PROCESS_RESPAWN);
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
386
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
387 ch.command = NGX_CMD_OPEN_CHANNEL;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
388 ch.pid = ngx_processes[ngx_process_slot].pid;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
389 ch.slot = ngx_process_slot;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
390 ch.fd = ngx_processes[ngx_process_slot].channel[0];
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
391
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
392 ngx_pass_open_channel(cycle, &ch);
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
393
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
394 if (loader == 0) {
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
395 return;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
396 }
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
397
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
398 ngx_spawn_process(cycle, ngx_cache_manager_process_cycle,
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
399 &ngx_cache_loader_ctx, "cache loader process",
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
400 respawn ? NGX_PROCESS_JUST_SPAWN : NGX_PROCESS_NORESPAWN);
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
401
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
402 ch.command = NGX_CMD_OPEN_CHANNEL;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
403 ch.pid = ngx_processes[ngx_process_slot].pid;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
404 ch.slot = ngx_process_slot;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
405 ch.fd = ngx_processes[ngx_process_slot].channel[0];
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
406
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
407 ngx_pass_open_channel(cycle, &ch);
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
408 }
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
409
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
410
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
411 static void
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
412 ngx_pass_open_channel(ngx_cycle_t *cycle, ngx_channel_t *ch)
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
413 {
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
414 ngx_int_t i;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
415
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
416 for (i = 0; i < ngx_last_process; i++) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
417
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
418 if (i == ngx_process_slot
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
419 || ngx_processes[i].pid == -1
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
420 || ngx_processes[i].channel[0] == -1)
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
421 {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
422 continue;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
423 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
424
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
425 ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0,
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
426 "pass channel s:%d pid:%P fd:%d to s:%i pid:%P fd:%d",
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
427 ch->slot, ch->pid, ch->fd,
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
428 i, ngx_processes[i].pid,
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
429 ngx_processes[i].channel[0]);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
430
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
431 /* TODO: NGX_AGAIN */
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
432
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
433 ngx_write_channel(ngx_processes[i].channel[0],
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
434 ch, sizeof(ngx_channel_t), cycle->log);
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
435 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
436 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
437
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
438
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
439 static void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
440 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
441 {
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
442 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
443 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
444 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
445
1581
81774dc3db28 Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents: 1578
diff changeset
446 #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
447
81774dc3db28 Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents: 1578
diff changeset
448 ch.command = 0;
81774dc3db28 Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents: 1578
diff changeset
449
81774dc3db28 Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents: 1578
diff changeset
450 #else
81774dc3db28 Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents: 1578
diff changeset
451
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
452 switch (signo) {
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
453
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
454 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
455 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
456 break;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
457
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
458 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
459 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
460 break;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
461
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
462 case ngx_signal_value(NGX_REOPEN_SIGNAL):
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
463 ch.command = NGX_CMD_REOPEN;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
464 break;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
465
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
466 default:
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
467 ch.command = 0;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
468 }
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
469
1581
81774dc3db28 Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents: 1578
diff changeset
470 #endif
81774dc3db28 Cygwin can not pass SCM_RIGHTS via unix socket, use signals
Igor Sysoev <igor@sysoev.ru>
parents: 1578
diff changeset
471
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
472 ch.fd = -1;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
473
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
474
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
475 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
476
449
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 448
diff changeset
477 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
478 "child: %d %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
479 i,
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 448
diff changeset
480 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
481 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
482 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
483 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
484 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
485 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
486
389
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
487 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
488 continue;
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
3016
d82993af1da0 introduce NGX_PROCESS_JUST_SPAWN and change field name accordingly
Igor Sysoev <igor@sysoev.ru>
parents: 2616
diff changeset
491 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
492 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
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
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
496 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
497 && 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
498 {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
499 continue;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
500 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
501
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
502 if (ch.command) {
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
503 if (ngx_write_channel(ngx_processes[i].channel[0],
1132
4576627269ab style fix
Igor Sysoev <igor@sysoev.ru>
parents: 1069
diff changeset
504 &ch, sizeof(ngx_channel_t), cycle->log)
4576627269ab style fix
Igor Sysoev <igor@sysoev.ru>
parents: 1069
diff changeset
505 == NGX_OK)
354
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 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
508 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
509 }
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
510
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
511 continue;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
512 }
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
513 }
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
514
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
515 ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0,
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
516 "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
517
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
518 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
519 err = ngx_errno;
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
520 ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
3047
d02b6123b4dc style fix
Igor Sysoev <igor@sysoev.ru>
parents: 3046
diff changeset
521 "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
522
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
523 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
524 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
525 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
526 ngx_reap = 1;
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
527 }
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
528
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
529 continue;
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
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
532 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
533 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
534 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
535 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
536 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
537
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
538
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
539 static ngx_uint_t
1565
4c43e25d11ea fix English grammar
Igor Sysoev <igor@sysoev.ru>
parents: 1437
diff changeset
540 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
541 {
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
542 ngx_int_t i, n;
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
543 ngx_uint_t live;
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
544 ngx_channel_t ch;
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
545 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
546
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
547 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
548 ch.fd = -1;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
549
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
550 live = 0;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
551 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
552
389
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
553 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
554 "child: %d %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
555 i,
365
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].pid,
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
557 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
558 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
559 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
560 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
561 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
562
389
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
563 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
564 continue;
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
565 }
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
566
365
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
567 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
568
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
569 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
570 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
571
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
572 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
573 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
574
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
575 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
576 ch.slot = i;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
577
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
578 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
579 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
580 || 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
581 || 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
582 {
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
583 continue;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
584 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
585
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
586 ngx_log_debug3(NGX_LOG_DEBUG_CORE, cycle->log, 0,
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
587 "pass close channel s:%i pid:%P to:%P",
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
588 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
589
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
590 /* TODO: NGX_AGAIN */
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
591
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
592 ngx_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
593 &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
594 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
595 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
596
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
597 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
598 && !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
599 && !ngx_terminate
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
600 && !ngx_quit)
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
601 {
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
602 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
603 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
604 ngx_processes[i].name, i)
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
605 == 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
606 {
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
607 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
608 "can not respawn %s", ngx_processes[i].name);
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
609 continue;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
610 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
611
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
612
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
613 ch.command = NGX_CMD_OPEN_CHANNEL;
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
614 ch.pid = ngx_processes[ngx_process_slot].pid;
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
615 ch.slot = ngx_process_slot;
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
616 ch.fd = ngx_processes[ngx_process_slot].channel[0];
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
617
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
618 ngx_pass_open_channel(cycle, &ch);
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
619
365
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
620 live = 1;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
621
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
622 continue;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
623 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
624
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
625 if (ngx_processes[i].pid == ngx_new_binary) {
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
626
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
627 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx,
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
628 ngx_core_module);
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
629
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
630 if (ngx_rename_file((char *) ccf->oldpid.data,
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
631 (char *) ccf->pid.data)
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
632 != NGX_OK)
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
633 {
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
634 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
635 ngx_rename_file_n " %s back to %s failed "
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
636 "after the new binary process \"%s\" exited",
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
637 ccf->oldpid.data, ccf->pid.data, ngx_argv[0]);
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
638 }
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
639
365
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
640 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
641 if (ngx_noaccepting) {
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
642 ngx_restart = 1;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
643 ngx_noaccepting = 0;
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
389
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
647 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
648 ngx_last_process--;
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
649
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
650 } else {
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
651 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
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 } 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
655 live = 1;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
656 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
657 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
658
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
659 return live;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
660 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
661
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
662
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
663 static void
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
664 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
665 {
571
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
666 ngx_uint_t i;
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
667
310
a9a9af2c7370 nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents: 309
diff changeset
668 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
669
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
670 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
671
571
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
672 for (i = 0; ngx_modules[i]; i++) {
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
673 if (ngx_modules[i]->exit_master) {
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
674 ngx_modules[i]->exit_master(cycle);
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
675 }
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
676 }
458b6c3fea65 nginx-0.3.7-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 563
diff changeset
677
505
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
678 /*
1437
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
679 * 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
680 * 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
681 * 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
682 * ngx_cycle->pool is already destroyed.
505
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
683 */
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
684
1437
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
685 ngx_exit_log_file.fd = ngx_cycle->log->file->fd;
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_log = *ngx_cycle->log;
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
688 ngx_exit_log.file = &ngx_exit_log_file;
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
689
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
690 ngx_exit_cycle.log = &ngx_exit_log;
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
691 ngx_cycle = &ngx_exit_cycle;
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
692
322
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
693 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
694
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
695 exit(0);
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
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
698
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
699 static void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
700 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
701 {
1135
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
702 ngx_uint_t i;
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
703 ngx_connection_t *c;
469
2ff194b74f1e nginx-0.1.9-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
704
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
705 ngx_worker_process_init(cycle, 1);
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
706
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
707 ngx_setproctitle("worker process");
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
708
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
709 #if (NGX_THREADS)
1704
e584e946e198 move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents: 1581
diff changeset
710 {
e584e946e198 move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents: 1581
diff changeset
711 ngx_int_t n;
e584e946e198 move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents: 1581
diff changeset
712 ngx_err_t err;
e584e946e198 move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents: 1581
diff changeset
713 ngx_core_conf_t *ccf;
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
714
469
2ff194b74f1e nginx-0.1.9-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
715 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
2ff194b74f1e nginx-0.1.9-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
716
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
717 if (ngx_threads_n) {
1133
d5c1c84b7904 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 1132
diff changeset
718 if (ngx_init_threads(ngx_threads_n, ccf->thread_stack_size, cycle)
d5c1c84b7904 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 1132
diff changeset
719 == NGX_ERROR)
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
720 {
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
721 /* fatal */
279
b79f021a644a nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 278
diff changeset
722 exit(2);
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
723 }
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
724
381
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
725 err = ngx_thread_key_create(&ngx_core_tls_key);
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
726 if (err != 0) {
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
727 ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
728 ngx_thread_key_create_n " failed");
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
729 /* fatal */
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
730 exit(2);
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
731 }
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
732
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
733 for (n = 0; n < ngx_threads_n; n++) {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
734
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
735 ngx_threads[n].cv = ngx_cond_init(cycle->log);
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
736
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
737 if (ngx_threads[n].cv == NULL) {
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
738 /* fatal */
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
739 exit(2);
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
740 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
741
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
742 if (ngx_create_thread((ngx_tid_t *) &ngx_threads[n].tid,
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
743 ngx_worker_thread_cycle,
1133
d5c1c84b7904 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 1132
diff changeset
744 (void *) &ngx_threads[n], cycle->log)
d5c1c84b7904 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 1132
diff changeset
745 != 0)
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
746 {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
747 /* fatal */
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
748 exit(2);
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
749 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
750 }
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
751 }
1704
e584e946e198 move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents: 1581
diff changeset
752 }
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
753 #endif
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
754
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
755 for ( ;; ) {
1135
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
756
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
757 if (ngx_exiting) {
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
758
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
759 c = cycle->connections;
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
760
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
761 for (i = 0; i < cycle->connection_n; i++) {
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
762
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
763 /* THREAD: lock */
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
764
1135
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
765 if (c[i].fd != -1 && c[i].idle) {
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
766 c[i].close = 1;
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
767 c[i].read->handler(c[i].read);
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
768 }
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
769 }
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
770
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
771 if (ngx_event_timer_rbtree.root == ngx_event_timer_rbtree.sentinel)
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
772 {
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
773 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
774
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
775 ngx_worker_process_exit(cycle);
03f1133f24e8 close keep-alive connections in the shuting down processes
Igor Sysoev <igor@sysoev.ru>
parents: 1134
diff changeset
776 }
322
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
777 }
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
778
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
779 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
780
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
781 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
782
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
783 if (ngx_terminate) {
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
784 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
785
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
786 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
787 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
788
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
789 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
790 ngx_quit = 0;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
791 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
792 "gracefully shutting down");
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
793 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
794
326
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
795 if (!ngx_exiting) {
322
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
796 ngx_close_listening_sockets(cycle);
326
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
797 ngx_exiting = 1;
322
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
798 }
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
799 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
800
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
801 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
802 ngx_reopen = 0;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
803 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
804 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
805 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
806 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
807 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
808
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
809
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
810 static void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
811 ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
812 {
1069
Igor Sysoev <igor@sysoev.ru>
parents: 949
diff changeset
813 sigset_t set;
Igor Sysoev <igor@sysoev.ru>
parents: 949
diff changeset
814 ngx_int_t n;
Igor Sysoev <igor@sysoev.ru>
parents: 949
diff changeset
815 ngx_uint_t i;
Igor Sysoev <igor@sysoev.ru>
parents: 949
diff changeset
816 struct rlimit rlmt;
Igor Sysoev <igor@sysoev.ru>
parents: 949
diff changeset
817 ngx_core_conf_t *ccf;
Igor Sysoev <igor@sysoev.ru>
parents: 949
diff changeset
818 ngx_listening_t *ls;
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
819
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
820 ngx_process = NGX_PROCESS_WORKER;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
821
1069
Igor Sysoev <igor@sysoev.ru>
parents: 949
diff changeset
822 if (ngx_set_environment(cycle, NULL) == NULL) {
Igor Sysoev <igor@sysoev.ru>
parents: 949
diff changeset
823 /* fatal */
Igor Sysoev <igor@sysoev.ru>
parents: 949
diff changeset
824 exit(2);
Igor Sysoev <igor@sysoev.ru>
parents: 949
diff changeset
825 }
Igor Sysoev <igor@sysoev.ru>
parents: 949
diff changeset
826
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
827 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
828
1404
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
829 if (priority && ccf->priority != 0) {
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
830 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
831 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
832 "setpriority(%d) failed", ccf->priority);
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
833 }
1404
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
834 }
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
835
1404
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
836 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
837 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
838 rlmt.rlim_max = (rlim_t) ccf->rlimit_nofile;
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
839
1404
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
840 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
841 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
842 "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
843 ccf->rlimit_nofile);
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
844 }
1404
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
845 }
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
846
1404
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
847 if (ccf->rlimit_core != NGX_CONF_UNSET_SIZE) {
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
848 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
849 rlmt.rlim_max = (rlim_t) ccf->rlimit_core;
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 587
diff changeset
850
1404
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
851 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
852 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
853 "setrlimit(RLIMIT_CORE, %i) failed",
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
854 ccf->rlimit_core);
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 587
diff changeset
855 }
1404
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
856 }
589
d4e858a5751a nginx-0.3.16-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 587
diff changeset
857
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
858 #ifdef RLIMIT_SIGPENDING
1404
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
859 if (ccf->rlimit_sigpending != NGX_CONF_UNSET) {
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
860 rlmt.rlim_cur = (rlim_t) ccf->rlimit_sigpending;
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
861 rlmt.rlim_max = (rlim_t) ccf->rlimit_sigpending;
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
862
1404
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
863 if (setrlimit(RLIMIT_SIGPENDING, &rlmt) == -1) {
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
864 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
865 "setrlimit(RLIMIT_SIGPENDING, %i) failed",
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
866 ccf->rlimit_sigpending);
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
867 }
1404
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
868 }
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
869 #endif
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
870
1404
df2592d32e49 set worker_priority, worker_rlimit_nofile, worker_rlimit_core, and
Igor Sysoev <igor@sysoev.ru>
parents: 1135
diff changeset
871 if (geteuid() == 0) {
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
872 if (setgid(ccf->group) == -1) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
873 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
874 "setgid(%d) failed", ccf->group);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
875 /* fatal */
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
876 exit(2);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
877 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
878
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
879 if (initgroups(ccf->username, ccf->group) == -1) {
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
880 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
881 "initgroups(%s, %d) failed",
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
882 ccf->username, ccf->group);
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
883 }
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
884
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
885 if (setuid(ccf->user) == -1) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
886 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
887 "setuid(%d) failed", ccf->user);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
888 /* fatal */
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
889 exit(2);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
890 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
891 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
892
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
893 #if (NGX_HAVE_SCHED_SETAFFINITY)
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
894
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
895 if (cpu_affinity) {
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
896 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0,
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
897 "sched_setaffinity(0x%08Xl)", cpu_affinity);
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
898
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
899 if (sched_setaffinity(0, 32, (cpu_set_t *) &cpu_affinity) == -1) {
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
900 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
901 "sched_setaffinity(0x%08Xl) failed", cpu_affinity);
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
902 }
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
903 }
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
904
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
905 #endif
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
906
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
907 #if (NGX_HAVE_PR_SET_DUMPABLE)
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
908
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
909 /* allow coredump after setuid() in Linux 2.4.x */
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
910
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
911 if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
912 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
913 "prctl(PR_SET_DUMPABLE) failed");
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
914 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
915
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
916 #endif
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
917
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
918 if (ccf->working_directory.len) {
523
2019117e6b38 nginx-0.1.36-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 521
diff changeset
919 if (chdir((char *) ccf->working_directory.data) == -1) {
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
920 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
921 "chdir(\"%s\") failed", ccf->working_directory.data);
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
922 /* fatal */
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
923 exit(2);
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
924 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
925 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
926
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
927 sigemptyset(&set);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
928
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
929 if (sigprocmask(SIG_SETMASK, &set, NULL) == -1) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
930 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
931 "sigprocmask() failed");
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
932 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
933
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
934 /*
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
935 * disable deleting previous events for the listening sockets because
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
936 * in the worker processes there are no events at all at this point
577
4d9ea73a627a nginx-0.3.10-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 573
diff changeset
937 */
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
938 ls = cycle->listening.elts;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
939 for (i = 0; i < cycle->listening.nelts; i++) {
543
511a89da35ad nginx-0.2.0-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 535
diff changeset
940 ls[i].previous = NULL;
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
941 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
942
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
943 for (i = 0; ngx_modules[i]; i++) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
944 if (ngx_modules[i]->init_process) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
945 if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
946 /* fatal */
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
947 exit(2);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
948 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
949 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
950 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
951
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
952 for (n = 0; n < ngx_last_process; n++) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
953
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
954 if (ngx_processes[n].pid == -1) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
955 continue;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
956 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
957
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
958 if (n == ngx_process_slot) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
959 continue;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
960 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
961
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
962 if (ngx_processes[n].channel[1] == -1) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
963 continue;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
964 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
965
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
966 if (close(ngx_processes[n].channel[1]) == -1) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
967 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
968 "close() channel failed");
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
969 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
970 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
971
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
972 if (close(ngx_processes[ngx_process_slot].channel[0]) == -1) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
973 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
974 "close() channel failed");
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
975 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
976
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
977 #if 0
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
978 ngx_last_process = 0;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
979 #endif
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
980
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
981 if (ngx_add_channel_event(cycle, ngx_channel, NGX_READ_EVENT,
1133
d5c1c84b7904 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 1132
diff changeset
982 ngx_channel_handler)
d5c1c84b7904 style fix
Igor Sysoev <igor@sysoev.ru>
parents: 1132
diff changeset
983 == NGX_ERROR)
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
984 {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
985 /* fatal */
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
986 exit(2);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
987 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
988 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
989
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
990
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
991 static void
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
992 ngx_worker_process_exit(ngx_cycle_t *cycle)
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
993 {
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
994 ngx_uint_t i;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
995 ngx_connection_t *c;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
996
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
997 #if (NGX_THREADS)
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
998 ngx_terminate = 1;
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
999
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1000 ngx_wakeup_worker_threads(cycle);
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1001 #endif
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1002
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1003 for (i = 0; ngx_modules[i]; i++) {
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1004 if (ngx_modules[i]->exit_process) {
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1005 ngx_modules[i]->exit_process(cycle);
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1006 }
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1007 }
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1008
1905
0cafbfd8112e left open sockets were not really tested
Igor Sysoev <igor@sysoev.ru>
parents: 1900
diff changeset
1009 if (ngx_exiting) {
587
284cc140593b nginx-0.3.15-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
1010 c = cycle->connections;
284cc140593b nginx-0.3.15-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
1011 for (i = 0; i < cycle->connection_n; i++) {
284cc140593b nginx-0.3.15-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
1012 if (c[i].fd != -1
284cc140593b nginx-0.3.15-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
1013 && c[i].read
284cc140593b nginx-0.3.15-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
1014 && !c[i].read->accept
1905
0cafbfd8112e left open sockets were not really tested
Igor Sysoev <igor@sysoev.ru>
parents: 1900
diff changeset
1015 && !c[i].read->channel
0cafbfd8112e left open sockets were not really tested
Igor Sysoev <igor@sysoev.ru>
parents: 1900
diff changeset
1016 && !c[i].read->resolver)
587
284cc140593b nginx-0.3.15-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
1017 {
284cc140593b nginx-0.3.15-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
1018 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
3026
f4b5c787fe33 fix debug point for left open sockets
Igor Sysoev <igor@sysoev.ru>
parents: 3019
diff changeset
1019 "open socket #%d left in connection %ui",
f4b5c787fe33 fix debug point for left open sockets
Igor Sysoev <igor@sysoev.ru>
parents: 3019
diff changeset
1020 c[i].fd, i);
f4b5c787fe33 fix debug point for left open sockets
Igor Sysoev <igor@sysoev.ru>
parents: 3019
diff changeset
1021 ngx_debug_quit = 1;
587
284cc140593b nginx-0.3.15-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
1022 }
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1023 }
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1024
587
284cc140593b nginx-0.3.15-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
1025 if (ngx_debug_quit) {
3026
f4b5c787fe33 fix debug point for left open sockets
Igor Sysoev <igor@sysoev.ru>
parents: 3019
diff changeset
1026 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, "aborting");
587
284cc140593b nginx-0.3.15-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
1027 ngx_debug_point();
284cc140593b nginx-0.3.15-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 577
diff changeset
1028 }
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1029 }
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1030
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1031 /*
1437
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
1032 * 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
1033 * 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
1034 * 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
1035 * ngx_cycle->pool is already destroyed.
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1036 */
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1037
1437
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
1038 ngx_exit_log_file.fd = ngx_cycle->log->file->fd;
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
1039
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
1040 ngx_exit_log = *ngx_cycle->log;
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
1041 ngx_exit_log.file = &ngx_exit_log_file;
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
1042
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
1043 ngx_exit_cycle.log = &ngx_exit_log;
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
1044 ngx_cycle = &ngx_exit_cycle;
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
1045
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1046 ngx_destroy_pool(cycle->pool);
1437
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
1047
e498f4cb1663 destroy ngx_cycle->pool on exit
Igor Sysoev <igor@sysoev.ru>
parents: 1404
diff changeset
1048 ngx_log_error(NGX_LOG_NOTICE, ngx_cycle->log, 0, "exit");
573
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1049
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1050 exit(0);
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1051 }
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1052
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1053
58475592100c nginx-0.3.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 571
diff changeset
1054 static void
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1055 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
1056 {
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
1057 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
1058 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
1059 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
1060
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1061 if (ev->timedout) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1062 ev->timedout = 0;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1063 return;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1064 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1065
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
1066 c = ev->data;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
1067
357
e260514b9ad4 nginx-0.0.7-2004-06-16-23:36:07 import
Igor Sysoev <igor@sysoev.ru>
parents: 355
diff changeset
1068 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
1069
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1070 for ( ;; ) {
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
1071
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1072 n = ngx_read_channel(c->fd, &ch, sizeof(ngx_channel_t), ev->log);
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1073
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1074 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
1075
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1076 if (n == NGX_ERROR) {
1900
55a9d867e3c8 avoid endless loop if epoll is used
Igor Sysoev <igor@sysoev.ru>
parents: 1704
diff changeset
1077
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1078 if (ngx_event_flags & NGX_USE_EPOLL_EVENT) {
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1079 ngx_del_conn(c, 0);
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1080 }
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1081
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1082 ngx_close_connection(c);
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1083 return;
1900
55a9d867e3c8 avoid endless loop if epoll is used
Igor Sysoev <igor@sysoev.ru>
parents: 1704
diff changeset
1084 }
55a9d867e3c8 avoid endless loop if epoll is used
Igor Sysoev <igor@sysoev.ru>
parents: 1704
diff changeset
1085
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1086 if (ngx_event_flags & NGX_USE_EVENTPORT_EVENT) {
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1087 if (ngx_add_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) {
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1088 return;
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1089 }
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1090 }
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
1091
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1092 if (n == NGX_AGAIN) {
1134
384c92c210f9 worker processes did not exit after reconfiguration and
Igor Sysoev <igor@sysoev.ru>
parents: 1133
diff changeset
1093 return;
384c92c210f9 worker processes did not exit after reconfiguration and
Igor Sysoev <igor@sysoev.ru>
parents: 1133
diff changeset
1094 }
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1095
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1096 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0,
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1097 "channel command: %d", ch.command);
1134
384c92c210f9 worker processes did not exit after reconfiguration and
Igor Sysoev <igor@sysoev.ru>
parents: 1133
diff changeset
1098
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1099 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
1100
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1101 case NGX_CMD_QUIT:
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1102 ngx_quit = 1;
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1103 break;
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
1104
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1105 case NGX_CMD_TERMINATE:
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1106 ngx_terminate = 1;
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1107 break;
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
1108
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1109 case NGX_CMD_REOPEN:
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1110 ngx_reopen = 1;
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1111 break;
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
1112
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1113 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
1114
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1115 ngx_log_debug3(NGX_LOG_DEBUG_CORE, ev->log, 0,
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1116 "get channel s:%i pid:%P fd:%d",
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1117 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
1118
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1119 ngx_processes[ch.slot].pid = ch.pid;
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1120 ngx_processes[ch.slot].channel[0] = ch.fd;
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1121 break;
365
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
1122
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1123 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
1124
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1125 ngx_log_debug4(NGX_LOG_DEBUG_CORE, ev->log, 0,
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1126 "close channel s:%i pid:%P our:%P fd:%d",
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1127 ch.slot, ch.pid, ngx_processes[ch.slot].pid,
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1128 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
1129
2031
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1130 if (close(ngx_processes[ch.slot].channel[0]) == -1) {
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1131 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1132 "close() channel failed");
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1133 }
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1134
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1135 ngx_processes[ch.slot].channel[0] = -1;
c509e16b70f5 read channel until EAGAIN
Igor Sysoev <igor@sysoev.ru>
parents: 1905
diff changeset
1136 break;
365
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
1137 }
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
1138 }
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
1139 }
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
1140
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
1141
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1142 #if (NGX_THREADS)
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1143
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1144 static void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1145 ngx_wakeup_worker_threads(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
1146 {
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1147 ngx_int_t i;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1148 ngx_uint_t live;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1149
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1150 for ( ;; ) {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1151
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1152 live = 0;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1153
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1154 for (i = 0; i < ngx_threads_n; i++) {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1155 if (ngx_threads[i].state < NGX_THREAD_EXIT) {
469
2ff194b74f1e nginx-0.1.9-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
1156 if (ngx_cond_signal(ngx_threads[i].cv) == NGX_ERROR) {
2ff194b74f1e nginx-0.1.9-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
1157 ngx_threads[i].state = NGX_THREAD_DONE;
377
41437e4fd9b4 nginx-0.0.7-2004-07-05-19:08:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 376
diff changeset
1158
41437e4fd9b4 nginx-0.0.7-2004-07-05-19:08:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 376
diff changeset
1159 } else {
41437e4fd9b4 nginx-0.0.7-2004-07-05-19:08:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 376
diff changeset
1160 live = 1;
41437e4fd9b4 nginx-0.0.7-2004-07-05-19:08:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 376
diff changeset
1161 }
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1162 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1163
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1164 if (ngx_threads[i].state == NGX_THREAD_EXIT) {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1165 ngx_thread_join(ngx_threads[i].tid, NULL);
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1166 ngx_threads[i].state = NGX_THREAD_DONE;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1167 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1168 }
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1169
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1170 if (live == 0) {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1171 ngx_log_debug0(NGX_LOG_DEBUG_CORE, cycle->log, 0,
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1172 "all worker threads are joined");
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1173
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1174 /* STUB */
380
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1175 ngx_done_events(cycle);
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1176 ngx_mutex_destroy(ngx_event_timer_mutex);
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1177 ngx_mutex_destroy(ngx_posted_events_mutex);
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1178
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1179 return;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1180 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1181
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1182 ngx_sched_yield();
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1183 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1184 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1185
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1186
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
1187 static ngx_thread_value_t
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1188 ngx_worker_thread_cycle(void *data)
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1189 {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1190 ngx_thread_t *thr = data;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1191
379
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1192 sigset_t set;
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1193 ngx_err_t err;
381
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
1194 ngx_core_tls_t *tls;
380
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1195 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
1196
380
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1197 cycle = (ngx_cycle_t *) ngx_cycle;
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1198
375
744ccb59062d nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents: 371
diff changeset
1199 sigemptyset(&set);
744ccb59062d nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents: 371
diff changeset
1200 sigaddset(&set, ngx_signal_value(NGX_RECONFIGURE_SIGNAL));
744ccb59062d nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents: 371
diff changeset
1201 sigaddset(&set, ngx_signal_value(NGX_REOPEN_SIGNAL));
744ccb59062d nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents: 371
diff changeset
1202 sigaddset(&set, ngx_signal_value(NGX_CHANGEBIN_SIGNAL));
279
b79f021a644a nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 278
diff changeset
1203
b79f021a644a nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 278
diff changeset
1204 err = ngx_thread_sigmask(SIG_BLOCK, &set, NULL);
b79f021a644a nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 278
diff changeset
1205 if (err) {
380
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1206 ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
279
b79f021a644a nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 278
diff changeset
1207 ngx_thread_sigmask_n " failed");
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
1208 return (ngx_thread_value_t) 1;
279
b79f021a644a nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 278
diff changeset
1209 }
b79f021a644a nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 278
diff changeset
1210
382
449c4885dcd1 nginx-0.0.7-2004-07-07-23:48:31 import
Igor Sysoev <igor@sysoev.ru>
parents: 381
diff changeset
1211 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0,
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
1212 "thread " NGX_TID_T_FMT " started", ngx_thread_self());
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1213
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1214 ngx_setthrtitle("worker thread");
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1215
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1216 tls = ngx_calloc(sizeof(ngx_core_tls_t), cycle->log);
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1217 if (tls == NULL) {
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
1218 return (ngx_thread_value_t) 1;
379
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1219 }
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1220
381
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
1221 err = ngx_thread_set_tls(ngx_core_tls_key, tls);
379
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1222 if (err != 0) {
380
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1223 ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
381
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
1224 ngx_thread_set_tls_n " failed");
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
1225 return (ngx_thread_value_t) 1;
379
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1226 }
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1227
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
1228 ngx_mutex_lock(ngx_posted_events_mutex);
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1229
370
54f76b0b8dca nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 366
diff changeset
1230 for ( ;; ) {
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1231 thr->state = NGX_THREAD_FREE;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1232
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1233 if (ngx_cond_wait(thr->cv, ngx_posted_events_mutex) == NGX_ERROR) {
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
1234 return (ngx_thread_value_t) 1;
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1235 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1236
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1237 if (ngx_terminate) {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1238 thr->state = NGX_THREAD_EXIT;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1239
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1240 ngx_mutex_unlock(ngx_posted_events_mutex);
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1241
381
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
1242 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0,
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
1243 "thread " NGX_TID_T_FMT " is done",
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
1244 ngx_thread_self());
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1245
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
1246 return (ngx_thread_value_t) 0;
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1247 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1248
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1249 thr->state = NGX_THREAD_BUSY;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1250
380
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1251 if (ngx_event_thread_process_posted(cycle) == NGX_ERROR) {
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
1252 return (ngx_thread_value_t) 1;
380
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1253 }
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1254
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1255 if (ngx_event_thread_process_posted(cycle) == NGX_ERROR) {
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
1256 return (ngx_thread_value_t) 1;
380
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1257 }
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1258
381
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
1259 if (ngx_process_changes) {
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
1260 if (ngx_process_changes(cycle, 1) == NGX_ERROR) {
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
1261 return (ngx_thread_value_t) 1;
381
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
1262 }
370
54f76b0b8dca nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 366
diff changeset
1263 }
54f76b0b8dca nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 366
diff changeset
1264 }
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1265 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1266
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1267 #endif
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1268
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1269
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1270 static void
2616
d19979e0d980 introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents: 2592
diff changeset
1271 ngx_cache_manager_process_cycle(ngx_cycle_t *cycle, void *data)
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1272 {
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1273 ngx_cache_manager_ctx_t *ctx = data;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1274
2592
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1275 void *ident[4];
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1276 ngx_event_t ev;
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1277
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1278 cycle->connection_n = 512;
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1279
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
1280 ngx_worker_process_init(cycle, 0);
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1281
2592
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1282 ngx_close_listening_sockets(cycle);
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1283
2592
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1284 ngx_memzero(&ev, sizeof(ngx_event_t));
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1285 ev.handler = ctx->handler;
2592
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1286 ev.data = ident;
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1287 ev.log = cycle->log;
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1288 ident[3] = (void *) -1;
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1289
2592
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1290 ngx_use_accept_mutex = 0;
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1291
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1292 ngx_setproctitle(ctx->name);
2592
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1293
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1294 ngx_add_timer(&ev, ctx->delay);
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1295
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1296 for ( ;; ) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1297
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1298 if (ngx_terminate || ngx_quit) {
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
1299 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "exiting");
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1300 exit(0);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1301 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1302
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1303 if (ngx_reopen) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1304 ngx_reopen = 0;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
1305 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs");
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1306 ngx_reopen_files(cycle, -1);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1307 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1308
563
9c2f3ed7a247 nginx-0.3.3-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 559
diff changeset
1309 ngx_process_events_and_timers(cycle);
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1310 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1311 }
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1312
2592
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1313
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1314 static void
2616
d19979e0d980 introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents: 2592
diff changeset
1315 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
1316 {
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1317 time_t next, n;
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1318 ngx_uint_t i;
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1319 ngx_path_t **path;
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1320
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1321 next = 60 * 60;
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1322
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1323 path = ngx_cycle->pathes.elts;
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1324 for (i = 0; i < ngx_cycle->pathes.nelts; i++) {
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1325
2616
d19979e0d980 introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents: 2592
diff changeset
1326 if (path[i]->manager) {
d19979e0d980 introduce cache manager instead of cache cleaner
Igor Sysoev <igor@sysoev.ru>
parents: 2592
diff changeset
1327 n = path[i]->manager(path[i]->data);
2592
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1328
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1329 next = (n <= next) ? n : next;
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1330
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1331 ngx_time_update(0, 0);
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1332 }
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1333 }
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1334
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1335 if (next == 0) {
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1336 next = 1;
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1337 }
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1338
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1339 ngx_add_timer(ev, next * 1000);
3a8a53c0c42f a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents: 2522
diff changeset
1340 }
3018
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1341
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1342
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1343 static void
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1344 ngx_cache_loader_process_handler(ngx_event_t *ev)
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1345 {
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1346 ngx_uint_t i;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1347 ngx_path_t **path;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1348 ngx_cycle_t *cycle;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1349
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1350 cycle = (ngx_cycle_t *) ngx_cycle;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1351
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1352 path = cycle->pathes.elts;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1353 for (i = 0; i < cycle->pathes.nelts; i++) {
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1354
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1355 if (ngx_terminate || ngx_quit) {
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1356 break;
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1357 }
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1358
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1359 if (path[i]->loader) {
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1360 path[i]->loader(path[i]->data);
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1361 ngx_time_update(0, 0);
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1362 }
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1363 }
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1364
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1365 exit(0);
8fc7b94f647b cache loader process
Igor Sysoev <igor@sysoev.ru>
parents: 3016
diff changeset
1366 }