annotate src/os/unix/ngx_process_cycle.c @ 521:6f00349b98e5 release-0.1.35

nginx-0.1.35-RELEASE import *) Feature: the "working_directory" directive. *) Feature: the "port_in_redirect" directive. *) Bugfix: the segmentation fault was occurred if the backend response header was in several packets; the bug had appeared in 0.1.29. *) Bugfix: if more than 10 servers were configured or some server did not use the "listen" directive, then the segmentation fault was occurred on the start. *) Bugfix: the segmentation fault might occur if the response was bigger than the temporary file. *) Bugfix: nginx returned the 400 response on requests like "GET http://www.domain.com/uri HTTP/1.0"; the bug had appeared in 0.1.28.
author Igor Sysoev <igor@sysoev.ru>
date Tue, 07 Jun 2005 15:56:31 +0000
parents 9b8c906f6e63
children 2019117e6b38
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>
509
9b8c906f6e63 nginx-0.1.29-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 505
diff changeset
10 #include <ngx_setproctitle.h>
366
e411b1482ee3 nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents: 365
diff changeset
11 #include <ngx_channel.h>
309
2e899477243a nginx-0.0.3-2004-04-09-20:03:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 305
diff changeset
12
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
13
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
14 static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n,
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
15 ngx_int_t type);
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
16 static void ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type);
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
17 static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo);
365
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
18 static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle);
452
23fb87bddda1 nginx-0.1.1-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 449
diff changeset
19 static void ngx_master_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
20 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
21 static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority);
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
22 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
23 #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
24 static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle);
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
25 static void *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
26 #endif
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
27 #if 0
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
28 static void ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data);
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
29 #endif
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
30
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
31
326
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
32 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
33 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
34 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
35
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
36 sig_atomic_t ngx_reap;
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
37 sig_atomic_t ngx_timer;
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
38 sig_atomic_t ngx_sigio;
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
39 sig_atomic_t ngx_terminate;
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
40 sig_atomic_t ngx_quit;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
41 sig_atomic_t ngx_debug_quit;
326
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
42 ngx_uint_t ngx_exiting;
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
43 sig_atomic_t ngx_reconfigure;
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
44 sig_atomic_t ngx_reopen;
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
45
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
46 sig_atomic_t ngx_change_binary;
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
47 ngx_pid_t ngx_new_binary;
326
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
48 ngx_uint_t ngx_inherited;
366
e411b1482ee3 nginx-0.0.7-2004-06-23-19:18:17 import
Igor Sysoev <igor@sysoev.ru>
parents: 365
diff changeset
49 ngx_uint_t ngx_daemonized;
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
50
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
51 sig_atomic_t ngx_noaccept;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
52 ngx_uint_t ngx_noaccepting;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
53 ngx_uint_t ngx_restart;
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
54
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
55
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
56 #if (NGX_THREADS)
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
57 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
58 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
59 #endif
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
60
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
61
326
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
62 u_char master_process[] = "master process";
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
63
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
64
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
65 void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
66 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
67 {
329
9a0ffa21f193 nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 327
diff changeset
68 char *title;
9a0ffa21f193 nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 327
diff changeset
69 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
70 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
71 ngx_int_t i;
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
72 sigset_t set;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
73 struct timeval tv;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
74 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
75 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
76 ngx_msec_t delay;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
77 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
78
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
79 sigemptyset(&set);
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
80 sigaddset(&set, SIGCHLD);
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
81 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
82 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
83 sigaddset(&set, SIGINT);
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
84 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
85 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
86 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
87 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
88 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
89 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
90
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
91 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
92 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
93 "sigprocmask() failed");
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
94 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
95
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
96 sigemptyset(&set);
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
97
326
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
98
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
99 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
100
452
23fb87bddda1 nginx-0.1.1-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 449
diff changeset
101 for (i = 0; i < ngx_argc; i++) {
23fb87bddda1 nginx-0.1.1-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 449
diff changeset
102 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
103 }
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
104
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
105 title = ngx_palloc(cycle->pool, size);
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
106
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
107 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
108 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
109 *p++ = ' ';
452
23fb87bddda1 nginx-0.1.1-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 449
diff changeset
110 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
111 }
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
112
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
113 ngx_setproctitle(title);
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
114
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
115
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
116 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
117
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
118 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
119 NGX_PROCESS_RESPAWN);
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
120 ngx_start_garbage_collector(cycle, NGX_PROCESS_RESPAWN);
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
121
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
122 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
123 delay = 0;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
124 live = 1;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
125
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
126 for ( ;; ) {
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
127 if (delay) {
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
128 delay *= 2;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
129
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
130 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
131 "temination cycle: %d", delay);
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
132
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
133 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
134 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
135 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
136 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
137
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
138 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
139 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
140 "setitimer() failed");
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
141 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
142 }
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 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
145
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
146 sigsuspend(&set);
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
147
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
148 ngx_gettimeofday(&tv);
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
149 ngx_time_update(tv.tv_sec);
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_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
152
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
153 if (ngx_reap) {
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
154 ngx_reap = 0;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
155 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "reap childs");
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
156
365
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
157 live = ngx_reap_childs(cycle);
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
158 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
159
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
160 if (!live && (ngx_terminate || ngx_quit)) {
452
23fb87bddda1 nginx-0.1.1-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 449
diff changeset
161 ngx_master_exit(cycle);
317
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 if (ngx_terminate) {
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
165 if (delay == 0) {
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
166 delay = 50;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
167 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
168
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
169 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
170 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
171 } else {
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
172 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
173 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
174 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
175
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
176 continue;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
177 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
178
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
179 if (ngx_quit) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
180 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
181 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
182 continue;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
183 }
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
184
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
185 if (ngx_timer) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
186 ngx_timer = 0;
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 452
diff changeset
187
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 452
diff changeset
188 if (!ngx_noaccepting) {
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 452
diff changeset
189 ngx_start_worker_processes(cycle, ccf->worker_processes,
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 452
diff changeset
190 NGX_PROCESS_JUST_RESPAWN);
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
191 ngx_start_garbage_collector(cycle, NGX_PROCESS_JUST_RESPAWN);
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 452
diff changeset
192 live = 1;
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 452
diff changeset
193 ngx_signal_worker_processes(cycle,
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
194 ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 452
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 }
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
197
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
198 if (ngx_reconfigure) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
199 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
200
9a0ffa21f193 nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 327
diff changeset
201 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
202 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
203 NGX_PROCESS_RESPAWN);
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
204 ngx_start_garbage_collector(cycle, NGX_PROCESS_RESPAWN);
449
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 448
diff changeset
205 ngx_noaccepting = 0;
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 448
diff changeset
206
329
9a0ffa21f193 nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 327
diff changeset
207 continue;
9a0ffa21f193 nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 327
diff changeset
208 }
9a0ffa21f193 nginx-0.0.3-2004-04-29-00:21:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 327
diff changeset
209
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
210 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
211
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
212 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
213 if (cycle == NULL) {
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
214 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
215 continue;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
216 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
217
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
218 ngx_cycle = cycle;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
219 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
220 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
221 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
222 NGX_PROCESS_JUST_RESPAWN);
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
223 ngx_start_garbage_collector(cycle, NGX_PROCESS_JUST_RESPAWN);
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
224 live = 1;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
225 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
226 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
227 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
228
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
229 if (ngx_restart) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
230 ngx_restart = 0;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
231 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
232 NGX_PROCESS_RESPAWN);
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
233 ngx_start_garbage_collector(cycle, NGX_PROCESS_RESPAWN);
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
234 live = 1;
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
235 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
236
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
237 if (ngx_reopen) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
238 ngx_reopen = 0;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
239 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
240 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
241 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
242 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
243 }
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
244
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
245 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
246 ngx_change_binary = 0;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
247 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
248 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
249 }
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
250
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
251 if (ngx_noaccept) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
252 ngx_noaccept = 0;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
253 ngx_noaccepting = 1;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
254 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
255 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
256 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
257 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
258 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
259
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
260
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
261 void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
262 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
263 {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
264 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
265
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
266 ngx_init_temp_number();
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
267
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
268 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
269 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
270 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
271 /* fatal */
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
272 exit(2);
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
273 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
274 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
275 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
276
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
277 for ( ;; ) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
278 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
279
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
280 ngx_process_events(cycle);
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 if (ngx_terminate || ngx_quit) {
452
23fb87bddda1 nginx-0.1.1-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 449
diff changeset
283 ngx_master_exit(cycle);
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
284 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
285
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
286 if (ngx_reconfigure) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
287 ngx_reconfigure = 0;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
288 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
289
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
290 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
291 if (cycle == NULL) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
292 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
293 continue;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
294 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
295
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
296 ngx_cycle = cycle;
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
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
299 if (ngx_reopen) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
300 ngx_reopen = 0;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
301 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
302 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
303 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
304 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
305 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
306
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
307
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
308 static void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
309 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
310 {
360
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
311 ngx_int_t i;
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
312 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
313 struct itimerval itv;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
314
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
315 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
316
360
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
317 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
318
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
319 while (n--) {
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
320 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
321 "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
322
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
323 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
324 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
325 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
326
389
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
327 for (i = 0; i < ngx_last_process; i++) {
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
328
449
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 448
diff changeset
329 if (i == ngx_process_slot
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 448
diff changeset
330 || ngx_processes[i].pid == -1
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 448
diff changeset
331 || ngx_processes[i].channel[0] == -1)
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 448
diff changeset
332 {
389
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
333 continue;
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
334 }
360
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
335
449
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 448
diff changeset
336 ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0,
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
337 "pass channel s:%d pid:%P fd:%d to s:%i pid:%P fd:%d",
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
338 ch.slot, ch.pid, ch.fd,
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
339 i, ngx_processes[i].pid,
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
340 ngx_processes[i].channel[0]);
360
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
341
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
342 /* TODO: NGX_AGAIN */
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
343
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
344 ngx_write_channel(ngx_processes[i].channel[0],
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
345 &ch, sizeof(ngx_channel_t), cycle->log);
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
346 }
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
347 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
348
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
349 /*
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
350 * we have to limit the maximum life time of the worker processes
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
351 * by 10 days because our millisecond event timer is limited
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
352 * by 24 days on 32-bit platforms
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 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
356 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
357 itv.it_value.tv_sec = 10 * 24 * 60 * 60;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
358 itv.it_value.tv_usec = 0;
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
359
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
360 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
361 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
362 "setitimer() failed");
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
363 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
364 }
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
365
360
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
366
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
367 static void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
368 ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type)
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
369 {
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
370 #if 0
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
371 ngx_int_t i;
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
372 ngx_channel_t ch;
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
373
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
374 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start garbage collector");
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
375
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
376 ch.command = NGX_CMD_OPEN_CHANNEL;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
377
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
378 ngx_spawn_process(cycle, ngx_garbage_collector_cycle, NULL,
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
379 "garbage collector", type);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
380
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
381 ch.pid = ngx_processes[ngx_process_slot].pid;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
382 ch.slot = ngx_process_slot;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
383 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
384
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
385 for (i = 0; i < ngx_last_process; i++) {
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 if (i == ngx_process_slot
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
388 || ngx_processes[i].pid == -1
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
389 || ngx_processes[i].channel[0] == -1)
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
390 {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
391 continue;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
392 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
393
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
394 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
395 "pass channel s:%d pid:%P fd:%d to s:%i pid:%P fd:%d",
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
396 ch.slot, ch.pid, ch.fd,
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
397 i, ngx_processes[i].pid,
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
398 ngx_processes[i].channel[0]);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
399
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
400 /* TODO: NGX_AGAIN */
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
401
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
402 ngx_write_channel(ngx_processes[i].channel[0],
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
403 &ch, sizeof(ngx_channel_t), cycle->log);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
404 }
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
405 #endif
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
406 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
407
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
408
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
409 static void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
410 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
411 {
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
412 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
413 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
414 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
415
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
416 switch (signo) {
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
417
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
418 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
419 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
420 break;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
421
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
422 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
423 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
424 break;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
425
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
426 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
427 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
428 break;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
429
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
430 default:
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
431 ch.command = 0;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
432 }
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
433
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
434 ch.fd = -1;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
435
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
436
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
437 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
438
449
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 448
diff changeset
439 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
440 "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
441 i,
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 448
diff changeset
442 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
443 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
444 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
445 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
446 ngx_processes[i].respawn,
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 448
diff changeset
447 ngx_processes[i].just_respawn);
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 448
diff changeset
448
389
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
449 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
450 continue;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
451 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
452
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
453 if (ngx_processes[i].just_respawn) {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
454 ngx_processes[i].just_respawn = 0;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
455 continue;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
456 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
457
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
458 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
459 && 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
460 {
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
461 continue;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
462 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
463
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
464 if (ch.command) {
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
465 if (ngx_write_channel(ngx_processes[i].channel[0],
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
466 &ch, sizeof(ngx_channel_t), cycle->log) == NGX_OK)
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
467 {
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
468 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
469 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
470 }
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
471
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
472 continue;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
473 }
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
474 }
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
475
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
476 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
477 "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
478
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
479 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
480 err = ngx_errno;
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
481 ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
482 "kill(%P, %d) failed",
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
483 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
484
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
485 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
486 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
487 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
488 ngx_reap = 1;
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
489 }
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
490
318
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
491 continue;
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
492 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
493
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
494 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
495 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
496 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
497 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
498 }
56496082668b nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 317
diff changeset
499
317
1308b98496a2 nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents: 315
diff changeset
500
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
501 static ngx_uint_t
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
502 ngx_reap_childs(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
503 {
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
504 ngx_int_t i, n;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
505 ngx_uint_t live;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
506 ngx_channel_t ch;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
507
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
508 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
509 ch.fd = -1;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
510
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
511 live = 0;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
512 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
513
389
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
514 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
515 "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
516 i,
365
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
517 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
518 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
519 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
520 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
521 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
522 ngx_processes[i].just_respawn);
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
523
389
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
524 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
525 continue;
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
526 }
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
527
365
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
528 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
529
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
530 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
531 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
532
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
533 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
534 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
535
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
536 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
537 ch.slot = i;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
538
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
539 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
540 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
541 || 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
542 || 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
543 {
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
544 continue;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
545 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
546
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
547 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
548 "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
549 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
550
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
551 /* TODO: NGX_AGAIN */
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
552
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
553 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
554 &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
555 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
556 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
557
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
558 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
559 && !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
560 && !ngx_terminate
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
561 && !ngx_quit)
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
562 {
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
563 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
564 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
565 ngx_processes[i].name, i)
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
566 == NGX_ERROR)
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
567 {
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
568 ngx_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
569 "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
570 continue;
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
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
573
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
574 ch.command = NGX_CMD_OPEN_CHANNEL;
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
575 ch.pid = ngx_processes[ngx_process_slot].pid;
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
576 ch.slot = ngx_process_slot;
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
577 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
578
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
579 for (n = 0; n < ngx_last_process; n++) {
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
580
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
581 if (n == ngx_process_slot
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
582 || ngx_processes[n].pid == -1
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
583 || ngx_processes[n].channel[0] == -1)
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
584 {
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
585 continue;
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
586 }
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
587
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
588 ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0,
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
589 "pass channel s:%d pid:%P fd:%d to s:%i pid:%P fd:%d",
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
590 ch.slot, ch.pid, ch.fd,
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
591 n, ngx_processes[n].pid,
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
592 ngx_processes[n].channel[0]);
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
593
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
594 /* TODO: NGX_AGAIN */
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
595
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
596 ngx_write_channel(ngx_processes[n].channel[0],
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
597 &ch, sizeof(ngx_channel_t), cycle->log);
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
598 }
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
599
365
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
600 live = 1;
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 continue;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
603 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
604
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
605 if (ngx_processes[i].pid == ngx_new_binary) {
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
606 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
607 if (ngx_noaccepting) {
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
608 ngx_restart = 1;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
609 ngx_noaccepting = 0;
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 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
612
389
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
613 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
614 ngx_last_process--;
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
615
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
616 } else {
537de4dca8ca nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 382
diff changeset
617 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
618 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
619
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
620 } 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
621 live = 1;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
622 }
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 return live;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
626 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
627
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
628
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
629 static void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
630 ngx_master_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
631 {
310
a9a9af2c7370 nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents: 309
diff changeset
632 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
633
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
634 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
635
505
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
636 /*
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
637 * we do not destroy cycle->pool here because a signal handler
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
638 * that uses cycle->log can be called at this point
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
639 */
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
640
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
641 #if 0
322
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
642 ngx_destroy_pool(cycle->pool);
505
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
643 #endif
322
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
644
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
645 exit(0);
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
646 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
647
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
648
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
649 static void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
650 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
651 {
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
652 #if (NGX_THREADS)
469
2ff194b74f1e nginx-0.1.9-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
653 ngx_int_t n;
2ff194b74f1e nginx-0.1.9-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
654 ngx_err_t err;
2ff194b74f1e nginx-0.1.9-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
655 ngx_core_conf_t *ccf;
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
656 #endif
469
2ff194b74f1e nginx-0.1.9-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
657
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
658 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
659
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
660 ngx_setproctitle("worker process");
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
661
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
662 #if (NGX_THREADS)
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
663
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
664 if (ngx_time_mutex_init(cycle->log) == NGX_ERROR) {
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
665 /* fatal */
279
b79f021a644a nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 278
diff changeset
666 exit(2);
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
667 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
668
469
2ff194b74f1e nginx-0.1.9-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 467
diff changeset
669 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
670
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
671 if (ngx_threads_n) {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
672 if (ngx_init_threads(ngx_threads_n,
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
673 ccf->thread_stack_size, cycle) == NGX_ERROR)
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
674 {
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
675 /* fatal */
279
b79f021a644a nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 278
diff changeset
676 exit(2);
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
677 }
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
678
381
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
679 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
680 if (err != 0) {
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
681 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
682 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
683 /* fatal */
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
684 exit(2);
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
685 }
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
686
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
687 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
688
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
689 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
690
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
691 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
692 /* fatal */
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
693 exit(2);
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
694 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
695
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
696 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
697 ngx_worker_thread_cycle,
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
698 (void *) &ngx_threads[n], cycle->log) != 0)
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
699 {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
700 /* fatal */
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
701 exit(2);
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
702 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
703 }
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
704 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
705
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
706 #endif
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
707
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
708 for ( ;; ) {
326
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
709 if (ngx_exiting
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
710 && ngx_event_timer_rbtree == &ngx_event_timer_sentinel)
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
711 {
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
712 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
713
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
714
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
715 #if (NGX_THREADS)
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
716 ngx_terminate = 1;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
717
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
718 ngx_wakeup_worker_threads(cycle);
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
719 #endif
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
720
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
721 if (ngx_debug_quit) {
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
722 ngx_debug_point();
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
723 }
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
724
345
fade4edd61f8 nginx-0.0.3-2004-06-04-18:57:33 import
Igor Sysoev <igor@sysoev.ru>
parents: 329
diff changeset
725 /*
fade4edd61f8 nginx-0.0.3-2004-06-04-18:57:33 import
Igor Sysoev <igor@sysoev.ru>
parents: 329
diff changeset
726 * we do not destroy cycle->pool here because a signal handler
fade4edd61f8 nginx-0.0.3-2004-06-04-18:57:33 import
Igor Sysoev <igor@sysoev.ru>
parents: 329
diff changeset
727 * that uses cycle->log can be called at this point
fade4edd61f8 nginx-0.0.3-2004-06-04-18:57:33 import
Igor Sysoev <igor@sysoev.ru>
parents: 329
diff changeset
728 */
505
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
729
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
730 #if 0
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
731 ngx_destroy_pool(cycle->pool);
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
732 #endif
322
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
733 exit(0);
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
734 }
ab2f8c9a2a45 nginx-0.0.3-2004-04-20-11:00:43 import
Igor Sysoev <igor@sysoev.ru>
parents: 318
diff changeset
735
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
736 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
737
301
744965ec6275 nginx-0.0.3-2004-03-31-19:26:46 import
Igor Sysoev <igor@sysoev.ru>
parents: 300
diff changeset
738 ngx_process_events(cycle);
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
739
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
740 if (ngx_terminate) {
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
741 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
742
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
743 #if (NGX_THREADS)
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
744 ngx_wakeup_worker_threads(cycle);
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
745 #endif
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
746
345
fade4edd61f8 nginx-0.0.3-2004-06-04-18:57:33 import
Igor Sysoev <igor@sysoev.ru>
parents: 329
diff changeset
747 /*
fade4edd61f8 nginx-0.0.3-2004-06-04-18:57:33 import
Igor Sysoev <igor@sysoev.ru>
parents: 329
diff changeset
748 * we do not destroy cycle->pool here because a signal handler
fade4edd61f8 nginx-0.0.3-2004-06-04-18:57:33 import
Igor Sysoev <igor@sysoev.ru>
parents: 329
diff changeset
749 * that uses cycle->log can be called at this point
fade4edd61f8 nginx-0.0.3-2004-06-04-18:57:33 import
Igor Sysoev <igor@sysoev.ru>
parents: 329
diff changeset
750 */
505
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
751
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
752 #if 0
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
753 ngx_destroy_pool(cycle->pool);
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
754 #endif
ee66921ecd47 nginx-0.1.27-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 501
diff changeset
755
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
756 exit(0);
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
757 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
758
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
759 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
760 ngx_quit = 0;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
761 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
762 "gracefully shutting down");
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
763 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
764
326
8733703a37f3 nginx-0.0.3-2004-04-26-00:13:21 import
Igor Sysoev <igor@sysoev.ru>
parents: 323
diff changeset
765 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
766 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
767 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
768 }
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
769 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
770
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
771 if (ngx_reopen) {
323
ba876b26b76d nginx-0.0.3-2004-04-21-22:54:33 import
Igor Sysoev <igor@sysoev.ru>
parents: 322
diff changeset
772 ngx_reopen = 0;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
773 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "reopening logs");
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
774 ngx_reopen_files(cycle, -1);
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
775 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
776 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
777 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
778
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
779
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
780 static void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
781 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
782 {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
783 sigset_t set;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
784 ngx_int_t n;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
785 ngx_uint_t i;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
786 struct timeval tv;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
787 ngx_core_conf_t *ccf;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
788 ngx_listening_t *ls;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
789
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
790 ngx_gettimeofday(&tv);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
791
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
792 ngx_start_msec = (ngx_epoch_msec_t) tv.tv_sec * 1000 + tv.tv_usec / 1000;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
793 ngx_old_elapsed_msec = 0;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
794 ngx_elapsed_msec = 0;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
795
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
796
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
797 ngx_process = NGX_PROCESS_WORKER;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
798
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
799 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
800
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
801 if (geteuid() == 0) {
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
802 if (priority && ccf->priority != 0) {
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
803 if (setpriority(PRIO_PROCESS, 0, ccf->priority) == -1) {
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
804 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
805 "setpriority(%d) failed", ccf->priority);
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
806 }
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
807 }
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
808
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
809 if (setgid(ccf->group) == -1) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
810 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
811 "setgid(%d) failed", ccf->group);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
812 /* fatal */
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
813 exit(2);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
814 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
815
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
816 if (initgroups(ccf->username, ccf->group) == -1) {
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
817 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
818 "initgroups(%s, %d) failed",
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
819 ccf->username, ccf->group);
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
820 }
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
821
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
822 if (setuid(ccf->user) == -1) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
823 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
824 "setuid(%d) failed", ccf->user);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
825 /* fatal */
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
826 exit(2);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
827 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
828 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
829
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
830 #if (NGX_HAVE_PR_SET_DUMPABLE)
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
831
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
832 /* 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
833
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
834 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
835 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
836 "prctl(PR_SET_DUMPABLE) failed");
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
837 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
838
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
839 #endif
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
840
521
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
841 if (ccf->working_directory.len) {
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
842 if (chdir(ccf->working_directory.data) == -1) {
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
843 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
844 "chdir(\"%s\") failed", ccf->working_directory.data);
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
845 /* fatal */
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
846 exit(2);
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
847 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
848 }
6f00349b98e5 nginx-0.1.35-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 509
diff changeset
849
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
850 sigemptyset(&set);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
851
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
852 if (sigprocmask(SIG_SETMASK, &set, NULL) == -1) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
853 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
854 "sigprocmask() failed");
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
855 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
856
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
857 ngx_init_temp_number();
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
858
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
859 /*
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
860 * 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
861 * in the worker processes there are no events at all at this point
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
862 */
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
863 ls = cycle->listening.elts;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
864 for (i = 0; i < cycle->listening.nelts; i++) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
865 ls[i].remain = 0;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
866 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
867
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
868 for (i = 0; ngx_modules[i]; i++) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
869 if (ngx_modules[i]->init_process) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
870 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
871 /* fatal */
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
872 exit(2);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
873 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
874 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
875 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
876
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
877 for (n = 0; n < ngx_last_process; n++) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
878
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
879 if (ngx_processes[n].pid == -1) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
880 continue;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
881 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
882
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
883 if (n == ngx_process_slot) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
884 continue;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
885 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
886
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
887 if (ngx_processes[n].channel[1] == -1) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
888 continue;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
889 }
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 if (close(ngx_processes[n].channel[1]) == -1) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
892 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
893 "close() channel failed");
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
894 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
895 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
896
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
897 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
898 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
899 "close() channel failed");
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
900 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
901
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
902 #if 0
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
903 ngx_last_process = 0;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
904 #endif
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
905
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
906 if (ngx_add_channel_event(cycle, ngx_channel, NGX_READ_EVENT,
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
907 ngx_channel_handler) == NGX_ERROR)
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 /* fatal */
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
910 exit(2);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
911 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
912 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
913
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
914
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
915 static void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
916 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
917 {
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
918 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
919 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
920 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
921
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
922 if (ev->timedout) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
923 ev->timedout = 0;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
924 return;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
925 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
926
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
927 c = ev->data;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
928
357
e260514b9ad4 nginx-0.0.7-2004-06-16-23:36:07 import
Igor Sysoev <igor@sysoev.ru>
parents: 355
diff changeset
929 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
930
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
931 n = ngx_read_channel(c->fd, &ch, sizeof(ngx_channel_t), ev->log);
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
932
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
933 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
934
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
935 if (n == NGX_ERROR) {
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
936 if (close(c->fd) == -1) {
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
937 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
938 "close() channel failed");
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
939 }
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
940
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
941 c->fd = -1;
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
942 return;
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
943 }
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
944
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
945 if (n == NGX_AGAIN) {
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
946 return;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
947 }
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
948
357
e260514b9ad4 nginx-0.0.7-2004-06-16-23:36:07 import
Igor Sysoev <igor@sysoev.ru>
parents: 355
diff changeset
949 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0,
e260514b9ad4 nginx-0.0.7-2004-06-16-23:36:07 import
Igor Sysoev <igor@sysoev.ru>
parents: 355
diff changeset
950 "channel command: %d", ch.command);
e260514b9ad4 nginx-0.0.7-2004-06-16-23:36:07 import
Igor Sysoev <igor@sysoev.ru>
parents: 355
diff changeset
951
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
952 switch (ch.command) {
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
953
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
954 case NGX_CMD_QUIT:
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
955 ngx_quit = 1;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
956 break;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
957
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
958 case NGX_CMD_TERMINATE:
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
959 ngx_terminate = 1;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
960 break;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
961
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
962 case NGX_CMD_REOPEN:
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
963 ngx_reopen = 1;
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
964 break;
360
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
965
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
966 case 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
967
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
968 ngx_log_debug3(NGX_LOG_DEBUG_CORE, ev->log, 0,
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
969 "get channel s:%i pid:%P fd:%d", 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
970
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
971 ngx_processes[ch.slot].pid = ch.pid;
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
972 ngx_processes[ch.slot].channel[0] = ch.fd;
239e37d44a34 nginx-0.0.7-2004-06-18-20:22:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 357
diff changeset
973 break;
365
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
974
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
975 case 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
976
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
977 ngx_log_debug4(NGX_LOG_DEBUG_CORE, ev->log, 0,
461
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
978 "close channel s:%i pid:%P our:%P fd:%d",
365
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
979 ch.slot, ch.pid, ngx_processes[ch.slot].pid,
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
980 ngx_processes[ch.slot].channel[0]);
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
981
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
982 if (close(ngx_processes[ch.slot].channel[0]) == -1) {
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
983 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
984 "close() channel failed");
365
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
985 }
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
986
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
987 ngx_processes[ch.slot].channel[0] = -1;
fd24ba70e1b3 nginx-0.0.7-2004-06-23-09:54:27 import
Igor Sysoev <igor@sysoev.ru>
parents: 362
diff changeset
988 break;
354
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
989 }
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
990 }
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
991
eaf1f651cf86 nginx-0.0.7-2004-06-15-11:55:11 import
Igor Sysoev <igor@sysoev.ru>
parents: 345
diff changeset
992
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
993 #if (NGX_THREADS)
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
994
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
995 static void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
996 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
997 {
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
998 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
999 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
1000
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1001 for ( ;; ) {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1002
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1003 live = 0;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1004
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1005 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
1006 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
1007 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
1008 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
1009
41437e4fd9b4 nginx-0.0.7-2004-07-05-19:08:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 376
diff changeset
1010 } else {
41437e4fd9b4 nginx-0.0.7-2004-07-05-19:08:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 376
diff changeset
1011 live = 1;
41437e4fd9b4 nginx-0.0.7-2004-07-05-19:08:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 376
diff changeset
1012 }
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1013 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1014
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1015 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
1016 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
1017 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
1018 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1019 }
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1020
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1021 if (live == 0) {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1022 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
1023 "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
1024
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1025 /* STUB */
380
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1026 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
1027 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
1028 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
1029
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1030 return;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1031 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1032
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1033 ngx_sched_yield();
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1034 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1035 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1036
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1037
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1038 static void *
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1039 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
1040 {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1041 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
1042
379
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1043 sigset_t set;
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1044 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
1045 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
1046 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
1047
380
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1048 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
1049
375
744ccb59062d nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents: 371
diff changeset
1050 sigemptyset(&set);
744ccb59062d nginx-0.0.7-2004-07-02-19:54:34 import
Igor Sysoev <igor@sysoev.ru>
parents: 371
diff changeset
1051 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
1052 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
1053 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
1054
b79f021a644a nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 278
diff changeset
1055 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
1056 if (err) {
380
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1057 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
1058 ngx_thread_sigmask_n " failed");
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1059 return (void *) 1;
279
b79f021a644a nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 278
diff changeset
1060 }
b79f021a644a nginx-0.0.2-2004-03-04-19:34:23 import
Igor Sysoev <igor@sysoev.ru>
parents: 278
diff changeset
1061
382
449c4885dcd1 nginx-0.0.7-2004-07-07-23:48:31 import
Igor Sysoev <igor@sysoev.ru>
parents: 381
diff changeset
1062 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
1063 "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
1064
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1065 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
1066
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1067 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
1068 if (tls == NULL) {
379
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1069 return (void *) 1;
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1070 }
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1071
381
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
1072 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
1073 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
1074 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
1075 ngx_thread_set_tls_n " failed");
379
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1076 return (void *) 1;
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1077 }
73688d5d7fc3 nginx-0.0.7-2004-07-06-20:12:16 import
Igor Sysoev <igor@sysoev.ru>
parents: 377
diff changeset
1078
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1079 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1080 return (void *) 1;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1081 }
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1082
370
54f76b0b8dca nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 366
diff changeset
1083 for ( ;; ) {
376
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1084 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
1085
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1086 if (ngx_cond_wait(thr->cv, ngx_posted_events_mutex) == NGX_ERROR) {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1087 return (void *) 1;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1088 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1089
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1090 if (ngx_terminate) {
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1091 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
1092
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1093 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
1094
381
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
1095 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
1096 "thread " NGX_TID_T_FMT " is done",
a88a3e4e158f nginx-0.1.5-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 455
diff changeset
1097 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
1098
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1099 return (void *) 0;
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1100 }
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1101
d0451e402e27 nginx-0.0.7-2004-07-05-10:55:54 import
Igor Sysoev <igor@sysoev.ru>
parents: 375
diff changeset
1102 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
1103
380
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1104 if (ngx_event_thread_process_posted(cycle) == NGX_ERROR) {
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1105 return (void *) 1;
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1106 }
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1107
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1108 if (ngx_event_thread_process_posted(cycle) == NGX_ERROR) {
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1109 return (void *) 1;
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1110 }
5ce6561246a5 nginx-0.0.7-2004-07-07-10:15:04 import
Igor Sysoev <igor@sysoev.ru>
parents: 379
diff changeset
1111
381
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
1112 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
1113 if (ngx_process_changes(cycle, 1) == NGX_ERROR) {
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
1114 return (void *) 1;
02a511569afb nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents: 380
diff changeset
1115 }
370
54f76b0b8dca nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 366
diff changeset
1116 }
54f76b0b8dca nginx-0.0.7-2004-06-27-22:01:57 import
Igor Sysoev <igor@sysoev.ru>
parents: 366
diff changeset
1117 }
278
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1118 }
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1119
0ba4821f4460 nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
1120 #endif
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1121
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1122
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1123 #if 0
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1124
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1125 static void
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1126 ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data)
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1127 {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1128 ngx_uint_t i;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1129 ngx_gc_t ctx;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1130 ngx_path_t **path;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1131 ngx_event_t *ev;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1132
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
1133 ngx_worker_process_init(cycle, 0);
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1134
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1135 ev = &cycle->read_events[ngx_channel];
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1136
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1137 ngx_accept_mutex = NULL;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1138
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1139 ngx_setproctitle("garbage collector");
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1140
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1141 #if 0
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1142 ngx_add_timer(ev, 60 * 1000);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1143 #endif
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1144
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1145 for ( ;; ) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1146
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1147 if (ngx_terminate || ngx_quit) {
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
1148 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
1149 exit(0);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1150 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1151
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1152 if (ngx_reopen) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1153 ngx_reopen = 0;
477
ad1e9ebf93bb nginx-0.1.13-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
1154 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
1155 ngx_reopen_files(cycle, -1);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1156 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1157
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1158 path = cycle->pathes.elts;
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1159 for (i = 0; i < cycle->pathes.nelts; i++) {
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1160 ctx.path = path[i];
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1161 ctx.log = cycle->log;
479
c52408583801 nginx-0.1.14-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 477
diff changeset
1162 ctx.handler = path[i]->cleaner;
467
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1163
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1164 ngx_collect_garbage(&ctx, &path[i]->name, 0);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1165 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1166
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1167 ngx_add_timer(ev, 60 * 60 * 1000);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1168
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1169 ngx_process_events(cycle);
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1170 }
bbd6b0b4a2b1 nginx-0.1.8-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 461
diff changeset
1171 }
501
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1172
d4ea69372b94 nginx-0.1.25-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 479
diff changeset
1173 #endif