annotate src/core/ngx_cycle.c @ 618:b9763778e212 NGINX_0_9_7

nginx 0.9.7 *) Feature: now keepalive connections may be closed premature, if there are no free worker connections. Thanks to Maxim Dounin. *) Feature: the "rotate" parameter of the "image_filter" directive. Thanks to Adam Bocim. *) Bugfix: a case when a backend in "fastcgi_pass", "scgi_pass", or "uwsgi_pass" directives is given by expression and refers to a defined upstream.
author Igor Sysoev <http://sysoev.ru>
date Mon, 04 Apr 2011 00:00:00 +0400
parents 6c96fdd2dfc3
children 0d6525917227
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
2 /*
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
4 */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
5
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
6
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
7 #include <ngx_config.h>
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
8 #include <ngx_core.h>
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
9 #include <ngx_event.h>
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
10
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
11
154
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
12 static void ngx_destroy_cycle_pools(ngx_conf_t *conf);
28
7ca9bdc82b3f nginx 0.1.14
Igor Sysoev <http://sysoev.ru>
parents: 22
diff changeset
13 static ngx_int_t ngx_cmp_sockaddr(struct sockaddr *sa1, struct sockaddr *sa2);
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
14 static ngx_int_t ngx_init_zone_pool(ngx_cycle_t *cycle,
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
15 ngx_shm_zone_t *shm_zone);
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
16 static ngx_int_t ngx_test_lockfile(u_char *file, ngx_log_t *log);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
17 static void ngx_clean_old_cycles(ngx_event_t *ev);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
18
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
19
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
20 volatile ngx_cycle_t *ngx_cycle;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
21 ngx_array_t ngx_old_cycles;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
22
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
23 static ngx_pool_t *ngx_temp_pool;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
24 static ngx_event_t ngx_cleaner_event;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
25
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
26 ngx_uint_t ngx_test_config;
596
6c96fdd2dfc3 nginx 0.8.50
Igor Sysoev <http://sysoev.ru>
parents: 582
diff changeset
27 ngx_uint_t ngx_quiet_mode;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
28
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
29 #if (NGX_THREADS)
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
30 ngx_tls_key_t ngx_core_tls_key;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
31 #endif
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
32
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
33
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
34 /* STUB NAME */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
35 static ngx_connection_t dumb;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
36 /* STUB */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
37
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
38 static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
39
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
40
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
41 ngx_cycle_t *
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
42 ngx_init_cycle(ngx_cycle_t *old_cycle)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
43 {
356
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
44 void *rv;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
45 char **senv, **env;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
46 ngx_uint_t i, n;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
47 ngx_log_t *log;
404
a094317ba307 nginx 0.7.14
Igor Sysoev <http://sysoev.ru>
parents: 384
diff changeset
48 ngx_time_t *tp;
356
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
49 ngx_conf_t conf;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
50 ngx_pool_t *pool;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
51 ngx_cycle_t *cycle, **old;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
52 ngx_shm_zone_t *shm_zone, *oshm_zone;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
53 ngx_list_part_t *part, *opart;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
54 ngx_open_file_t *file;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
55 ngx_listening_t *ls, *nls;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
56 ngx_core_conf_t *ccf, *old_ccf;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
57 ngx_core_module_t *module;
376
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
58 char hostname[NGX_MAXHOSTNAMELEN];
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
59
404
a094317ba307 nginx 0.7.14
Igor Sysoev <http://sysoev.ru>
parents: 384
diff changeset
60 ngx_timezone_update();
a094317ba307 nginx 0.7.14
Igor Sysoev <http://sysoev.ru>
parents: 384
diff changeset
61
a094317ba307 nginx 0.7.14
Igor Sysoev <http://sysoev.ru>
parents: 384
diff changeset
62 /* force localtime update with a new timezone */
a094317ba307 nginx 0.7.14
Igor Sysoev <http://sysoev.ru>
parents: 384
diff changeset
63
a094317ba307 nginx 0.7.14
Igor Sysoev <http://sysoev.ru>
parents: 384
diff changeset
64 tp = ngx_timeofday();
a094317ba307 nginx 0.7.14
Igor Sysoev <http://sysoev.ru>
parents: 384
diff changeset
65 tp->sec = 0;
a094317ba307 nginx 0.7.14
Igor Sysoev <http://sysoev.ru>
parents: 384
diff changeset
66
566
be4f34123024 nginx 0.8.35
Igor Sysoev <http://sysoev.ru>
parents: 538
diff changeset
67 ngx_time_update();
404
a094317ba307 nginx 0.7.14
Igor Sysoev <http://sysoev.ru>
parents: 384
diff changeset
68
a094317ba307 nginx 0.7.14
Igor Sysoev <http://sysoev.ru>
parents: 384
diff changeset
69
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
70 log = old_cycle->log;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
71
56
3050baa54a26 nginx 0.1.28
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
72 pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 28
diff changeset
73 if (pool == NULL) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
74 return NULL;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
75 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
76 pool->log = log;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
77
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 28
diff changeset
78 cycle = ngx_pcalloc(pool, sizeof(ngx_cycle_t));
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 28
diff changeset
79 if (cycle == NULL) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
80 ngx_destroy_pool(pool);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
81 return NULL;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
82 }
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 28
diff changeset
83
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
84 cycle->pool = pool;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
85 cycle->log = log;
484
ed5e10fb40fc nginx 0.7.54
Igor Sysoev <http://sysoev.ru>
parents: 482
diff changeset
86 cycle->new_log.log_level = NGX_LOG_ERR;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
87 cycle->old_cycle = old_cycle;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
88
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
89 cycle->conf_prefix.len = old_cycle->conf_prefix.len;
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
90 cycle->conf_prefix.data = ngx_pstrdup(pool, &old_cycle->conf_prefix);
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
91 if (cycle->conf_prefix.data == NULL) {
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
92 ngx_destroy_pool(pool);
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
93 return NULL;
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
94 }
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
95
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
96 cycle->prefix.len = old_cycle->prefix.len;
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
97 cycle->prefix.data = ngx_pstrdup(pool, &old_cycle->prefix);
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
98 if (cycle->prefix.data == NULL) {
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
99 ngx_destroy_pool(pool);
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
100 return NULL;
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
101 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
102
154
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
103 cycle->conf_file.len = old_cycle->conf_file.len;
382
984bb0b1399b nginx 0.7.3
Igor Sysoev <http://sysoev.ru>
parents: 376
diff changeset
104 cycle->conf_file.data = ngx_pnalloc(pool, old_cycle->conf_file.len + 1);
154
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
105 if (cycle->conf_file.data == NULL) {
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
106 ngx_destroy_pool(pool);
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
107 return NULL;
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
108 }
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
109 ngx_cpystrn(cycle->conf_file.data, old_cycle->conf_file.data,
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
110 old_cycle->conf_file.len + 1);
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
111
384
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
112 cycle->conf_param.len = old_cycle->conf_param.len;
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
113 cycle->conf_param.data = ngx_pstrdup(pool, &old_cycle->conf_param);
384
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
114 if (cycle->conf_param.data == NULL) {
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
115 ngx_destroy_pool(pool);
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
116 return NULL;
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
117 }
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
118
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
119
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
120 n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 28
diff changeset
121
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 28
diff changeset
122 cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *));
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 28
diff changeset
123 if (cycle->pathes.elts == NULL) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
124 ngx_destroy_pool(pool);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
125 return NULL;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
126 }
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 28
diff changeset
127
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
128 cycle->pathes.nelts = 0;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
129 cycle->pathes.size = sizeof(ngx_path_t *);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
130 cycle->pathes.nalloc = n;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
131 cycle->pathes.pool = pool;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
132
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
133
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
134 if (old_cycle->open_files.part.nelts) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
135 n = old_cycle->open_files.part.nelts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
136 for (part = old_cycle->open_files.part.next; part; part = part->next) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
137 n += part->nelts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
138 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
139
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
140 } else {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
141 n = 20;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
142 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
143
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
144 if (ngx_list_init(&cycle->open_files, pool, n, sizeof(ngx_open_file_t))
454
a8424ffa495c nginx 0.7.39
Igor Sysoev <http://sysoev.ru>
parents: 448
diff changeset
145 != NGX_OK)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
146 {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
147 ngx_destroy_pool(pool);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
148 return NULL;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
149 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
150
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
151
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
152 if (old_cycle->shared_memory.part.nelts) {
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
153 n = old_cycle->shared_memory.part.nelts;
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
154 for (part = old_cycle->shared_memory.part.next; part; part = part->next)
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
155 {
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
156 n += part->nelts;
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
157 }
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
158
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
159 } else {
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
160 n = 1;
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
161 }
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
162
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
163 if (ngx_list_init(&cycle->shared_memory, pool, n, sizeof(ngx_shm_zone_t))
454
a8424ffa495c nginx 0.7.39
Igor Sysoev <http://sysoev.ru>
parents: 448
diff changeset
164 != NGX_OK)
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
165 {
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
166 ngx_destroy_pool(pool);
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
167 return NULL;
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
168 }
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
169
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
170 n = old_cycle->listening.nelts ? old_cycle->listening.nelts : 10;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 28
diff changeset
171
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
172 cycle->listening.elts = ngx_pcalloc(pool, n * sizeof(ngx_listening_t));
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
173 if (cycle->listening.elts == NULL) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
174 ngx_destroy_pool(pool);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
175 return NULL;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
176 }
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 28
diff changeset
177
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
178 cycle->listening.nelts = 0;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
179 cycle->listening.size = sizeof(ngx_listening_t);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
180 cycle->listening.nalloc = n;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
181 cycle->listening.pool = pool;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
182
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
183
618
b9763778e212 nginx 0.9.7
Igor Sysoev <http://sysoev.ru>
parents: 596
diff changeset
184 ngx_queue_init(&cycle->reusable_connections_queue);
b9763778e212 nginx 0.9.7
Igor Sysoev <http://sysoev.ru>
parents: 596
diff changeset
185
b9763778e212 nginx 0.9.7
Igor Sysoev <http://sysoev.ru>
parents: 596
diff changeset
186
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
187 cycle->conf_ctx = ngx_pcalloc(pool, ngx_max_module * sizeof(void *));
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
188 if (cycle->conf_ctx == NULL) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
189 ngx_destroy_pool(pool);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
190 return NULL;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
191 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
192
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
193
376
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
194 if (gethostname(hostname, NGX_MAXHOSTNAMELEN) == -1) {
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
195 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "gethostname() failed");
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
196 ngx_destroy_pool(pool);
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
197 return NULL;
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
198 }
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
199
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
200 /* on Linux gethostname() silently truncates name that does not fit */
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
201
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
202 hostname[NGX_MAXHOSTNAMELEN - 1] = '\0';
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
203 cycle->hostname.len = ngx_strlen(hostname);
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
204
382
984bb0b1399b nginx 0.7.3
Igor Sysoev <http://sysoev.ru>
parents: 376
diff changeset
205 cycle->hostname.data = ngx_pnalloc(pool, cycle->hostname.len);
376
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
206 if (cycle->hostname.data == NULL) {
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
207 ngx_destroy_pool(pool);
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
208 return NULL;
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
209 }
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
210
538
1dcf6adad484 nginx 0.8.21
Igor Sysoev <http://sysoev.ru>
parents: 528
diff changeset
211 ngx_strlow(cycle->hostname.data, (u_char *) hostname, cycle->hostname.len);
376
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
212
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 356
diff changeset
213
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
214 for (i = 0; ngx_modules[i]; i++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
215 if (ngx_modules[i]->type != NGX_CORE_MODULE) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
216 continue;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
217 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
218
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
219 module = ngx_modules[i]->ctx;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
220
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
221 if (module->create_conf) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
222 rv = module->create_conf(cycle);
496
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
223 if (rv == NULL) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
224 ngx_destroy_pool(pool);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
225 return NULL;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
226 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
227 cycle->conf_ctx[ngx_modules[i]->index] = rv;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
228 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
229 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
230
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
231
356
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
232 senv = environ;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
233
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
234
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
235 ngx_memzero(&conf, sizeof(ngx_conf_t));
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
236 /* STUB: init array ? */
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 28
diff changeset
237 conf.args = ngx_array_create(pool, 10, sizeof(ngx_str_t));
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
238 if (conf.args == NULL) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
239 ngx_destroy_pool(pool);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
240 return NULL;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
241 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
242
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
243 conf.temp_pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
244 if (conf.temp_pool == NULL) {
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
245 ngx_destroy_pool(pool);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
246 return NULL;
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
247 }
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
248
154
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
249
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
250 conf.ctx = cycle->conf_ctx;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
251 conf.cycle = cycle;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
252 conf.pool = pool;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
253 conf.log = log;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
254 conf.module_type = NGX_CORE_MODULE;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
255 conf.cmd_type = NGX_MAIN_CONF;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
256
4
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 2
diff changeset
257 #if 0
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 2
diff changeset
258 log->log_level = NGX_LOG_DEBUG_ALL;
4b2dafa26fe2 nginx 0.1.2
Igor Sysoev <http://sysoev.ru>
parents: 2
diff changeset
259 #endif
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
260
384
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
261 if (ngx_conf_param(&conf) != NGX_CONF_OK) {
528
005a70f9573b nginx 0.8.16
Igor Sysoev <http://sysoev.ru>
parents: 498
diff changeset
262 environ = senv;
384
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
263 ngx_destroy_cycle_pools(&conf);
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
264 return NULL;
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
265 }
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
266
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
267 if (ngx_conf_parse(&conf, &cycle->conf_file) != NGX_CONF_OK) {
528
005a70f9573b nginx 0.8.16
Igor Sysoev <http://sysoev.ru>
parents: 498
diff changeset
268 environ = senv;
154
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
269 ngx_destroy_cycle_pools(&conf);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
270 return NULL;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
271 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
272
596
6c96fdd2dfc3 nginx 0.8.50
Igor Sysoev <http://sysoev.ru>
parents: 582
diff changeset
273 if (ngx_test_config && !ngx_quiet_mode) {
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
274 ngx_log_stderr(0, "the configuration file %s syntax is ok",
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
275 cycle->conf_file.data);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
276 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
277
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
278 for (i = 0; ngx_modules[i]; i++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
279 if (ngx_modules[i]->type != NGX_CORE_MODULE) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
280 continue;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
281 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
282
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
283 module = ngx_modules[i]->ctx;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
284
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
285 if (module->init_conf) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
286 if (module->init_conf(cycle, cycle->conf_ctx[ngx_modules[i]->index])
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
287 == NGX_CONF_ERROR)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
288 {
528
005a70f9573b nginx 0.8.16
Igor Sysoev <http://sysoev.ru>
parents: 498
diff changeset
289 environ = senv;
154
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
290 ngx_destroy_cycle_pools(&conf);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
291 return NULL;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
292 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
293 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
294 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
295
498
207ae3ff0444 nginx 0.8.1
Igor Sysoev <http://sysoev.ru>
parents: 496
diff changeset
296 if (ngx_process == NGX_PROCESS_SIGNALLER) {
207ae3ff0444 nginx 0.8.1
Igor Sysoev <http://sysoev.ru>
parents: 496
diff changeset
297 return cycle;
207ae3ff0444 nginx 0.8.1
Igor Sysoev <http://sysoev.ru>
parents: 496
diff changeset
298 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
299
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
300 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
301
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
302 if (ngx_test_config) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
303
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
304 if (ngx_create_pidfile(&ccf->pid, log) != NGX_OK) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
305 goto failed;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
306 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
307
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
308 } else if (!ngx_is_init_cycle(old_cycle)) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
309
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
310 /*
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
311 * we do not create the pid file in the first ngx_init_cycle() call
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
312 * because we need to write the demonized process pid
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
313 */
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
314
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
315 old_ccf = (ngx_core_conf_t *) ngx_get_conf(old_cycle->conf_ctx,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
316 ngx_core_module);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
317 if (ccf->pid.len != old_ccf->pid.len
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
318 || ngx_strcmp(ccf->pid.data, old_ccf->pid.data) != 0)
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
319 {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
320 /* new pid file name */
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
321
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
322 if (ngx_create_pidfile(&ccf->pid, log) != NGX_OK) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
323 goto failed;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
324 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
325
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
326 ngx_delete_pidfile(old_cycle);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
327 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
328 }
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
329
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
330
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
331 if (ngx_test_lockfile(cycle->lock_file.data, log) != NGX_OK) {
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
332 goto failed;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
333 }
16
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
334
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
335
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
336 if (ngx_create_pathes(cycle, ccf->user) != NGX_OK) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
337 goto failed;
16
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
338 }
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
339
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
340
484
ed5e10fb40fc nginx 0.7.54
Igor Sysoev <http://sysoev.ru>
parents: 482
diff changeset
341 if (cycle->new_log.file == NULL) {
ed5e10fb40fc nginx 0.7.54
Igor Sysoev <http://sysoev.ru>
parents: 482
diff changeset
342 cycle->new_log.file = ngx_conf_open_file(cycle, &error_log);
ed5e10fb40fc nginx 0.7.54
Igor Sysoev <http://sysoev.ru>
parents: 482
diff changeset
343 if (cycle->new_log.file == NULL) {
ed5e10fb40fc nginx 0.7.54
Igor Sysoev <http://sysoev.ru>
parents: 482
diff changeset
344 goto failed;
ed5e10fb40fc nginx 0.7.54
Igor Sysoev <http://sysoev.ru>
parents: 482
diff changeset
345 }
ed5e10fb40fc nginx 0.7.54
Igor Sysoev <http://sysoev.ru>
parents: 482
diff changeset
346 }
ed5e10fb40fc nginx 0.7.54
Igor Sysoev <http://sysoev.ru>
parents: 482
diff changeset
347
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
348 /* open the new files */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
349
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
350 part = &cycle->open_files.part;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
351 file = part->elts;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
352
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
353 for (i = 0; /* void */ ; i++) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
354
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
355 if (i >= part->nelts) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
356 if (part->next == NULL) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
357 break;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
358 }
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
359 part = part->next;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
360 file = part->elts;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
361 i = 0;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
362 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
363
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
364 if (file[i].name.len == 0) {
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
365 continue;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
366 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
367
470
6866b490272e nginx 0.7.47
Igor Sysoev <http://sysoev.ru>
parents: 454
diff changeset
368 file[i].fd = ngx_open_file(file[i].name.data,
6866b490272e nginx 0.7.47
Igor Sysoev <http://sysoev.ru>
parents: 454
diff changeset
369 NGX_FILE_APPEND,
6866b490272e nginx 0.7.47
Igor Sysoev <http://sysoev.ru>
parents: 454
diff changeset
370 NGX_FILE_CREATE_OR_OPEN,
276
c5c2b2883984 nginx 0.5.8
Igor Sysoev <http://sysoev.ru>
parents: 274
diff changeset
371 NGX_FILE_DEFAULT_ACCESS);
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
372
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
373 ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
374 "log: %p %d \"%s\"",
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
375 &file[i], file[i].fd, file[i].name.data);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
376
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
377 if (file[i].fd == NGX_INVALID_FILE) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
378 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
379 ngx_open_file_n " \"%s\" failed",
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
380 file[i].name.data);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
381 goto failed;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
382 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
383
478
f2c6a7373274 nginx 0.7.51
Igor Sysoev <http://sysoev.ru>
parents: 470
diff changeset
384 #if !(NGX_WIN32)
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
385 if (fcntl(file[i].fd, F_SETFD, FD_CLOEXEC) == -1) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
386 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
387 "fcntl(FD_CLOEXEC) \"%s\" failed",
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
388 file[i].name.data);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
389 goto failed;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
390 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
391 #endif
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
392 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
393
484
ed5e10fb40fc nginx 0.7.54
Igor Sysoev <http://sysoev.ru>
parents: 482
diff changeset
394 cycle->log = &cycle->new_log;
ed5e10fb40fc nginx 0.7.54
Igor Sysoev <http://sysoev.ru>
parents: 482
diff changeset
395 pool->log = &cycle->new_log;
440
6281966854a5 nginx 0.7.32
Igor Sysoev <http://sysoev.ru>
parents: 438
diff changeset
396
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
397
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
398 /* create shared memory */
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
399
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
400 part = &cycle->shared_memory.part;
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
401 shm_zone = part->elts;
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
402
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
403 for (i = 0; /* void */ ; i++) {
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
404
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
405 if (i >= part->nelts) {
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
406 if (part->next == NULL) {
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
407 break;
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
408 }
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
409 part = part->next;
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
410 shm_zone = part->elts;
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
411 i = 0;
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
412 }
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
413
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
414 if (shm_zone[i].shm.size == 0) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
415 ngx_log_error(NGX_LOG_EMERG, log, 0,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
416 "zero size shared memory zone \"%V\"",
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
417 &shm_zone[i].shm.name);
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
418 goto failed;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
419 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
420
274
052a7b1d40e5 nginx 0.5.7
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
421 if (shm_zone[i].init == NULL) {
052a7b1d40e5 nginx 0.5.7
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
422 /* unused shared zone */
052a7b1d40e5 nginx 0.5.7
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
423 continue;
052a7b1d40e5 nginx 0.5.7
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
424 }
052a7b1d40e5 nginx 0.5.7
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
425
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
426 shm_zone[i].shm.log = cycle->log;
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
427
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
428 opart = &old_cycle->shared_memory.part;
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
429 oshm_zone = opart->elts;
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
430
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
431 for (n = 0; /* void */ ; n++) {
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
432
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
433 if (n >= opart->nelts) {
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
434 if (opart->next == NULL) {
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
435 break;
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
436 }
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
437 opart = opart->next;
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
438 oshm_zone = opart->elts;
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
439 n = 0;
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
440 }
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
441
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
442 if (shm_zone[i].shm.name.len != oshm_zone[n].shm.name.len) {
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
443 continue;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
444 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
445
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
446 if (ngx_strncmp(shm_zone[i].shm.name.data,
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
447 oshm_zone[n].shm.name.data,
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
448 shm_zone[i].shm.name.len)
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
449 != 0)
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
450 {
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
451 continue;
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
452 }
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
453
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
454 if (shm_zone[i].shm.size == oshm_zone[n].shm.size) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
455 shm_zone[i].shm.addr = oshm_zone[n].shm.addr;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
456
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
457 if (shm_zone[i].init(&shm_zone[i], oshm_zone[n].data)
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
458 != NGX_OK)
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
459 {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
460 goto failed;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
461 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
462
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
463 goto shm_zone_found;
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
464 }
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
465
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
466 ngx_shm_free(&oshm_zone[n].shm);
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
467
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
468 break;
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
469 }
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
470
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
471 if (ngx_shm_alloc(&shm_zone[i].shm) != NGX_OK) {
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
472 goto failed;
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
473 }
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
474
496
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
475 if (ngx_init_zone_pool(cycle, &shm_zone[i]) != NGX_OK) {
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
476 goto failed;
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
477 }
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
478
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
479 if (shm_zone[i].init(&shm_zone[i], NULL) != NGX_OK) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
480 goto failed;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
481 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
482
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
483 shm_zone_found:
258
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
484
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
485 continue;
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
486 }
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
487
6ae1357b7b7c nginx 0.4.14
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
488
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
489 /* handle the listening sockets */
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
490
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
491 if (old_cycle->listening.nelts) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
492 ls = old_cycle->listening.elts;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
493 for (i = 0; i < old_cycle->listening.nelts; i++) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
494 ls[i].remain = 0;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
495 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
496
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
497 nls = cycle->listening.elts;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
498 for (n = 0; n < cycle->listening.nelts; n++) {
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
499
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
500 for (i = 0; i < old_cycle->listening.nelts; i++) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
501 if (ls[i].ignore) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
502 continue;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
503 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
504
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
505 if (ngx_cmp_sockaddr(nls[n].sockaddr, ls[i].sockaddr) == NGX_OK)
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
506 {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
507 nls[n].fd = ls[i].fd;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
508 nls[n].previous = &ls[i];
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
509 ls[i].remain = 1;
72
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
510
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
511 if (ls[n].backlog != nls[i].backlog) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
512 nls[n].listen = 1;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
513 }
86
962c43960644 nginx 0.1.43
Igor Sysoev <http://sysoev.ru>
parents: 74
diff changeset
514
72
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
515 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
516
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
517 /*
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
518 * FreeBSD, except the most recent versions,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
519 * could not remove accept filter
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
520 */
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
521 nls[n].deferred_accept = ls[i].deferred_accept;
72
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
522
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
523 if (ls[i].accept_filter && nls[n].accept_filter) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
524 if (ngx_strcmp(ls[i].accept_filter,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
525 nls[n].accept_filter)
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
526 != 0)
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
527 {
72
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
528 nls[n].delete_deferred = 1;
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
529 nls[n].add_deferred = 1;
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
530 }
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
531
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
532 } else if (ls[i].accept_filter) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
533 nls[n].delete_deferred = 1;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
534
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
535 } else if (nls[n].accept_filter) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
536 nls[n].add_deferred = 1;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
537 }
72
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
538 #endif
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
539
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
540 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
541
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
542 if (ls[n].deferred_accept && !nls[n].deferred_accept) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
543 nls[n].delete_deferred = 1;
72
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
544
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
545 } else if (ls[i].deferred_accept != nls[n].deferred_accept)
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
546 {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
547 nls[n].add_deferred = 1;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
548 }
72
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
549 #endif
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
550 break;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
551 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
552 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
553
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
554 if (nls[n].fd == -1) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
555 nls[n].open = 1;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
556 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
557 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
558
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
559 } else {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
560 ls = cycle->listening.elts;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
561 for (i = 0; i < cycle->listening.nelts; i++) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
562 ls[i].open = 1;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
563 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
564 if (ls[i].accept_filter) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
565 ls[i].add_deferred = 1;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
566 }
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
567 #endif
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
568 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
569 if (ls[i].deferred_accept) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
570 ls[i].add_deferred = 1;
72
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
571 }
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
572 #endif
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
573 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
574 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
575
498
207ae3ff0444 nginx 0.8.1
Igor Sysoev <http://sysoev.ru>
parents: 496
diff changeset
576 if (ngx_open_listening_sockets(cycle) != NGX_OK) {
207ae3ff0444 nginx 0.8.1
Igor Sysoev <http://sysoev.ru>
parents: 496
diff changeset
577 goto failed;
207ae3ff0444 nginx 0.8.1
Igor Sysoev <http://sysoev.ru>
parents: 496
diff changeset
578 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
579
498
207ae3ff0444 nginx 0.8.1
Igor Sysoev <http://sysoev.ru>
parents: 496
diff changeset
580 if (!ngx_test_config) {
207ae3ff0444 nginx 0.8.1
Igor Sysoev <http://sysoev.ru>
parents: 496
diff changeset
581 ngx_configure_listening_sockets(cycle);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
582 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
583
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
584
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
585 /* commit the new cycle configuration */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
586
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
587 if (!ngx_use_stderr && cycle->log->file->fd != ngx_stderr) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
588
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
589 if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
590 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
591 ngx_set_stderr_n " failed");
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
592 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
593 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
594
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
595 pool->log = cycle->log;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
596
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
597 for (i = 0; ngx_modules[i]; i++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
598 if (ngx_modules[i]->init_module) {
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
599 if (ngx_modules[i]->init_module(cycle) != NGX_OK) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
600 /* fatal */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
601 exit(1);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
602 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
603 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
604 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
605
16
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
606
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
607 /* close and delete stuff that lefts from an old cycle */
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
608
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
609 /* free the unnecessary shared memory */
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
610
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
611 opart = &old_cycle->shared_memory.part;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
612 oshm_zone = opart->elts;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
613
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
614 for (i = 0; /* void */ ; i++) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
615
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
616 if (i >= opart->nelts) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
617 if (opart->next == NULL) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
618 goto old_shm_zone_done;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
619 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
620 opart = opart->next;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
621 oshm_zone = opart->elts;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
622 i = 0;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
623 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
624
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
625 part = &cycle->shared_memory.part;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
626 shm_zone = part->elts;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
627
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
628 for (n = 0; /* void */ ; n++) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
629
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
630 if (n >= part->nelts) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
631 if (part->next == NULL) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
632 break;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
633 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
634 part = part->next;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
635 shm_zone = part->elts;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
636 n = 0;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
637 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
638
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
639 if (oshm_zone[i].shm.name.len == shm_zone[n].shm.name.len
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
640 && ngx_strncmp(oshm_zone[i].shm.name.data,
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
641 shm_zone[n].shm.name.data,
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
642 oshm_zone[i].shm.name.len)
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
643 == 0)
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
644 {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
645 goto live_shm_zone;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
646 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
647 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
648
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
649 ngx_shm_free(&oshm_zone[i].shm);
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
650
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
651 live_shm_zone:
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
652
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
653 continue;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
654 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
655
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
656 old_shm_zone_done:
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
657
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
658
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
659 /* close the unnecessary listening sockets */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
660
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
661 ls = old_cycle->listening.elts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
662 for (i = 0; i < old_cycle->listening.nelts; i++) {
498
207ae3ff0444 nginx 0.8.1
Igor Sysoev <http://sysoev.ru>
parents: 496
diff changeset
663
207ae3ff0444 nginx 0.8.1
Igor Sysoev <http://sysoev.ru>
parents: 496
diff changeset
664 if (ls[i].remain || ls[i].fd == -1) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
665 continue;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
666 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
667
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
668 if (ngx_close_socket(ls[i].fd) == -1) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
669 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
92
45945fa8b8ba nginx 0.2.0
Igor Sysoev <http://sysoev.ru>
parents: 86
diff changeset
670 ngx_close_socket_n " listening socket on %V failed",
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
671 &ls[i].addr_text);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
672 }
576
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
673
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
674 #if (NGX_HAVE_UNIX_DOMAIN)
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
675
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
676 if (ls[i].sockaddr->sa_family == AF_UNIX) {
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
677 u_char *name;
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
678
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
679 name = ls[i].addr_text.data + sizeof("unix:") - 1;
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
680
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
681 ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
682 "deleting socket %s", name);
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
683
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
684 if (ngx_delete_file(name) == -1) {
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
685 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
686 ngx_delete_file_n " %s failed", name);
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
687 }
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
688 }
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
689
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
690 #endif
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
691 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
692
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
693
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
694 /* close the unnecessary open files */
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
695
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
696 part = &old_cycle->open_files.part;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
697 file = part->elts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
698
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
699 for (i = 0; /* void */ ; i++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
700
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
701 if (i >= part->nelts) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
702 if (part->next == NULL) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
703 break;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
704 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
705 part = part->next;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
706 file = part->elts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
707 i = 0;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
708 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
709
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
710 if (file[i].fd == NGX_INVALID_FILE || file[i].fd == ngx_stderr) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
711 continue;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
712 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
713
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
714 if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
715 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
716 ngx_close_file_n " \"%s\" failed",
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
717 file[i].name.data);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
718 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
719 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
720
142
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
721 ngx_destroy_pool(conf.temp_pool);
84910468f6de nginx 0.3.18
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
722
154
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
723 if (ngx_process == NGX_PROCESS_MASTER || ngx_is_init_cycle(old_cycle)) {
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
724
356
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
725 /*
528
005a70f9573b nginx 0.8.16
Igor Sysoev <http://sysoev.ru>
parents: 498
diff changeset
726 * perl_destruct() frees environ, if it is not the same as it was at
005a70f9573b nginx 0.8.16
Igor Sysoev <http://sysoev.ru>
parents: 498
diff changeset
727 * perl_construct() time, therefore we save the previous cycle
356
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
728 * environment before ngx_conf_parse() where it will be changed.
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
729 */
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
730
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
731 env = environ;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
732 environ = senv;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
733
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
734 ngx_destroy_pool(old_cycle->pool);
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
735 cycle->old_cycle = NULL;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
736
356
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
737 environ = env;
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
738
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
739 return cycle;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
740 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
741
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
742
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
743 if (ngx_temp_pool == NULL) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
744 ngx_temp_pool = ngx_create_pool(128, cycle->log);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
745 if (ngx_temp_pool == NULL) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
746 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
747 "can not create ngx_temp_pool");
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
748 exit(1);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
749 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
750
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
751 n = 10;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
752 ngx_old_cycles.elts = ngx_pcalloc(ngx_temp_pool,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
753 n * sizeof(ngx_cycle_t *));
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
754 if (ngx_old_cycles.elts == NULL) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
755 exit(1);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
756 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
757 ngx_old_cycles.nelts = 0;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
758 ngx_old_cycles.size = sizeof(ngx_cycle_t *);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
759 ngx_old_cycles.nalloc = n;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
760 ngx_old_cycles.pool = ngx_temp_pool;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
761
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 56
diff changeset
762 ngx_cleaner_event.handler = ngx_clean_old_cycles;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
763 ngx_cleaner_event.log = cycle->log;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
764 ngx_cleaner_event.data = &dumb;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
765 dumb.fd = (ngx_socket_t) -1;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
766 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
767
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
768 ngx_temp_pool->log = cycle->log;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
769
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 28
diff changeset
770 old = ngx_array_push(&ngx_old_cycles);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
771 if (old == NULL) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
772 exit(1);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
773 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
774 *old = old_cycle;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
775
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
776 if (!ngx_cleaner_event.timer_set) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
777 ngx_add_timer(&ngx_cleaner_event, 30000);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
778 ngx_cleaner_event.timer_set = 1;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
779 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
780
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
781 return cycle;
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
782
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
783
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
784 failed:
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
785
296
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 284
diff changeset
786 if (!ngx_is_init_cycle(old_cycle)) {
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 284
diff changeset
787 old_ccf = (ngx_core_conf_t *) ngx_get_conf(old_cycle->conf_ctx,
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 284
diff changeset
788 ngx_core_module);
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 284
diff changeset
789 if (old_ccf->environment) {
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 284
diff changeset
790 environ = old_ccf->environment;
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 284
diff changeset
791 }
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 284
diff changeset
792 }
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 284
diff changeset
793
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
794 /* rollback the new cycle configuration */
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
795
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
796 part = &cycle->open_files.part;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
797 file = part->elts;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
798
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
799 for (i = 0; /* void */ ; i++) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
800
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
801 if (i >= part->nelts) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
802 if (part->next == NULL) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
803 break;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
804 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
805 part = part->next;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
806 file = part->elts;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
807 i = 0;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
808 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
809
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
810 if (file[i].fd == NGX_INVALID_FILE || file[i].fd == ngx_stderr) {
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
811 continue;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
812 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
813
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
814 if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
815 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
816 ngx_close_file_n " \"%s\" failed",
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
817 file[i].name.data);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
818 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
819 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
820
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
821 if (ngx_test_config) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
822 ngx_destroy_cycle_pools(&conf);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
823 return NULL;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
824 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
825
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
826 ls = cycle->listening.elts;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
827 for (i = 0; i < cycle->listening.nelts; i++) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
828 if (ls[i].fd == -1 || !ls[i].open) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
829 continue;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
830 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
831
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
832 if (ngx_close_socket(ls[i].fd) == -1) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
833 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
834 ngx_close_socket_n " %V failed",
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
835 &ls[i].addr_text);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
836 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
837 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
838
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
839 ngx_destroy_cycle_pools(&conf);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
840
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
841 return NULL;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
842 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
843
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
844
154
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
845 static void
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
846 ngx_destroy_cycle_pools(ngx_conf_t *conf)
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
847 {
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
848 ngx_destroy_pool(conf->temp_pool);
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
849 ngx_destroy_pool(conf->pool);
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
850 }
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
851
bb61aa162c6b nginx 0.3.24
Igor Sysoev <http://sysoev.ru>
parents: 142
diff changeset
852
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
853 static ngx_int_t
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
854 ngx_cmp_sockaddr(struct sockaddr *sa1, struct sockaddr *sa2)
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
855 {
448
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
856 struct sockaddr_in *sin1, *sin2;
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
857 #if (NGX_HAVE_INET6)
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
858 struct sockaddr_in6 *sin61, *sin62;
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
859 #endif
576
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
860 #if (NGX_HAVE_UNIX_DOMAIN)
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
861 struct sockaddr_un *saun1, *saun2;
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
862 #endif
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
863
448
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
864 if (sa1->sa_family != sa2->sa_family) {
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
865 return NGX_DECLINED;
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
866 }
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
867
448
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
868 switch (sa1->sa_family) {
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
869
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
870 #if (NGX_HAVE_INET6)
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
871 case AF_INET6:
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
872 sin61 = (struct sockaddr_in6 *) sa1;
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
873 sin62 = (struct sockaddr_in6 *) sa2;
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
874
582
c456a023113c nginx 0.8.43
Igor Sysoev <http://sysoev.ru>
parents: 576
diff changeset
875 if (sin61->sin6_port != sin62->sin6_port) {
448
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
876 return NGX_DECLINED;
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
877 }
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
878
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
879 if (ngx_memcmp(&sin61->sin6_addr, &sin62->sin6_addr, 16) != 0) {
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
880 return NGX_DECLINED;
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
881 }
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
882
448
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
883 break;
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
884 #endif
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
885
576
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
886 #if (NGX_HAVE_UNIX_DOMAIN)
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
887 case AF_UNIX:
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
888 saun1 = (struct sockaddr_un *) sa1;
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
889 saun2 = (struct sockaddr_un *) sa2;
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
890
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
891 if (ngx_memcmp(&saun1->sun_path, &saun2->sun_path,
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
892 sizeof(saun1->sun_path))
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
893 != 0)
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
894 {
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
895 return NGX_DECLINED;
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
896 }
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
897
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
898 break;
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
899 #endif
01f2313e34f1 nginx 0.8.40
Igor Sysoev <http://sysoev.ru>
parents: 566
diff changeset
900
448
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
901 default: /* AF_INET */
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
902
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
903 sin1 = (struct sockaddr_in *) sa1;
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
904 sin2 = (struct sockaddr_in *) sa2;
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
905
448
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
906 if (sin1->sin_port != sin2->sin_port) {
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
907 return NGX_DECLINED;
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
908 }
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
909
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
910 if (sin1->sin_addr.s_addr != sin2->sin_addr.s_addr) {
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
911 return NGX_DECLINED;
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
912 }
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
913
76a79816b771 nginx 0.7.36
Igor Sysoev <http://sysoev.ru>
parents: 440
diff changeset
914 break;
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
915 }
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
916
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
917 return NGX_OK;
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
918 }
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
919
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
920
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
921 static ngx_int_t
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
922 ngx_init_zone_pool(ngx_cycle_t *cycle, ngx_shm_zone_t *zn)
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
923 {
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
924 u_char *file;
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
925 ngx_slab_pool_t *sp;
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
926
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
927 sp = (ngx_slab_pool_t *) zn->shm.addr;
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
928
496
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
929 if (zn->shm.exists) {
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
930
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
931 if (sp == sp->addr) {
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
932 return NGX_OK;
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
933 }
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
934
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
935 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
936 "shared zone \"%V\" has no equal addresses: %p vs %p",
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
937 &zn->shm.name, sp->addr, sp);
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
938 return NGX_ERROR;
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
939 }
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
940
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
941 sp->end = zn->shm.addr + zn->shm.size;
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
942 sp->min_shift = 3;
496
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 486
diff changeset
943 sp->addr = zn->shm.addr;
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
944
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
945 #if (NGX_HAVE_ATOMIC_OPS)
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
946
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
947 file = NULL;
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
948
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
949 #else
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
950
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
951 file = ngx_pnalloc(cycle->pool, cycle->lock_file.len + zn->shm.name.len);
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
952 if (file == NULL) {
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
953 return NGX_ERROR;
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
954 }
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
955
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
956 (void) ngx_sprintf(file, "%V%V%Z", &cycle->lock_file, &zn->shm.name);
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
957
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
958 #endif
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
959
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
960 if (ngx_shmtx_create(&sp->mutex, (void *) &sp->lock, file) != NGX_OK) {
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
961 return NGX_ERROR;
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
962 }
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
963
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
964 ngx_slab_init(sp);
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
965
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
966 return NGX_OK;
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
967 }
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
968
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
969
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
970 ngx_int_t
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
971 ngx_create_pidfile(ngx_str_t *name, ngx_log_t *log)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
972 {
478
f2c6a7373274 nginx 0.7.51
Igor Sysoev <http://sysoev.ru>
parents: 470
diff changeset
973 size_t len;
f2c6a7373274 nginx 0.7.51
Igor Sysoev <http://sysoev.ru>
parents: 470
diff changeset
974 ngx_uint_t create;
f2c6a7373274 nginx 0.7.51
Igor Sysoev <http://sysoev.ru>
parents: 470
diff changeset
975 ngx_file_t file;
f2c6a7373274 nginx 0.7.51
Igor Sysoev <http://sysoev.ru>
parents: 470
diff changeset
976 u_char pid[NGX_INT64_LEN + 2];
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
977
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
978 if (ngx_process > NGX_PROCESS_MASTER) {
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
979 return NGX_OK;
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
980 }
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
981
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
982 ngx_memzero(&file, sizeof(ngx_file_t));
92
45945fa8b8ba nginx 0.2.0
Igor Sysoev <http://sysoev.ru>
parents: 86
diff changeset
983
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
984 file.name = *name;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
985 file.log = log;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
986
478
f2c6a7373274 nginx 0.7.51
Igor Sysoev <http://sysoev.ru>
parents: 470
diff changeset
987 create = ngx_test_config ? NGX_FILE_CREATE_OR_OPEN : NGX_FILE_TRUNCATE;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
988
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
989 file.fd = ngx_open_file(file.name.data, NGX_FILE_RDWR,
478
f2c6a7373274 nginx 0.7.51
Igor Sysoev <http://sysoev.ru>
parents: 470
diff changeset
990 create, NGX_FILE_DEFAULT_ACCESS);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
991
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
992 if (file.fd == NGX_INVALID_FILE) {
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
993 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
994 ngx_open_file_n " \"%s\" failed", file.name.data);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
995 return NGX_ERROR;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
996 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
997
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
998 if (!ngx_test_config) {
270
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 258
diff changeset
999 len = ngx_snprintf(pid, NGX_INT64_LEN + 2, "%P%N", ngx_pid) - pid;
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
1000
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1001 if (ngx_write_file(&file, pid, len, 0) == NGX_ERROR) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1002 return NGX_ERROR;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1003 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1004 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1005
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1006 if (ngx_close_file(file.fd) == NGX_FILE_ERROR) {
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1007 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1008 ngx_close_file_n " \"%s\" failed", file.name.data);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1009 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1010
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1011 return NGX_OK;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1012 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1013
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1014
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
1015 void
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
1016 ngx_delete_pidfile(ngx_cycle_t *cycle)
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1017 {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1018 u_char *name;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1019 ngx_core_conf_t *ccf;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1020
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1021 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1022
92
45945fa8b8ba nginx 0.2.0
Igor Sysoev <http://sysoev.ru>
parents: 86
diff changeset
1023 name = ngx_new_binary ? ccf->oldpid.data : ccf->pid.data;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1024
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1025 if (ngx_delete_file(name) == NGX_FILE_ERROR) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1026 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1027 ngx_delete_file_n " \"%s\" failed", name);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1028 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1029 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1030
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1031
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1032 ngx_int_t
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1033 ngx_signal_process(ngx_cycle_t *cycle, char *sig)
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1034 {
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1035 ssize_t n;
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1036 ngx_int_t pid;
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1037 ngx_file_t file;
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1038 ngx_core_conf_t *ccf;
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1039 u_char buf[NGX_INT64_LEN + 2];
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1040
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1041 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "signal process started");
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1042
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1043 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1044
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1045 file.name = ccf->pid;
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1046 file.log = cycle->log;
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1047
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1048 file.fd = ngx_open_file(file.name.data, NGX_FILE_RDONLY,
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1049 NGX_FILE_OPEN, NGX_FILE_DEFAULT_ACCESS);
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1050
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1051 if (file.fd == NGX_INVALID_FILE) {
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1052 ngx_log_error(NGX_LOG_ERR, cycle->log, ngx_errno,
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1053 ngx_open_file_n " \"%s\" failed", file.name.data);
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1054 return 1;
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1055 }
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1056
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1057 n = ngx_read_file(&file, buf, NGX_INT64_LEN + 2, 0);
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1058
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1059 if (ngx_close_file(file.fd) == NGX_FILE_ERROR) {
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1060 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1061 ngx_close_file_n " \"%s\" failed", file.name.data);
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1062 }
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1063
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1064 if (n == NGX_ERROR) {
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1065 return 1;
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1066 }
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1067
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1068 while (n-- && (buf[n] == CR || buf[n] == LF)) { /* void */ }
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1069
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1070 pid = ngx_atoi(buf, ++n);
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1071
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1072 if (pid == NGX_ERROR) {
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1073 ngx_log_error(NGX_LOG_ERR, cycle->log, 0,
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1074 "invalid PID number \"%*s\" in \"%s\"",
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1075 n, buf, file.name.data);
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1076 return 1;
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1077 }
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1078
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1079 return ngx_os_signal_process(cycle, sig, pid);
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1080
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1081 }
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1082
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1083
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1084 static ngx_int_t
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1085 ngx_test_lockfile(u_char *file, ngx_log_t *log)
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1086 {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1087 #if !(NGX_HAVE_ATOMIC_OPS)
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1088 ngx_fd_t fd;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1089
284
3dbecd747fbb nginx 0.5.12
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
1090 fd = ngx_open_file(file, NGX_FILE_RDWR, NGX_FILE_CREATE_OR_OPEN,
3dbecd747fbb nginx 0.5.12
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
1091 NGX_FILE_DEFAULT_ACCESS);
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1092
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1093 if (fd == NGX_INVALID_FILE) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1094 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1095 ngx_open_file_n " \"%s\" failed", file);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1096 return NGX_ERROR;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1097 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1098
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1099 if (ngx_close_file(fd) == NGX_FILE_ERROR) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1100 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1101 ngx_close_file_n " \"%s\" failed", file);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1102 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1103
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1104 if (ngx_delete_file(file) == NGX_FILE_ERROR) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1105 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1106 ngx_delete_file_n " \"%s\" failed", file);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1107 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1108
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1109 #endif
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1110
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1111 return NGX_OK;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1112 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1113
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 156
diff changeset
1114
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
1115 void
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
1116 ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1117 {
418
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1118 ssize_t n, len;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1119 ngx_fd_t fd;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1120 ngx_uint_t i;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1121 ngx_list_part_t *part;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1122 ngx_open_file_t *file;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1123
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1124 part = &cycle->open_files.part;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1125 file = part->elts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1126
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1127 for (i = 0; /* void */ ; i++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1128
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1129 if (i >= part->nelts) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1130 if (part->next == NULL) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1131 break;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1132 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1133 part = part->next;
72
b31656313b59 nginx 0.1.36
Igor Sysoev <http://sysoev.ru>
parents: 66
diff changeset
1134 file = part->elts;
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1135 i = 0;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1136 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1137
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
1138 if (file[i].name.len == 0) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1139 continue;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1140 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1141
418
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1142 len = file[i].pos - file[i].buffer;
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1143
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1144 if (file[i].buffer && len != 0) {
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1145
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1146 n = ngx_write_fd(file[i].fd, file[i].buffer, len);
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1147
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1148 if (n == NGX_FILE_ERROR) {
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1149 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1150 ngx_write_fd_n " to \"%s\" failed",
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1151 file[i].name.data);
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1152
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1153 } else if (n != len) {
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1154 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1155 ngx_write_fd_n " to \"%s\" was incomplete: %z of %uz",
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1156 file[i].name.data, n, len);
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1157 }
ff86d646f9df nginx 0.7.21
Igor Sysoev <http://sysoev.ru>
parents: 404
diff changeset
1158
120
e85dca77c46a nginx 0.3.7
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
1159 file[i].pos = file[i].buffer;
e85dca77c46a nginx 0.3.7
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
1160 }
e85dca77c46a nginx 0.3.7
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
1161
470
6866b490272e nginx 0.7.47
Igor Sysoev <http://sysoev.ru>
parents: 454
diff changeset
1162 fd = ngx_open_file(file[i].name.data, NGX_FILE_APPEND,
6866b490272e nginx 0.7.47
Igor Sysoev <http://sysoev.ru>
parents: 454
diff changeset
1163 NGX_FILE_CREATE_OR_OPEN, NGX_FILE_DEFAULT_ACCESS);
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1164
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1165 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1166 "reopen file \"%s\", old:%d new:%d",
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1167 file[i].name.data, file[i].fd, fd);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1168
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1169 if (fd == NGX_INVALID_FILE) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1170 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1171 ngx_open_file_n " \"%s\" failed", file[i].name.data);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1172 continue;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1173 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1174
478
f2c6a7373274 nginx 0.7.51
Igor Sysoev <http://sysoev.ru>
parents: 470
diff changeset
1175 #if !(NGX_WIN32)
66
818201e5a553 nginx 0.1.33
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
1176 if (user != (ngx_uid_t) NGX_CONF_UNSET_UINT) {
356
b743d290eb3b nginx 0.6.22
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
1177 ngx_file_info_t fi;
2
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1178
484
ed5e10fb40fc nginx 0.7.54
Igor Sysoev <http://sysoev.ru>
parents: 482
diff changeset
1179 if (ngx_file_info((const char *) file[i].name.data, &fi)
ed5e10fb40fc nginx 0.7.54
Igor Sysoev <http://sysoev.ru>
parents: 482
diff changeset
1180 == NGX_FILE_ERROR)
ed5e10fb40fc nginx 0.7.54
Igor Sysoev <http://sysoev.ru>
parents: 482
diff changeset
1181 {
2
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1182 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1183 ngx_file_info_n " \"%s\" failed",
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1184 file[i].name.data);
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1185
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1186 if (ngx_close_file(fd) == NGX_FILE_ERROR) {
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1187 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1188 ngx_close_file_n " \"%s\" failed",
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1189 file[i].name.data);
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1190 }
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1191 }
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1192
16
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1193 if (fi.st_uid != user) {
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1194 if (chown((const char *) file[i].name.data, user, -1) == -1) {
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1195 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1196 "chown(\"%s\", %d) failed",
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1197 file[i].name.data, user);
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1198
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1199 if (ngx_close_file(fd) == NGX_FILE_ERROR) {
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1200 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1201 ngx_close_file_n " \"%s\" failed",
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1202 file[i].name.data);
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1203 }
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1204 }
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1205 }
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1206
2
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1207 if ((fi.st_mode & (S_IRUSR|S_IWUSR)) != (S_IRUSR|S_IWUSR)) {
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1208
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1209 fi.st_mode |= (S_IRUSR|S_IWUSR);
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1210
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1211 if (chmod((const char *) file[i].name.data, fi.st_mode) == -1) {
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1212 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
16
74b1868dd3cd nginx 0.1.8
Igor Sysoev <http://sysoev.ru>
parents: 10
diff changeset
1213 "chmod() \"%s\" failed", file[i].name.data);
2
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1214
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1215 if (ngx_close_file(fd) == NGX_FILE_ERROR) {
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1216 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1217 ngx_close_file_n " \"%s\" failed",
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1218 file[i].name.data);
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1219 }
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1220 }
cc9f381affaa nginx 0.1.1
Igor Sysoev <http://sysoev.ru>
parents: 0
diff changeset
1221 }
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1222 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1223
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1224 if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1225 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1226 "fcntl(FD_CLOEXEC) \"%s\" failed",
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1227 file[i].name.data);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1228
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1229 if (ngx_close_file(fd) == NGX_FILE_ERROR) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1230 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1231 ngx_close_file_n " \"%s\" failed",
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1232 file[i].name.data);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1233 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1234
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1235 continue;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1236 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1237 #endif
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1238
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1239 if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1240 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1241 ngx_close_file_n " \"%s\" failed",
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1242 file[i].name.data);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1243 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1244
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1245 file[i].fd = fd;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1246 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1247
10
46833bd150cb nginx 0.1.5
Igor Sysoev <http://sysoev.ru>
parents: 4
diff changeset
1248 #if !(NGX_WIN32)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1249
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1250 if (cycle->log->file->fd != STDERR_FILENO) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1251 if (dup2(cycle->log->file->fd, STDERR_FILENO) == -1) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1252 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1253 "dup2(STDERR) failed");
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1254 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1255 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1256
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1257 #endif
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1258 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1259
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1260
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1261 ngx_shm_zone_t *
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1262 ngx_shared_memory_add(ngx_conf_t *cf, ngx_str_t *name, size_t size, void *tag)
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1263 {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1264 ngx_uint_t i;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1265 ngx_shm_zone_t *shm_zone;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1266 ngx_list_part_t *part;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1267
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1268 part = &cf->cycle->shared_memory.part;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1269 shm_zone = part->elts;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1270
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1271 for (i = 0; /* void */ ; i++) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1273 if (i >= part->nelts) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1274 if (part->next == NULL) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1275 break;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1276 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1277 part = part->next;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1278 shm_zone = part->elts;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1279 i = 0;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1280 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1281
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
1282 if (name->len != shm_zone[i].shm.name.len) {
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1283 continue;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1284 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1285
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
1286 if (ngx_strncmp(name->data, shm_zone[i].shm.name.data, name->len)
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
1287 != 0)
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
1288 {
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1289 continue;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1290 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1291
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1292 if (size && size != shm_zone[i].shm.size) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1293 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
1294 "the size %uz of shared memory zone \"%V\" "
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
1295 "conflicts with already declared size %uz",
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
1296 size, &shm_zone[i].shm.name, shm_zone[i].shm.size);
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1297 return NULL;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1298 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1299
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1300 if (tag != shm_zone[i].tag) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1301 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
1302 "the shared memory zone \"%V\" is "
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
1303 "already declared for a different use",
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
1304 &shm_zone[i].shm.name);
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1305 return NULL;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1306 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1307
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1308 return &shm_zone[i];
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1309 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1310
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1311 shm_zone = ngx_list_push(&cf->cycle->shared_memory);
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1312
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1313 if (shm_zone == NULL) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1314 return NULL;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1315 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1316
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1317 shm_zone->data = NULL;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1318 shm_zone->shm.log = cf->cycle->log;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1319 shm_zone->shm.size = size;
480
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
1320 shm_zone->shm.name = *name;
549994537f15 nginx 0.7.52
Igor Sysoev <http://sysoev.ru>
parents: 478
diff changeset
1321 shm_zone->shm.exists = 0;
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1322 shm_zone->init = NULL;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1323 shm_zone->tag = tag;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1324
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1325 return shm_zone;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1326 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1327
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
1328
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
1329 static void
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
1330 ngx_clean_old_cycles(ngx_event_t *ev)
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1331 {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1332 ngx_uint_t i, n, found, live;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1333 ngx_log_t *log;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1334 ngx_cycle_t **cycle;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1335
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1336 log = ngx_cycle->log;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1337 ngx_temp_pool->log = log;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1338
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1339 ngx_log_debug0(NGX_LOG_DEBUG_CORE, log, 0, "clean old cycles");
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1340
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1341 live = 0;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1342
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1343 cycle = ngx_old_cycles.elts;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1344 for (i = 0; i < ngx_old_cycles.nelts; i++) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1345
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1346 if (cycle[i] == NULL) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1347 continue;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1348 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1349
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1350 found = 0;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1351
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1352 for (n = 0; n < cycle[i]->connection_n; n++) {
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 92
diff changeset
1353 if (cycle[i]->connections[n].fd != (ngx_socket_t) -1) {
0
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1354 found = 1;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1355
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1356 ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "live fd:%d", n);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1357
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1358 break;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1359 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1360 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1361
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1362 if (found) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1363 live = 1;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1364 continue;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1365 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1366
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1367 ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "clean old cycle: %d", i);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1368
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1369 ngx_destroy_pool(cycle[i]->pool);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1370 cycle[i] = NULL;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1371 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1372
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1373 ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "old cycles status: %d", live);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1374
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1375 if (live) {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1376 ngx_add_timer(ev, 30000);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1377
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1378 } else {
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1379 ngx_destroy_pool(ngx_temp_pool);
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1380 ngx_temp_pool = NULL;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1381 ngx_old_cycles.nelts = 0;
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1382 }
f0b350454894 nginx 0.1.0
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1383 }