Mercurial > hg > nginx-quic
annotate src/core/ngx_cycle.c @ 8045:7d46c9f56c9a
release-1.19.2 tag
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 11 Aug 2020 17:52:30 +0300 |
parents | 4f30f75dbdf3 |
children | f18db38a9826 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
440
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
440
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
4412 | 4 * Copyright (C) Nginx, Inc. |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
440
diff
changeset
|
5 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
440
diff
changeset
|
6 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 #include <ngx_event.h> |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
12 |
605 | 13 static void ngx_destroy_cycle_pools(ngx_conf_t *conf); |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
14 static ngx_int_t ngx_init_zone_pool(ngx_cycle_t *cycle, |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
15 ngx_shm_zone_t *shm_zone); |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
16 static ngx_int_t ngx_test_lockfile(u_char *file, ngx_log_t *log); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
17 static void ngx_clean_old_cycles(ngx_event_t *ev); |
6930
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
18 static void ngx_shutdown_timer_handler(ngx_event_t *ev); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
19 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
20 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 volatile ngx_cycle_t *ngx_cycle; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
22 ngx_array_t ngx_old_cycles; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
23 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
24 static ngx_pool_t *ngx_temp_pool; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
25 static ngx_event_t ngx_cleaner_event; |
6930
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
26 static ngx_event_t ngx_shutdown_event; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
27 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
28 ngx_uint_t ngx_test_config; |
6187
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6153
diff
changeset
|
29 ngx_uint_t ngx_dump_config; |
3750 | 30 ngx_uint_t ngx_quiet_mode; |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
31 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
32 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
33 /* STUB NAME */ |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
34 static ngx_connection_t dumb; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
35 /* STUB */ |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
36 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
37 |
563 | 38 ngx_cycle_t * |
39 ngx_init_cycle(ngx_cycle_t *old_cycle) | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
40 { |
1740
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
41 void *rv; |
6821
30b6f1ff192b
Perl: removed special environment handling for the perl module.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6776
diff
changeset
|
42 char **senv; |
1740
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
43 ngx_uint_t i, n; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
44 ngx_log_t *log; |
2220 | 45 ngx_time_t *tp; |
1740
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
46 ngx_conf_t conf; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
47 ngx_pool_t *pool; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
48 ngx_cycle_t *cycle, **old; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
49 ngx_shm_zone_t *shm_zone, *oshm_zone; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
50 ngx_list_part_t *part, *opart; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
51 ngx_open_file_t *file; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
52 ngx_listening_t *ls, *nls; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
53 ngx_core_conf_t *ccf, *old_ccf; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
54 ngx_core_module_t *module; |
2011 | 55 char hostname[NGX_MAXHOSTNAMELEN]; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
56 |
2220 | 57 ngx_timezone_update(); |
58 | |
59 /* force localtime update with a new timezone */ | |
60 | |
61 tp = ngx_timeofday(); | |
62 tp->sec = 0; | |
63 | |
3475
ab353d7dc182
*) introduce ngx_time_sigsafe_update() to update the error log time only
Igor Sysoev <igor@sysoev.ru>
parents:
3474
diff
changeset
|
64 ngx_time_update(); |
2220 | 65 |
66 | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
67 log = old_cycle->log; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
68 |
507 | 69 pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log); |
501 | 70 if (pool == NULL) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
71 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
72 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
73 pool->log = log; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
74 |
501 | 75 cycle = ngx_pcalloc(pool, sizeof(ngx_cycle_t)); |
76 if (cycle == NULL) { | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
77 ngx_destroy_pool(pool); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
78 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
79 } |
501 | 80 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
81 cycle->pool = pool; |
316
a0beefedaf94
nginx-0.0.3-2004-04-15-00:34:05 import
Igor Sysoev <igor@sysoev.ru>
parents:
311
diff
changeset
|
82 cycle->log = log; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
83 cycle->old_cycle = old_cycle; |
336
ca9a7f8c86da
nginx-0.0.3-2004-05-18-19:29:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
333
diff
changeset
|
84 |
2758 | 85 cycle->conf_prefix.len = old_cycle->conf_prefix.len; |
86 cycle->conf_prefix.data = ngx_pstrdup(pool, &old_cycle->conf_prefix); | |
87 if (cycle->conf_prefix.data == NULL) { | |
88 ngx_destroy_pool(pool); | |
89 return NULL; | |
90 } | |
91 | |
92 cycle->prefix.len = old_cycle->prefix.len; | |
93 cycle->prefix.data = ngx_pstrdup(pool, &old_cycle->prefix); | |
94 if (cycle->prefix.data == NULL) { | |
95 ngx_destroy_pool(pool); | |
96 return NULL; | |
97 } | |
336
ca9a7f8c86da
nginx-0.0.3-2004-05-18-19:29:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
333
diff
changeset
|
98 |
605 | 99 cycle->conf_file.len = old_cycle->conf_file.len; |
2049 | 100 cycle->conf_file.data = ngx_pnalloc(pool, old_cycle->conf_file.len + 1); |
605 | 101 if (cycle->conf_file.data == NULL) { |
102 ngx_destroy_pool(pool); | |
103 return NULL; | |
104 } | |
105 ngx_cpystrn(cycle->conf_file.data, old_cycle->conf_file.data, | |
106 old_cycle->conf_file.len + 1); | |
107 | |
2073 | 108 cycle->conf_param.len = old_cycle->conf_param.len; |
2758 | 109 cycle->conf_param.data = ngx_pstrdup(pool, &old_cycle->conf_param); |
2073 | 110 if (cycle->conf_param.data == NULL) { |
111 ngx_destroy_pool(pool); | |
112 return NULL; | |
113 } | |
114 | |
115 | |
4870
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4869
diff
changeset
|
116 n = old_cycle->paths.nelts ? old_cycle->paths.nelts : 10; |
501 | 117 |
6946
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
118 if (ngx_array_init(&cycle->paths, pool, n, sizeof(ngx_path_t *)) |
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
119 != NGX_OK) |
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
120 { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
121 ngx_destroy_pool(pool); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
122 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
123 } |
501 | 124 |
6946
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
125 ngx_memzero(cycle->paths.elts, n * sizeof(ngx_path_t *)); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
126 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
127 |
6187
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6153
diff
changeset
|
128 if (ngx_array_init(&cycle->config_dump, pool, 1, sizeof(ngx_conf_dump_t)) |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6153
diff
changeset
|
129 != NGX_OK) |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6153
diff
changeset
|
130 { |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6153
diff
changeset
|
131 ngx_destroy_pool(pool); |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6153
diff
changeset
|
132 return NULL; |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6153
diff
changeset
|
133 } |
1b7e246e6b38
Core: store and dump processed configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6153
diff
changeset
|
134 |
6776
1bf4f21b1b72
Core: show file contents only once while dumping configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6483
diff
changeset
|
135 ngx_rbtree_init(&cycle->config_dump_rbtree, &cycle->config_dump_sentinel, |
1bf4f21b1b72
Core: show file contents only once while dumping configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6483
diff
changeset
|
136 ngx_str_rbtree_insert_value); |
1bf4f21b1b72
Core: show file contents only once while dumping configuration.
Vladimir Homutov <vl@nginx.com>
parents:
6483
diff
changeset
|
137 |
414
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
138 if (old_cycle->open_files.part.nelts) { |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
139 n = old_cycle->open_files.part.nelts; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
140 for (part = old_cycle->open_files.part.next; part; part = part->next) { |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
141 n += part->nelts; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
142 } |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
143 |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
144 } else { |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
145 n = 20; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
146 } |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
147 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
148 if (ngx_list_init(&cycle->open_files, pool, n, sizeof(ngx_open_file_t)) |
2536
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2512
diff
changeset
|
149 != NGX_OK) |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
diff
changeset
|
150 { |
414
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
151 ngx_destroy_pool(pool); |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
152 return NULL; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
153 } |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
154 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
155 |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
156 if (old_cycle->shared_memory.part.nelts) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
157 n = old_cycle->shared_memory.part.nelts; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
158 for (part = old_cycle->shared_memory.part.next; part; part = part->next) |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
159 { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
160 n += part->nelts; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
161 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
162 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
163 } else { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
164 n = 1; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
165 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
166 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
167 if (ngx_list_init(&cycle->shared_memory, pool, n, sizeof(ngx_shm_zone_t)) |
2536
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2512
diff
changeset
|
168 != NGX_OK) |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
169 { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
170 ngx_destroy_pool(pool); |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
171 return NULL; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
172 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
173 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
174 n = old_cycle->listening.nelts ? old_cycle->listening.nelts : 10; |
501 | 175 |
6946
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
176 if (ngx_array_init(&cycle->listening, pool, n, sizeof(ngx_listening_t)) |
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
177 != NGX_OK) |
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
178 { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
179 ngx_destroy_pool(pool); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
180 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
181 } |
501 | 182 |
6946
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
183 ngx_memzero(cycle->listening.elts, n * sizeof(ngx_listening_t)); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
184 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
185 |
3880
e3cb8e27e413
reuse keepalive connections if there are no free worker connections
Igor Sysoev <igor@sysoev.ru>
parents:
3750
diff
changeset
|
186 ngx_queue_init(&cycle->reusable_connections_queue); |
e3cb8e27e413
reuse keepalive connections if there are no free worker connections
Igor Sysoev <igor@sysoev.ru>
parents:
3750
diff
changeset
|
187 |
e3cb8e27e413
reuse keepalive connections if there are no free worker connections
Igor Sysoev <igor@sysoev.ru>
parents:
3750
diff
changeset
|
188 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
189 cycle->conf_ctx = ngx_pcalloc(pool, ngx_max_module * sizeof(void *)); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
190 if (cycle->conf_ctx == NULL) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
191 ngx_destroy_pool(pool); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
192 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
193 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
194 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
195 |
2011 | 196 if (gethostname(hostname, NGX_MAXHOSTNAMELEN) == -1) { |
197 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "gethostname() failed"); | |
198 ngx_destroy_pool(pool); | |
199 return NULL; | |
200 } | |
201 | |
202 /* on Linux gethostname() silently truncates name that does not fit */ | |
203 | |
204 hostname[NGX_MAXHOSTNAMELEN - 1] = '\0'; | |
205 cycle->hostname.len = ngx_strlen(hostname); | |
206 | |
2049 | 207 cycle->hostname.data = ngx_pnalloc(pool, cycle->hostname.len); |
2011 | 208 if (cycle->hostname.data == NULL) { |
209 ngx_destroy_pool(pool); | |
210 return NULL; | |
211 } | |
212 | |
3222 | 213 ngx_strlow(cycle->hostname.data, (u_char *) hostname, cycle->hostname.len); |
2011 | 214 |
215 | |
6383 | 216 if (ngx_cycle_modules(cycle) != NGX_OK) { |
217 ngx_destroy_pool(pool); | |
218 return NULL; | |
219 } | |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
220 |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
221 |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
222 for (i = 0; cycle->modules[i]; i++) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
223 if (cycle->modules[i]->type != NGX_CORE_MODULE) { |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
224 continue; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
225 } |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
226 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
227 module = cycle->modules[i]->ctx; |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
228 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
229 if (module->create_conf) { |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
230 rv = module->create_conf(cycle); |
2912
c7d57b539248
return NULL instead of NGX_CONF_ERROR on a create conf failure
Igor Sysoev <igor@sysoev.ru>
parents:
2905
diff
changeset
|
231 if (rv == NULL) { |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
232 ngx_destroy_pool(pool); |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
233 return NULL; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
234 } |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
235 cycle->conf_ctx[cycle->modules[i]->index] = rv; |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
236 } |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
237 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
238 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
239 |
1740
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
240 senv = environ; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
241 |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
242 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
243 ngx_memzero(&conf, sizeof(ngx_conf_t)); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
244 /* STUB: init array ? */ |
501 | 245 conf.args = ngx_array_create(pool, 10, sizeof(ngx_str_t)); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
246 if (conf.args == NULL) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
247 ngx_destroy_pool(pool); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
248 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
249 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
250 |
593 | 251 conf.temp_pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log); |
252 if (conf.temp_pool == NULL) { | |
253 ngx_destroy_pool(pool); | |
254 return NULL; | |
255 } | |
256 | |
605 | 257 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
258 conf.ctx = cycle->conf_ctx; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
259 conf.cycle = cycle; |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
260 conf.pool = pool; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
261 conf.log = log; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
262 conf.module_type = NGX_CORE_MODULE; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
263 conf.cmd_type = NGX_MAIN_CONF; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
264 |
728
e82eed614d4a
turn off startup debug logging introduced by previous commit
Igor Sysoev <igor@sysoev.ru>
parents:
727
diff
changeset
|
265 #if 0 |
455 | 266 log->log_level = NGX_LOG_DEBUG_ALL; |
267 #endif | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
268 |
2073 | 269 if (ngx_conf_param(&conf) != NGX_CONF_OK) { |
3142
959fa3a11b03
restore environ, this fixes segfault on reconfiguration failure when
Igor Sysoev <igor@sysoev.ru>
parents:
3141
diff
changeset
|
270 environ = senv; |
2073 | 271 ngx_destroy_cycle_pools(&conf); |
272 return NULL; | |
273 } | |
274 | |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
275 if (ngx_conf_parse(&conf, &cycle->conf_file) != NGX_CONF_OK) { |
3142
959fa3a11b03
restore environ, this fixes segfault on reconfiguration failure when
Igor Sysoev <igor@sysoev.ru>
parents:
3141
diff
changeset
|
276 environ = senv; |
605 | 277 ngx_destroy_cycle_pools(&conf); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
278 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
279 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
280 |
3750 | 281 if (ngx_test_config && !ngx_quiet_mode) { |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
282 ngx_log_stderr(0, "the configuration file %s syntax is ok", |
2722 | 283 cycle->conf_file.data); |
320
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
284 } |
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
285 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
286 for (i = 0; cycle->modules[i]; i++) { |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
287 if (cycle->modules[i]->type != NGX_CORE_MODULE) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
288 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
289 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
290 |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
291 module = cycle->modules[i]->ctx; |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
292 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
293 if (module->init_conf) { |
6379
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
294 if (module->init_conf(cycle, |
cf5e822cf470
Dynamic modules: changed ngx_modules to cycle->modules.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6378
diff
changeset
|
295 cycle->conf_ctx[cycle->modules[i]->index]) |
593 | 296 == NGX_CONF_ERROR) |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
297 { |
3142
959fa3a11b03
restore environ, this fixes segfault on reconfiguration failure when
Igor Sysoev <igor@sysoev.ru>
parents:
3141
diff
changeset
|
298 environ = senv; |
605 | 299 ngx_destroy_cycle_pools(&conf); |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
300 return NULL; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
301 } |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
302 } |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
303 } |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
304 |
2923
d9c46f98b09f
a signaller process should stop configuration processing just after
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
305 if (ngx_process == NGX_PROCESS_SIGNALLER) { |
d9c46f98b09f
a signaller process should stop configuration processing just after
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
306 return cycle; |
d9c46f98b09f
a signaller process should stop configuration processing just after
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
307 } |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
308 |
611 | 309 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
310 |
611 | 311 if (ngx_test_config) { |
312 | |
313 if (ngx_create_pidfile(&ccf->pid, log) != NGX_OK) { | |
314 goto failed; | |
315 } | |
316 | |
317 } else if (!ngx_is_init_cycle(old_cycle)) { | |
318 | |
319 /* | |
320 * we do not create the pid file in the first ngx_init_cycle() call | |
321 * because we need to write the demonized process pid | |
322 */ | |
323 | |
324 old_ccf = (ngx_core_conf_t *) ngx_get_conf(old_cycle->conf_ctx, | |
325 ngx_core_module); | |
326 if (ccf->pid.len != old_ccf->pid.len | |
327 || ngx_strcmp(ccf->pid.data, old_ccf->pid.data) != 0) | |
328 { | |
329 /* new pid file name */ | |
330 | |
331 if (ngx_create_pidfile(&ccf->pid, log) != NGX_OK) { | |
332 goto failed; | |
333 } | |
334 | |
335 ngx_delete_pidfile(old_cycle); | |
336 } | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
337 } |
611 | 338 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
339 |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
340 if (ngx_test_lockfile(cycle->lock_file.data, log) != NGX_OK) { |
611 | 341 goto failed; |
342 } | |
467 | 343 |
611 | 344 |
4870
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4869
diff
changeset
|
345 if (ngx_create_paths(cycle, ccf->user) != NGX_OK) { |
611 | 346 goto failed; |
467 | 347 } |
348 | |
349 | |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
350 if (ngx_log_open_default(cycle) != NGX_OK) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
351 goto failed; |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2782
diff
changeset
|
352 } |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2782
diff
changeset
|
353 |
611 | 354 /* open the new files */ |
414
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
355 |
611 | 356 part = &cycle->open_files.part; |
357 file = part->elts; | |
414
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
358 |
611 | 359 for (i = 0; /* void */ ; i++) { |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
360 |
611 | 361 if (i >= part->nelts) { |
362 if (part->next == NULL) { | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
363 break; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
364 } |
611 | 365 part = part->next; |
366 file = part->elts; | |
367 i = 0; | |
368 } | |
369 | |
2758 | 370 if (file[i].name.len == 0) { |
611 | 371 continue; |
372 } | |
373 | |
2628
64a10d6b97bd
win32 ngx_open_file() supports utf8 names and NGX_FILE_APPEND
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
374 file[i].fd = ngx_open_file(file[i].name.data, |
2629
367b29612a00
Win32 appends synchronized if only FILE_APPEND_DATA and SYNCHRONIZE are set
Igor Sysoev <igor@sysoev.ru>
parents:
2628
diff
changeset
|
375 NGX_FILE_APPEND, |
2628
64a10d6b97bd
win32 ngx_open_file() supports utf8 names and NGX_FILE_APPEND
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
376 NGX_FILE_CREATE_OR_OPEN, |
1048
c4f666fc3a7e
ngx_open_file(name, access, create) > ngx_open_file(name, mode, create, access)
Igor Sysoev <igor@sysoev.ru>
parents:
1032
diff
changeset
|
377 NGX_FILE_DEFAULT_ACCESS); |
611 | 378 |
379 ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0, | |
380 "log: %p %d \"%s\"", | |
381 &file[i], file[i].fd, file[i].name.data); | |
382 | |
383 if (file[i].fd == NGX_INVALID_FILE) { | |
384 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | |
385 ngx_open_file_n " \"%s\" failed", | |
386 file[i].name.data); | |
387 goto failed; | |
388 } | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
389 |
2687
5190c5dc3486
delete win32 ngx_file_append_mode() as we use reliable
Igor Sysoev <igor@sysoev.ru>
parents:
2686
diff
changeset
|
390 #if !(NGX_WIN32) |
611 | 391 if (fcntl(file[i].fd, F_SETFD, FD_CLOEXEC) == -1) { |
392 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | |
393 "fcntl(FD_CLOEXEC) \"%s\" failed", | |
394 file[i].name.data); | |
395 goto failed; | |
396 } | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
397 #endif |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
398 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
399 |
2785
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2782
diff
changeset
|
400 cycle->log = &cycle->new_log; |
d478379e51ac
*) refactor error_log processing: listen socket log might inherit built-in
Igor Sysoev <igor@sysoev.ru>
parents:
2782
diff
changeset
|
401 pool->log = &cycle->new_log; |
2466
550ab350c306
revert the previous commit and r2447 change in src/core/ngx_cycle.c
Igor Sysoev <igor@sysoev.ru>
parents:
2465
diff
changeset
|
402 |
461 | 403 |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
404 /* create shared memory */ |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
405 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
406 part = &cycle->shared_memory.part; |
972 | 407 shm_zone = part->elts; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
408 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
409 for (i = 0; /* void */ ; i++) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
410 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
411 if (i >= part->nelts) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
412 if (part->next == NULL) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
413 break; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
414 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
415 part = part->next; |
972 | 416 shm_zone = part->elts; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
417 i = 0; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
418 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
419 |
979 | 420 if (shm_zone[i].shm.size == 0) { |
421 ngx_log_error(NGX_LOG_EMERG, log, 0, | |
422 "zero size shared memory zone \"%V\"", | |
2716
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2688
diff
changeset
|
423 &shm_zone[i].shm.name); |
979 | 424 goto failed; |
425 } | |
426 | |
972 | 427 shm_zone[i].shm.log = cycle->log; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
428 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
429 opart = &old_cycle->shared_memory.part; |
972 | 430 oshm_zone = opart->elts; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
431 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
432 for (n = 0; /* void */ ; n++) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
433 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
434 if (n >= opart->nelts) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
435 if (opart->next == NULL) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
436 break; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
437 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
438 opart = opart->next; |
972 | 439 oshm_zone = opart->elts; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
440 n = 0; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
441 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
442 |
2716
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2688
diff
changeset
|
443 if (shm_zone[i].shm.name.len != oshm_zone[n].shm.name.len) { |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
444 continue; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
445 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
446 |
2716
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2688
diff
changeset
|
447 if (ngx_strncmp(shm_zone[i].shm.name.data, |
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2688
diff
changeset
|
448 oshm_zone[n].shm.name.data, |
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2688
diff
changeset
|
449 shm_zone[i].shm.name.len) |
972 | 450 != 0) |
451 { | |
452 continue; | |
453 } | |
454 | |
4933
72e11139760b
Core: don't reuse shared memory zone that changed ownership (ticket #210).
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
455 if (shm_zone[i].tag == oshm_zone[n].tag |
6103
79ddb0bdb273
Upstream: the "zone" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
6016
diff
changeset
|
456 && shm_zone[i].shm.size == oshm_zone[n].shm.size |
79ddb0bdb273
Upstream: the "zone" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
6016
diff
changeset
|
457 && !shm_zone[i].noreuse) |
4933
72e11139760b
Core: don't reuse shared memory zone that changed ownership (ticket #210).
Ruslan Ermilov <ru@nginx.com>
parents:
4870
diff
changeset
|
458 { |
972 | 459 shm_zone[i].shm.addr = oshm_zone[n].shm.addr; |
6132
859ce1c41f64
Win32: fixed shm.handle loss on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6116
diff
changeset
|
460 #if (NGX_WIN32) |
859ce1c41f64
Win32: fixed shm.handle loss on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6116
diff
changeset
|
461 shm_zone[i].shm.handle = oshm_zone[n].shm.handle; |
859ce1c41f64
Win32: fixed shm.handle loss on reload.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6116
diff
changeset
|
462 #endif |
993
1b9a4d92173f
pass the inherited shm_zone data
Igor Sysoev <igor@sysoev.ru>
parents:
979
diff
changeset
|
463 |
1b9a4d92173f
pass the inherited shm_zone data
Igor Sysoev <igor@sysoev.ru>
parents:
979
diff
changeset
|
464 if (shm_zone[i].init(&shm_zone[i], oshm_zone[n].data) |
1b9a4d92173f
pass the inherited shm_zone data
Igor Sysoev <igor@sysoev.ru>
parents:
979
diff
changeset
|
465 != NGX_OK) |
1b9a4d92173f
pass the inherited shm_zone data
Igor Sysoev <igor@sysoev.ru>
parents:
979
diff
changeset
|
466 { |
1b9a4d92173f
pass the inherited shm_zone data
Igor Sysoev <igor@sysoev.ru>
parents:
979
diff
changeset
|
467 goto failed; |
1b9a4d92173f
pass the inherited shm_zone data
Igor Sysoev <igor@sysoev.ru>
parents:
979
diff
changeset
|
468 } |
1b9a4d92173f
pass the inherited shm_zone data
Igor Sysoev <igor@sysoev.ru>
parents:
979
diff
changeset
|
469 |
996 | 470 goto shm_zone_found; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
471 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
472 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
473 break; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
474 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
475 |
972 | 476 if (ngx_shm_alloc(&shm_zone[i].shm) != NGX_OK) { |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
477 goto failed; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
478 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
479 |
2905
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
480 if (ngx_init_zone_pool(cycle, &shm_zone[i]) != NGX_OK) { |
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
481 goto failed; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
482 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
483 |
993
1b9a4d92173f
pass the inherited shm_zone data
Igor Sysoev <igor@sysoev.ru>
parents:
979
diff
changeset
|
484 if (shm_zone[i].init(&shm_zone[i], NULL) != NGX_OK) { |
972 | 485 goto failed; |
486 } | |
487 | |
996 | 488 shm_zone_found: |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
489 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
490 continue; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
491 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
492 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
493 |
611 | 494 /* handle the listening sockets */ |
461 | 495 |
611 | 496 if (old_cycle->listening.nelts) { |
497 ls = old_cycle->listening.elts; | |
498 for (i = 0; i < old_cycle->listening.nelts; i++) { | |
499 ls[i].remain = 0; | |
500 } | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
501 |
611 | 502 nls = cycle->listening.elts; |
503 for (n = 0; n < cycle->listening.nelts; n++) { | |
461 | 504 |
611 | 505 for (i = 0; i < old_cycle->listening.nelts; i++) { |
506 if (ls[i].ignore) { | |
507 continue; | |
508 } | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
509 |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6133
diff
changeset
|
510 if (ls[i].remain) { |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6133
diff
changeset
|
511 continue; |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6133
diff
changeset
|
512 } |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6133
diff
changeset
|
513 |
6462
fd4b52e74f96
Fixed socket inheritance on reload and binary upgrade.
Roman Arutyunyan <arut@nginx.com>
parents:
6383
diff
changeset
|
514 if (ls[i].type != nls[n].type) { |
fd4b52e74f96
Fixed socket inheritance on reload and binary upgrade.
Roman Arutyunyan <arut@nginx.com>
parents:
6383
diff
changeset
|
515 continue; |
fd4b52e74f96
Fixed socket inheritance on reload and binary upgrade.
Roman Arutyunyan <arut@nginx.com>
parents:
6383
diff
changeset
|
516 } |
fd4b52e74f96
Fixed socket inheritance on reload and binary upgrade.
Roman Arutyunyan <arut@nginx.com>
parents:
6383
diff
changeset
|
517 |
5473
d39ef821d03e
Core: externalized ngx_cmp_sockaddr().
Ruslan Ermilov <ru@nginx.com>
parents:
5430
diff
changeset
|
518 if (ngx_cmp_sockaddr(nls[n].sockaddr, nls[n].socklen, |
5603
b2b5b1b74129
Core: fixed wrong indices in listening sockets compare loops.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5473
diff
changeset
|
519 ls[i].sockaddr, ls[i].socklen, 1) |
5473
d39ef821d03e
Core: externalized ngx_cmp_sockaddr().
Ruslan Ermilov <ru@nginx.com>
parents:
5430
diff
changeset
|
520 == NGX_OK) |
611 | 521 { |
522 nls[n].fd = ls[i].fd; | |
7965
9c038f5e0464
Fixed removing of listening UNIX sockets when "changing binary".
Ruslan Ermilov <ru@nginx.com>
parents:
7394
diff
changeset
|
523 nls[n].inherited = ls[i].inherited; |
611 | 524 nls[n].previous = &ls[i]; |
525 ls[i].remain = 1; | |
523 | 526 |
5603
b2b5b1b74129
Core: fixed wrong indices in listening sockets compare loops.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5473
diff
changeset
|
527 if (ls[i].backlog != nls[n].backlog) { |
611 | 528 nls[n].listen = 1; |
529 } | |
537 | 530 |
523 | 531 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) |
532 | |
611 | 533 /* |
534 * FreeBSD, except the most recent versions, | |
535 * could not remove accept filter | |
536 */ | |
537 nls[n].deferred_accept = ls[i].deferred_accept; | |
523 | 538 |
611 | 539 if (ls[i].accept_filter && nls[n].accept_filter) { |
540 if (ngx_strcmp(ls[i].accept_filter, | |
541 nls[n].accept_filter) | |
542 != 0) | |
543 { | |
523 | 544 nls[n].delete_deferred = 1; |
545 nls[n].add_deferred = 1; | |
546 } | |
611 | 547 |
548 } else if (ls[i].accept_filter) { | |
549 nls[n].delete_deferred = 1; | |
550 | |
551 } else if (nls[n].accept_filter) { | |
552 nls[n].add_deferred = 1; | |
553 } | |
523 | 554 #endif |
555 | |
556 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) | |
557 | |
5603
b2b5b1b74129
Core: fixed wrong indices in listening sockets compare loops.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5473
diff
changeset
|
558 if (ls[i].deferred_accept && !nls[n].deferred_accept) { |
611 | 559 nls[n].delete_deferred = 1; |
523 | 560 |
611 | 561 } else if (ls[i].deferred_accept != nls[n].deferred_accept) |
562 { | |
563 nls[n].add_deferred = 1; | |
564 } | |
523 | 565 #endif |
6153
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6133
diff
changeset
|
566 |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6133
diff
changeset
|
567 #if (NGX_HAVE_REUSEPORT) |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6133
diff
changeset
|
568 if (nls[n].reuseport && !ls[i].reuseport) { |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6133
diff
changeset
|
569 nls[n].add_reuseport = 1; |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6133
diff
changeset
|
570 } |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6133
diff
changeset
|
571 #endif |
4f6efabcb09b
The "reuseport" option of the "listen" directive.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6133
diff
changeset
|
572 |
611 | 573 break; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
574 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
575 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
576 |
5360
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5260
diff
changeset
|
577 if (nls[n].fd == (ngx_socket_t) -1) { |
611 | 578 nls[n].open = 1; |
5430
d8ee8ef5dcde
Core: apply missed options to sockets added during binary upgrade.
Piotr Sikora <piotr@cloudflare.com>
parents:
5360
diff
changeset
|
579 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) |
d8ee8ef5dcde
Core: apply missed options to sockets added during binary upgrade.
Piotr Sikora <piotr@cloudflare.com>
parents:
5360
diff
changeset
|
580 if (nls[n].accept_filter) { |
d8ee8ef5dcde
Core: apply missed options to sockets added during binary upgrade.
Piotr Sikora <piotr@cloudflare.com>
parents:
5360
diff
changeset
|
581 nls[n].add_deferred = 1; |
d8ee8ef5dcde
Core: apply missed options to sockets added during binary upgrade.
Piotr Sikora <piotr@cloudflare.com>
parents:
5360
diff
changeset
|
582 } |
d8ee8ef5dcde
Core: apply missed options to sockets added during binary upgrade.
Piotr Sikora <piotr@cloudflare.com>
parents:
5360
diff
changeset
|
583 #endif |
d8ee8ef5dcde
Core: apply missed options to sockets added during binary upgrade.
Piotr Sikora <piotr@cloudflare.com>
parents:
5360
diff
changeset
|
584 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) |
d8ee8ef5dcde
Core: apply missed options to sockets added during binary upgrade.
Piotr Sikora <piotr@cloudflare.com>
parents:
5360
diff
changeset
|
585 if (nls[n].deferred_accept) { |
d8ee8ef5dcde
Core: apply missed options to sockets added during binary upgrade.
Piotr Sikora <piotr@cloudflare.com>
parents:
5360
diff
changeset
|
586 nls[n].add_deferred = 1; |
d8ee8ef5dcde
Core: apply missed options to sockets added during binary upgrade.
Piotr Sikora <piotr@cloudflare.com>
parents:
5360
diff
changeset
|
587 } |
d8ee8ef5dcde
Core: apply missed options to sockets added during binary upgrade.
Piotr Sikora <piotr@cloudflare.com>
parents:
5360
diff
changeset
|
588 #endif |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
589 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
590 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
591 |
611 | 592 } else { |
593 ls = cycle->listening.elts; | |
594 for (i = 0; i < cycle->listening.nelts; i++) { | |
595 ls[i].open = 1; | |
596 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) | |
597 if (ls[i].accept_filter) { | |
598 ls[i].add_deferred = 1; | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
599 } |
611 | 600 #endif |
601 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) | |
602 if (ls[i].deferred_accept) { | |
603 ls[i].add_deferred = 1; | |
523 | 604 } |
611 | 605 #endif |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
606 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
607 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
608 |
2923
d9c46f98b09f
a signaller process should stop configuration processing just after
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
609 if (ngx_open_listening_sockets(cycle) != NGX_OK) { |
d9c46f98b09f
a signaller process should stop configuration processing just after
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
610 goto failed; |
d9c46f98b09f
a signaller process should stop configuration processing just after
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
611 } |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
612 |
2923
d9c46f98b09f
a signaller process should stop configuration processing just after
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
613 if (!ngx_test_config) { |
d9c46f98b09f
a signaller process should stop configuration processing just after
Igor Sysoev <igor@sysoev.ru>
parents:
2912
diff
changeset
|
614 ngx_configure_listening_sockets(cycle); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
615 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
616 |
249
2a0540287298
nginx-0.0.2-2004-02-03-19:43:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
237
diff
changeset
|
617 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
618 /* commit the new cycle configuration */ |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
619 |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
620 if (!ngx_use_stderr) { |
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
621 (void) ngx_log_redirect_stderr(cycle); |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
622 } |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
623 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
624 pool->log = cycle->log; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
625 |
6378
0f203a2af17c
Dynamic modules: moved module-related stuff to separate files.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6187
diff
changeset
|
626 if (ngx_init_modules(cycle) != NGX_OK) { |
0f203a2af17c
Dynamic modules: moved module-related stuff to separate files.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6187
diff
changeset
|
627 /* fatal */ |
0f203a2af17c
Dynamic modules: moved module-related stuff to separate files.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6187
diff
changeset
|
628 exit(1); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
629 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
630 |
467 | 631 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
632 /* close and delete stuff that lefts from an old cycle */ |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
633 |
995
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
634 /* free the unnecessary shared memory */ |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
635 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
636 opart = &old_cycle->shared_memory.part; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
637 oshm_zone = opart->elts; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
638 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
639 for (i = 0; /* void */ ; i++) { |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
640 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
641 if (i >= opart->nelts) { |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
642 if (opart->next == NULL) { |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
643 goto old_shm_zone_done; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
644 } |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
645 opart = opart->next; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
646 oshm_zone = opart->elts; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
647 i = 0; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
648 } |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
649 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
650 part = &cycle->shared_memory.part; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
651 shm_zone = part->elts; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
652 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
653 for (n = 0; /* void */ ; n++) { |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
654 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
655 if (n >= part->nelts) { |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
656 if (part->next == NULL) { |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
657 break; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
658 } |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
659 part = part->next; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
660 shm_zone = part->elts; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
661 n = 0; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
662 } |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
663 |
7151
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
664 if (oshm_zone[i].shm.name.len != shm_zone[n].shm.name.len) { |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
665 continue; |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
666 } |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
667 |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
668 if (ngx_strncmp(oshm_zone[i].shm.name.data, |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
669 shm_zone[n].shm.name.data, |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
670 oshm_zone[i].shm.name.len) |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
671 != 0) |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
672 { |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
673 continue; |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
674 } |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
675 |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
676 if (oshm_zone[i].tag == shm_zone[n].tag |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
677 && oshm_zone[i].shm.size == shm_zone[n].shm.size |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
678 && !oshm_zone[i].noreuse) |
995
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
679 { |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
680 goto live_shm_zone; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
681 } |
7151
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
682 |
9ef704d8563a
Core: free shared memory zones only after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
7032
diff
changeset
|
683 break; |
995
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
684 } |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
685 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
686 ngx_shm_free(&oshm_zone[i].shm); |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
687 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
688 live_shm_zone: |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
689 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
690 continue; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
691 } |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
692 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
693 old_shm_zone_done: |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
694 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
695 |
994 | 696 /* close the unnecessary listening sockets */ |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
697 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
698 ls = old_cycle->listening.elts; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
699 for (i = 0; i < old_cycle->listening.nelts; i++) { |
2924
a0987c332d8e
win32 master process had aready closed listening sockets
Igor Sysoev <igor@sysoev.ru>
parents:
2923
diff
changeset
|
700 |
5360
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5260
diff
changeset
|
701 if (ls[i].remain || ls[i].fd == (ngx_socket_t) -1) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
702 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
703 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
704 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
705 if (ngx_close_socket(ls[i].fd) == -1) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
706 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, |
543 | 707 ngx_close_socket_n " listening socket on %V failed", |
461 | 708 &ls[i].addr_text); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
709 } |
3569
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
710 |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
711 #if (NGX_HAVE_UNIX_DOMAIN) |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
712 |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
713 if (ls[i].sockaddr->sa_family == AF_UNIX) { |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
714 u_char *name; |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
715 |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
716 name = ls[i].addr_text.data + sizeof("unix:") - 1; |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
717 |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
718 ngx_log_error(NGX_LOG_WARN, cycle->log, 0, |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
719 "deleting socket %s", name); |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
720 |
5137
f941cf265cc5
Use NGX_FILE_ERROR for handling file operations errors.
Valentin Bartenev <vbart@nginx.com>
parents:
4985
diff
changeset
|
721 if (ngx_delete_file(name) == NGX_FILE_ERROR) { |
3569
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
722 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno, |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
723 ngx_delete_file_n " %s failed", name); |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
724 } |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
725 } |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
726 |
8bb6ce44672a
*) delete no longer used unix domain sockets
Igor Sysoev <igor@sysoev.ru>
parents:
3475
diff
changeset
|
727 #endif |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
728 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
729 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
730 |
994 | 731 /* close the unnecessary open files */ |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
732 |
414
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
733 part = &old_cycle->open_files.part; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
734 file = part->elts; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
735 |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
736 for (i = 0; /* void */ ; i++) { |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
737 |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
738 if (i >= part->nelts) { |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
739 if (part->next == NULL) { |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
740 break; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
741 } |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
742 part = part->next; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
743 file = part->elts; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
744 i = 0; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
745 } |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
746 |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
747 if (file[i].fd == NGX_INVALID_FILE || file[i].fd == ngx_stderr) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
748 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
749 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
750 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
751 if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
752 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
753 ngx_close_file_n " \"%s\" failed", |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
754 file[i].name.data); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
755 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
756 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
757 |
593 | 758 ngx_destroy_pool(conf.temp_pool); |
759 | |
605 | 760 if (ngx_process == NGX_PROCESS_MASTER || ngx_is_init_cycle(old_cycle)) { |
761 | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
762 ngx_destroy_pool(old_cycle->pool); |
611 | 763 cycle->old_cycle = NULL; |
764 | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
765 return cycle; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
766 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
767 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
768 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
769 if (ngx_temp_pool == NULL) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
770 ngx_temp_pool = ngx_create_pool(128, cycle->log); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
771 if (ngx_temp_pool == NULL) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
772 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
4133
59b99f217c6d
Replaced "can not" with "cannot" and "could not" in a bunch of places.
Ruslan Ermilov <ru@nginx.com>
parents:
3992
diff
changeset
|
773 "could not create ngx_temp_pool"); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
774 exit(1); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
775 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
776 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
777 n = 10; |
6946
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
778 |
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
779 if (ngx_array_init(&ngx_old_cycles, ngx_temp_pool, n, |
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
780 sizeof(ngx_cycle_t *)) |
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
781 != NGX_OK) |
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
782 { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
783 exit(1); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
784 } |
6946
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
785 |
99c87770b81b
Use ngx_array_init() to initialize arrays.
Ruslan Ermilov <ru@nginx.com>
parents:
6930
diff
changeset
|
786 ngx_memzero(ngx_old_cycles.elts, n * sizeof(ngx_cycle_t *)); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
787 |
509 | 788 ngx_cleaner_event.handler = ngx_clean_old_cycles; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
789 ngx_cleaner_event.log = cycle->log; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
790 ngx_cleaner_event.data = &dumb; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
791 dumb.fd = (ngx_socket_t) -1; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
792 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
793 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
794 ngx_temp_pool->log = cycle->log; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
795 |
501 | 796 old = ngx_array_push(&ngx_old_cycles); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
797 if (old == NULL) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
798 exit(1); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
799 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
800 *old = old_cycle; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
801 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
802 if (!ngx_cleaner_event.timer_set) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
803 ngx_add_timer(&ngx_cleaner_event, 30000); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
804 ngx_cleaner_event.timer_set = 1; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
805 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
806 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
807 return cycle; |
611 | 808 |
809 | |
810 failed: | |
811 | |
1165 | 812 if (!ngx_is_init_cycle(old_cycle)) { |
813 old_ccf = (ngx_core_conf_t *) ngx_get_conf(old_cycle->conf_ctx, | |
814 ngx_core_module); | |
815 if (old_ccf->environment) { | |
816 environ = old_ccf->environment; | |
817 } | |
818 } | |
819 | |
611 | 820 /* rollback the new cycle configuration */ |
821 | |
822 part = &cycle->open_files.part; | |
823 file = part->elts; | |
824 | |
825 for (i = 0; /* void */ ; i++) { | |
826 | |
827 if (i >= part->nelts) { | |
828 if (part->next == NULL) { | |
829 break; | |
830 } | |
831 part = part->next; | |
832 file = part->elts; | |
833 i = 0; | |
834 } | |
835 | |
2743
d8316f307b6a
issue start up errors and warning on both stderr and error_log
Igor Sysoev <igor@sysoev.ru>
parents:
2738
diff
changeset
|
836 if (file[i].fd == NGX_INVALID_FILE || file[i].fd == ngx_stderr) { |
611 | 837 continue; |
838 } | |
839 | |
840 if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) { | |
841 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | |
842 ngx_close_file_n " \"%s\" failed", | |
843 file[i].name.data); | |
844 } | |
845 } | |
846 | |
7394
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
847 /* free the newly created shared memory */ |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
848 |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
849 part = &cycle->shared_memory.part; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
850 shm_zone = part->elts; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
851 |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
852 for (i = 0; /* void */ ; i++) { |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
853 |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
854 if (i >= part->nelts) { |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
855 if (part->next == NULL) { |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
856 break; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
857 } |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
858 part = part->next; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
859 shm_zone = part->elts; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
860 i = 0; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
861 } |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
862 |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
863 if (shm_zone[i].shm.addr == NULL) { |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
864 continue; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
865 } |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
866 |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
867 opart = &old_cycle->shared_memory.part; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
868 oshm_zone = opart->elts; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
869 |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
870 for (n = 0; /* void */ ; n++) { |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
871 |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
872 if (n >= opart->nelts) { |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
873 if (opart->next == NULL) { |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
874 break; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
875 } |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
876 opart = opart->next; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
877 oshm_zone = opart->elts; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
878 n = 0; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
879 } |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
880 |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
881 if (shm_zone[i].shm.name.len != oshm_zone[n].shm.name.len) { |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
882 continue; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
883 } |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
884 |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
885 if (ngx_strncmp(shm_zone[i].shm.name.data, |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
886 oshm_zone[n].shm.name.data, |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
887 shm_zone[i].shm.name.len) |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
888 != 0) |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
889 { |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
890 continue; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
891 } |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
892 |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
893 if (shm_zone[i].tag == oshm_zone[n].tag |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
894 && shm_zone[i].shm.size == oshm_zone[n].shm.size |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
895 && !shm_zone[i].noreuse) |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
896 { |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
897 goto old_shm_zone_found; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
898 } |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
899 |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
900 break; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
901 } |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
902 |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
903 ngx_shm_free(&shm_zone[i].shm); |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
904 |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
905 old_shm_zone_found: |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
906 |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
907 continue; |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
908 } |
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
909 |
611 | 910 if (ngx_test_config) { |
911 ngx_destroy_cycle_pools(&conf); | |
912 return NULL; | |
913 } | |
914 | |
915 ls = cycle->listening.elts; | |
916 for (i = 0; i < cycle->listening.nelts; i++) { | |
5360
3d2d3e1cf427
Win32: MinGW GCC compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5260
diff
changeset
|
917 if (ls[i].fd == (ngx_socket_t) -1 || !ls[i].open) { |
611 | 918 continue; |
919 } | |
920 | |
921 if (ngx_close_socket(ls[i].fd) == -1) { | |
922 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, | |
923 ngx_close_socket_n " %V failed", | |
924 &ls[i].addr_text); | |
925 } | |
926 } | |
927 | |
928 ngx_destroy_cycle_pools(&conf); | |
929 | |
930 return NULL; | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
931 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
932 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
933 |
605 | 934 static void |
935 ngx_destroy_cycle_pools(ngx_conf_t *conf) | |
936 { | |
937 ngx_destroy_pool(conf->temp_pool); | |
938 ngx_destroy_pool(conf->pool); | |
939 } | |
940 | |
941 | |
563 | 942 static ngx_int_t |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
943 ngx_init_zone_pool(ngx_cycle_t *cycle, ngx_shm_zone_t *zn) |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
944 { |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
945 u_char *file; |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
946 ngx_slab_pool_t *sp; |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
947 |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
948 sp = (ngx_slab_pool_t *) zn->shm.addr; |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
949 |
2905
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
950 if (zn->shm.exists) { |
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
951 |
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
952 if (sp == sp->addr) { |
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
953 return NGX_OK; |
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
954 } |
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
955 |
6133
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
956 #if (NGX_WIN32) |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
957 |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
958 /* remap at the required address */ |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
959 |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
960 if (ngx_shm_remap(&zn->shm, sp->addr) != NGX_OK) { |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
961 return NGX_ERROR; |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
962 } |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
963 |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
964 sp = (ngx_slab_pool_t *) zn->shm.addr; |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
965 |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
966 if (sp == sp->addr) { |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
967 return NGX_OK; |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
968 } |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
969 |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
970 #endif |
af7eba90645d
Win32: shared memory base addresses and remapping.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6132
diff
changeset
|
971 |
2905
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
972 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
973 "shared zone \"%V\" has no equal addresses: %p vs %p", |
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
974 &zn->shm.name, sp->addr, sp); |
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
975 return NGX_ERROR; |
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
976 } |
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
977 |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
978 sp->end = zn->shm.addr + zn->shm.size; |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
979 sp->min_shift = 3; |
2905
5ff1ae0eada7
test that zone has the same addresses in different processes
Igor Sysoev <igor@sysoev.ru>
parents:
2802
diff
changeset
|
980 sp->addr = zn->shm.addr; |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
981 |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
982 #if (NGX_HAVE_ATOMIC_OPS) |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
983 |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
984 file = NULL; |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
985 |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
986 #else |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
987 |
7366
7bf3c323cb6e
Fixed off-by-one error in shared zone initialization.
Ruslan Ermilov <ru@nginx.com>
parents:
7151
diff
changeset
|
988 file = ngx_pnalloc(cycle->pool, |
7bf3c323cb6e
Fixed off-by-one error in shared zone initialization.
Ruslan Ermilov <ru@nginx.com>
parents:
7151
diff
changeset
|
989 cycle->lock_file.len + zn->shm.name.len + 1); |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
990 if (file == NULL) { |
2736 | 991 return NGX_ERROR; |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
992 } |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
993 |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
994 (void) ngx_sprintf(file, "%V%V%Z", &cycle->lock_file, &zn->shm.name); |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
995 |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
996 #endif |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
997 |
4309
3f6040cd731e
Added shmtx interface to forcibly unlock mutexes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4133
diff
changeset
|
998 if (ngx_shmtx_create(&sp->mutex, &sp->lock, file) != NGX_OK) { |
2736 | 999 return NGX_ERROR; |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
1000 } |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
1001 |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
1002 ngx_slab_init(sp); |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
1003 |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
1004 return NGX_OK; |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
1005 } |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
1006 |
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
1007 |
563 | 1008 ngx_int_t |
611 | 1009 ngx_create_pidfile(ngx_str_t *name, ngx_log_t *log) |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1010 { |
2688 | 1011 size_t len; |
8030
4f30f75dbdf3
Core: close PID file when writing fails.
Ruslan Ermilov <ru@nginx.com>
parents:
7965
diff
changeset
|
1012 ngx_int_t rc; |
2688 | 1013 ngx_uint_t create; |
1014 ngx_file_t file; | |
1015 u_char pid[NGX_INT64_LEN + 2]; | |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1016 |
2725 | 1017 if (ngx_process > NGX_PROCESS_MASTER) { |
1018 return NGX_OK; | |
1019 } | |
1020 | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1021 ngx_memzero(&file, sizeof(ngx_file_t)); |
543 | 1022 |
611 | 1023 file.name = *name; |
1024 file.log = log; | |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1025 |
2686
9e0ae986b587
adopt NGX_FILE_TRUNCATE for win32
Igor Sysoev <igor@sysoev.ru>
parents:
2629
diff
changeset
|
1026 create = ngx_test_config ? NGX_FILE_CREATE_OR_OPEN : NGX_FILE_TRUNCATE; |
337
4feff829a849
nginx-0.0.3-2004-05-19-00:28:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
336
diff
changeset
|
1027 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1028 file.fd = ngx_open_file(file.name.data, NGX_FILE_RDWR, |
2686
9e0ae986b587
adopt NGX_FILE_TRUNCATE for win32
Igor Sysoev <igor@sysoev.ru>
parents:
2629
diff
changeset
|
1029 create, NGX_FILE_DEFAULT_ACCESS); |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1030 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1031 if (file.fd == NGX_INVALID_FILE) { |
611 | 1032 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1033 ngx_open_file_n " \"%s\" failed", file.name.data); |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1034 return NGX_ERROR; |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1035 } |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1036 |
8030
4f30f75dbdf3
Core: close PID file when writing fails.
Ruslan Ermilov <ru@nginx.com>
parents:
7965
diff
changeset
|
1037 rc = NGX_OK; |
4f30f75dbdf3
Core: close PID file when writing fails.
Ruslan Ermilov <ru@nginx.com>
parents:
7965
diff
changeset
|
1038 |
337
4feff829a849
nginx-0.0.3-2004-05-19-00:28:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
336
diff
changeset
|
1039 if (!ngx_test_config) { |
942
7ddc5345fb4f
fix for Linix/ppc64 or FreeBSD/amd64 in 32-bit mode,
Igor Sysoev <igor@sysoev.ru>
parents:
860
diff
changeset
|
1040 len = ngx_snprintf(pid, NGX_INT64_LEN + 2, "%P%N", ngx_pid) - pid; |
461 | 1041 |
337
4feff829a849
nginx-0.0.3-2004-05-19-00:28:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
336
diff
changeset
|
1042 if (ngx_write_file(&file, pid, len, 0) == NGX_ERROR) { |
8030
4f30f75dbdf3
Core: close PID file when writing fails.
Ruslan Ermilov <ru@nginx.com>
parents:
7965
diff
changeset
|
1043 rc = NGX_ERROR; |
337
4feff829a849
nginx-0.0.3-2004-05-19-00:28:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
336
diff
changeset
|
1044 } |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1045 } |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1046 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1047 if (ngx_close_file(file.fd) == NGX_FILE_ERROR) { |
611 | 1048 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
1049 ngx_close_file_n " \"%s\" failed", file.name.data); |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1050 } |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1051 |
8030
4f30f75dbdf3
Core: close PID file when writing fails.
Ruslan Ermilov <ru@nginx.com>
parents:
7965
diff
changeset
|
1052 return rc; |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1053 } |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1054 |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1055 |
563 | 1056 void |
1057 ngx_delete_pidfile(ngx_cycle_t *cycle) | |
577 | 1058 { |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1059 u_char *name; |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1060 ngx_core_conf_t *ccf; |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1061 |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1062 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1063 |
543 | 1064 name = ngx_new_binary ? ccf->oldpid.data : ccf->pid.data; |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1065 |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1066 if (ngx_delete_file(name) == NGX_FILE_ERROR) { |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1067 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1068 ngx_delete_file_n " \"%s\" failed", name); |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1069 } |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1070 } |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1071 |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
1072 |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1073 ngx_int_t |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1074 ngx_signal_process(ngx_cycle_t *cycle, char *sig) |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1075 { |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1076 ssize_t n; |
6483
3a50ccd94333
Fixed ngx_os_signal_process() prototype.
Ruslan Ermilov <ru@nginx.com>
parents:
6480
diff
changeset
|
1077 ngx_pid_t pid; |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1078 ngx_file_t file; |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1079 ngx_core_conf_t *ccf; |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1080 u_char buf[NGX_INT64_LEN + 2]; |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1081 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1082 ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "signal process started"); |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1083 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1084 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1085 |
4869
2b129bb067b5
Made sure to initialize the entire ngx_file_t structure.
Andrey Belov <defan@nginx.com>
parents:
4777
diff
changeset
|
1086 ngx_memzero(&file, sizeof(ngx_file_t)); |
2b129bb067b5
Made sure to initialize the entire ngx_file_t structure.
Andrey Belov <defan@nginx.com>
parents:
4777
diff
changeset
|
1087 |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1088 file.name = ccf->pid; |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1089 file.log = cycle->log; |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1090 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1091 file.fd = ngx_open_file(file.name.data, NGX_FILE_RDONLY, |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1092 NGX_FILE_OPEN, NGX_FILE_DEFAULT_ACCESS); |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1093 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1094 if (file.fd == NGX_INVALID_FILE) { |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1095 ngx_log_error(NGX_LOG_ERR, cycle->log, ngx_errno, |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1096 ngx_open_file_n " \"%s\" failed", file.name.data); |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1097 return 1; |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1098 } |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1099 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1100 n = ngx_read_file(&file, buf, NGX_INT64_LEN + 2, 0); |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1101 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1102 if (ngx_close_file(file.fd) == NGX_FILE_ERROR) { |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1103 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1104 ngx_close_file_n " \"%s\" failed", file.name.data); |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1105 } |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1106 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1107 if (n == NGX_ERROR) { |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1108 return 1; |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1109 } |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1110 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1111 while (n-- && (buf[n] == CR || buf[n] == LF)) { /* void */ } |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1112 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1113 pid = ngx_atoi(buf, ++n); |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1114 |
6483
3a50ccd94333
Fixed ngx_os_signal_process() prototype.
Ruslan Ermilov <ru@nginx.com>
parents:
6480
diff
changeset
|
1115 if (pid == (ngx_pid_t) NGX_ERROR) { |
2738
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1116 ngx_log_error(NGX_LOG_ERR, cycle->log, 0, |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1117 "invalid PID number \"%*s\" in \"%s\"", |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1118 n, buf, file.name.data); |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1119 return 1; |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1120 } |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1121 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1122 return ngx_os_signal_process(cycle, sig, pid); |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1123 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1124 } |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1125 |
ae81441e23f4
implement "-s signal" option for Unix
Igor Sysoev <igor@sysoev.ru>
parents:
2736
diff
changeset
|
1126 |
611 | 1127 static ngx_int_t |
1128 ngx_test_lockfile(u_char *file, ngx_log_t *log) | |
1129 { | |
1130 #if !(NGX_HAVE_ATOMIC_OPS) | |
1131 ngx_fd_t fd; | |
1132 | |
1100
01884449985f
fix building on platforms with non-supported atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
1048
diff
changeset
|
1133 fd = ngx_open_file(file, NGX_FILE_RDWR, NGX_FILE_CREATE_OR_OPEN, |
01884449985f
fix building on platforms with non-supported atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
1048
diff
changeset
|
1134 NGX_FILE_DEFAULT_ACCESS); |
611 | 1135 |
1136 if (fd == NGX_INVALID_FILE) { | |
1137 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | |
1138 ngx_open_file_n " \"%s\" failed", file); | |
1139 return NGX_ERROR; | |
1140 } | |
1141 | |
1142 if (ngx_close_file(fd) == NGX_FILE_ERROR) { | |
1143 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | |
1144 ngx_close_file_n " \"%s\" failed", file); | |
1145 } | |
1146 | |
1147 if (ngx_delete_file(file) == NGX_FILE_ERROR) { | |
1148 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | |
1149 ngx_delete_file_n " \"%s\" failed", file); | |
1150 } | |
1151 | |
1152 #endif | |
1153 | |
1154 return NGX_OK; | |
1155 } | |
1156 | |
1157 | |
563 | 1158 void |
1159 ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user) | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1160 { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1161 ngx_fd_t fd; |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
286
diff
changeset
|
1162 ngx_uint_t i; |
414
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
1163 ngx_list_part_t *part; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1164 ngx_open_file_t *file; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1165 |
414
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
1166 part = &cycle->open_files.part; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
1167 file = part->elts; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
1168 |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
1169 for (i = 0; /* void */ ; i++) { |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
1170 |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
1171 if (i >= part->nelts) { |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
1172 if (part->next == NULL) { |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
1173 break; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
1174 } |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
1175 part = part->next; |
523 | 1176 file = part->elts; |
414
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
1177 i = 0; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
1178 } |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
1179 |
2758 | 1180 if (file[i].name.len == 0) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1181 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1182 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1183 |
4985
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
1184 if (file[i].flush) { |
a0599b56e748
Reopening log files code moved to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
1185 file[i].flush(&file[i], cycle->log); |
571 | 1186 } |
1187 | |
2629
367b29612a00
Win32 appends synchronized if only FILE_APPEND_DATA and SYNCHRONIZE are set
Igor Sysoev <igor@sysoev.ru>
parents:
2628
diff
changeset
|
1188 fd = ngx_open_file(file[i].name.data, NGX_FILE_APPEND, |
2628
64a10d6b97bd
win32 ngx_open_file() supports utf8 names and NGX_FILE_APPEND
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
1189 NGX_FILE_CREATE_OR_OPEN, NGX_FILE_DEFAULT_ACCESS); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1190 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1191 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1192 "reopen file \"%s\", old:%d new:%d", |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1193 file[i].name.data, file[i].fd, fd); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1194 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1195 if (fd == NGX_INVALID_FILE) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1196 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1197 ngx_open_file_n " \"%s\" failed", file[i].name.data); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1198 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1199 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1200 |
2687
5190c5dc3486
delete win32 ngx_file_append_mode() as we use reliable
Igor Sysoev <igor@sysoev.ru>
parents:
2686
diff
changeset
|
1201 #if !(NGX_WIN32) |
517 | 1202 if (user != (ngx_uid_t) NGX_CONF_UNSET_UINT) { |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1165
diff
changeset
|
1203 ngx_file_info_t fi; |
452 | 1204 |
7032
d48c8cdac201
Removed excessive casts for ngx_file_info().
Ruslan Ermilov <ru@nginx.com>
parents:
6946
diff
changeset
|
1205 if (ngx_file_info(file[i].name.data, &fi) == NGX_FILE_ERROR) { |
452 | 1206 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
1207 ngx_file_info_n " \"%s\" failed", | |
1208 file[i].name.data); | |
1209 | |
1210 if (ngx_close_file(fd) == NGX_FILE_ERROR) { | |
1211 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
1212 ngx_close_file_n " \"%s\" failed", | |
1213 file[i].name.data); | |
1214 } | |
5680
dfb3c15bc851
Core: fixed error handling in ngx_reopen_files().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5603
diff
changeset
|
1215 |
dfb3c15bc851
Core: fixed error handling in ngx_reopen_files().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5603
diff
changeset
|
1216 continue; |
452 | 1217 } |
1218 | |
467 | 1219 if (fi.st_uid != user) { |
1220 if (chown((const char *) file[i].name.data, user, -1) == -1) { | |
1221 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
1222 "chown(\"%s\", %d) failed", | |
1223 file[i].name.data, user); | |
1224 | |
1225 if (ngx_close_file(fd) == NGX_FILE_ERROR) { | |
1226 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
1227 ngx_close_file_n " \"%s\" failed", | |
1228 file[i].name.data); | |
1229 } | |
5680
dfb3c15bc851
Core: fixed error handling in ngx_reopen_files().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5603
diff
changeset
|
1230 |
dfb3c15bc851
Core: fixed error handling in ngx_reopen_files().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5603
diff
changeset
|
1231 continue; |
467 | 1232 } |
1233 } | |
1234 | |
452 | 1235 if ((fi.st_mode & (S_IRUSR|S_IWUSR)) != (S_IRUSR|S_IWUSR)) { |
1236 | |
1237 fi.st_mode |= (S_IRUSR|S_IWUSR); | |
1238 | |
1239 if (chmod((const char *) file[i].name.data, fi.st_mode) == -1) { | |
1240 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
467 | 1241 "chmod() \"%s\" failed", file[i].name.data); |
452 | 1242 |
1243 if (ngx_close_file(fd) == NGX_FILE_ERROR) { | |
1244 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
1245 ngx_close_file_n " \"%s\" failed", | |
1246 file[i].name.data); | |
1247 } | |
5680
dfb3c15bc851
Core: fixed error handling in ngx_reopen_files().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5603
diff
changeset
|
1248 |
dfb3c15bc851
Core: fixed error handling in ngx_reopen_files().
Maxim Dounin <mdounin@mdounin.ru>
parents:
5603
diff
changeset
|
1249 continue; |
452 | 1250 } |
1251 } | |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
1252 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
1253 |
227
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1254 if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1255 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1256 "fcntl(FD_CLOEXEC) \"%s\" failed", |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1257 file[i].name.data); |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1258 |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1259 if (ngx_close_file(fd) == NGX_FILE_ERROR) { |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1260 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1261 ngx_close_file_n " \"%s\" failed", |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1262 file[i].name.data); |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1263 } |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1264 |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1265 continue; |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1266 } |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1267 #endif |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1268 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1269 if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1270 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1271 ngx_close_file_n " \"%s\" failed", |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1272 file[i].name.data); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1273 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1274 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1275 file[i].fd = fd; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1276 } |
249
2a0540287298
nginx-0.0.2-2004-02-03-19:43:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
237
diff
changeset
|
1277 |
5260
e088695737c3
Core: consolidated log-related code.
Vladimir Homutov <vl@nginx.com>
parents:
5250
diff
changeset
|
1278 (void) ngx_log_redirect_stderr(cycle); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1279 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1280 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1281 |
972 | 1282 ngx_shm_zone_t * |
1283 ngx_shared_memory_add(ngx_conf_t *cf, ngx_str_t *name, size_t size, void *tag) | |
1284 { | |
1285 ngx_uint_t i; | |
1286 ngx_shm_zone_t *shm_zone; | |
1287 ngx_list_part_t *part; | |
1288 | |
1289 part = &cf->cycle->shared_memory.part; | |
1290 shm_zone = part->elts; | |
1291 | |
1292 for (i = 0; /* void */ ; i++) { | |
1293 | |
1294 if (i >= part->nelts) { | |
1295 if (part->next == NULL) { | |
1296 break; | |
1297 } | |
1298 part = part->next; | |
1299 shm_zone = part->elts; | |
1300 i = 0; | |
1301 } | |
1302 | |
2716
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2688
diff
changeset
|
1303 if (name->len != shm_zone[i].shm.name.len) { |
972 | 1304 continue; |
1305 } | |
1306 | |
2716
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2688
diff
changeset
|
1307 if (ngx_strncmp(name->data, shm_zone[i].shm.name.data, name->len) |
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2688
diff
changeset
|
1308 != 0) |
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2688
diff
changeset
|
1309 { |
972 | 1310 continue; |
1311 } | |
1312 | |
4777
6e37004865fb
Reorder checks in ngx_shared_memory_add() for more consistent error messages.
Andrey Belov <defan@nginx.com>
parents:
4412
diff
changeset
|
1313 if (tag != shm_zone[i].tag) { |
6e37004865fb
Reorder checks in ngx_shared_memory_add() for more consistent error messages.
Andrey Belov <defan@nginx.com>
parents:
4412
diff
changeset
|
1314 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
6e37004865fb
Reorder checks in ngx_shared_memory_add() for more consistent error messages.
Andrey Belov <defan@nginx.com>
parents:
4412
diff
changeset
|
1315 "the shared memory zone \"%V\" is " |
6e37004865fb
Reorder checks in ngx_shared_memory_add() for more consistent error messages.
Andrey Belov <defan@nginx.com>
parents:
4412
diff
changeset
|
1316 "already declared for a different use", |
6e37004865fb
Reorder checks in ngx_shared_memory_add() for more consistent error messages.
Andrey Belov <defan@nginx.com>
parents:
4412
diff
changeset
|
1317 &shm_zone[i].shm.name); |
6e37004865fb
Reorder checks in ngx_shared_memory_add() for more consistent error messages.
Andrey Belov <defan@nginx.com>
parents:
4412
diff
changeset
|
1318 return NULL; |
6e37004865fb
Reorder checks in ngx_shared_memory_add() for more consistent error messages.
Andrey Belov <defan@nginx.com>
parents:
4412
diff
changeset
|
1319 } |
6e37004865fb
Reorder checks in ngx_shared_memory_add() for more consistent error messages.
Andrey Belov <defan@nginx.com>
parents:
4412
diff
changeset
|
1320 |
6116
48b3d5ddfb03
Core: allow shared memory size to be declared after a reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6110
diff
changeset
|
1321 if (shm_zone[i].shm.size == 0) { |
48b3d5ddfb03
Core: allow shared memory size to be declared after a reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6110
diff
changeset
|
1322 shm_zone[i].shm.size = size; |
48b3d5ddfb03
Core: allow shared memory size to be declared after a reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6110
diff
changeset
|
1323 } |
48b3d5ddfb03
Core: allow shared memory size to be declared after a reference.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6110
diff
changeset
|
1324 |
972 | 1325 if (size && size != shm_zone[i].shm.size) { |
1326 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2716
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2688
diff
changeset
|
1327 "the size %uz of shared memory zone \"%V\" " |
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2688
diff
changeset
|
1328 "conflicts with already declared size %uz", |
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2688
diff
changeset
|
1329 size, &shm_zone[i].shm.name, shm_zone[i].shm.size); |
972 | 1330 return NULL; |
1331 } | |
1332 | |
1333 return &shm_zone[i]; | |
1334 } | |
1335 | |
1336 shm_zone = ngx_list_push(&cf->cycle->shared_memory); | |
1337 | |
1338 if (shm_zone == NULL) { | |
1339 return NULL; | |
1340 } | |
1341 | |
1342 shm_zone->data = NULL; | |
1343 shm_zone->shm.log = cf->cycle->log; | |
7394
650574a44505
Core: free shared memory on cycle initialization failure.
Ruslan Ermilov <ru@nginx.com>
parents:
7366
diff
changeset
|
1344 shm_zone->shm.addr = NULL; |
972 | 1345 shm_zone->shm.size = size; |
2716
d5896f6608e8
move zone name from ngx_shm_zone_t to ngx_shm_t to use Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2688
diff
changeset
|
1346 shm_zone->shm.name = *name; |
2720
b3b8c66bd520
support attaching to an existent Win32 shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
2717
diff
changeset
|
1347 shm_zone->shm.exists = 0; |
972 | 1348 shm_zone->init = NULL; |
1349 shm_zone->tag = tag; | |
6103
79ddb0bdb273
Upstream: the "zone" directive.
Ruslan Ermilov <ru@nginx.com>
parents:
6016
diff
changeset
|
1350 shm_zone->noreuse = 0; |
972 | 1351 |
1352 return shm_zone; | |
1353 } | |
1354 | |
1355 | |
563 | 1356 static void |
1357 ngx_clean_old_cycles(ngx_event_t *ev) | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1358 { |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
286
diff
changeset
|
1359 ngx_uint_t i, n, found, live; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1360 ngx_log_t *log; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1361 ngx_cycle_t **cycle; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1362 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1363 log = ngx_cycle->log; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1364 ngx_temp_pool->log = log; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1365 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
255
diff
changeset
|
1366 ngx_log_debug0(NGX_LOG_DEBUG_CORE, log, 0, "clean old cycles"); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1367 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1368 live = 0; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1369 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1370 cycle = ngx_old_cycles.elts; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1371 for (i = 0; i < ngx_old_cycles.nelts; i++) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1372 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1373 if (cycle[i] == NULL) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1374 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1375 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1376 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1377 found = 0; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1378 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1379 for (n = 0; n < cycle[i]->connection_n; n++) { |
561 | 1380 if (cycle[i]->connections[n].fd != (ngx_socket_t) -1) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1381 found = 1; |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
255
diff
changeset
|
1382 |
6480 | 1383 ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "live fd:%ui", n); |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
255
diff
changeset
|
1384 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1385 break; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1386 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1387 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1388 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1389 if (found) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1390 live = 1; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1391 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1392 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1393 |
6480 | 1394 ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "clean old cycle: %ui", i); |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
255
diff
changeset
|
1395 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1396 ngx_destroy_pool(cycle[i]->pool); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1397 cycle[i] = NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1398 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1399 |
6480 | 1400 ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "old cycles status: %ui", live); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1401 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1402 if (live) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1403 ngx_add_timer(ev, 30000); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1404 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1405 } else { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1406 ngx_destroy_pool(ngx_temp_pool); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1407 ngx_temp_pool = NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1408 ngx_old_cycles.nelts = 0; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1409 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1410 } |
6930
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1411 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1412 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1413 void |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1414 ngx_set_shutdown_timer(ngx_cycle_t *cycle) |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1415 { |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1416 ngx_core_conf_t *ccf; |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1417 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1418 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1419 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1420 if (ccf->shutdown_timeout) { |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1421 ngx_shutdown_event.handler = ngx_shutdown_timer_handler; |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1422 ngx_shutdown_event.data = cycle; |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1423 ngx_shutdown_event.log = cycle->log; |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1424 ngx_shutdown_event.cancelable = 1; |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1425 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1426 ngx_add_timer(&ngx_shutdown_event, ccf->shutdown_timeout); |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1427 } |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1428 } |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1429 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1430 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1431 static void |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1432 ngx_shutdown_timer_handler(ngx_event_t *ev) |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1433 { |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1434 ngx_uint_t i; |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1435 ngx_cycle_t *cycle; |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1436 ngx_connection_t *c; |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1437 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1438 cycle = ev->data; |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1439 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1440 c = cycle->connections; |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1441 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1442 for (i = 0; i < cycle->connection_n; i++) { |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1443 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1444 if (c[i].fd == (ngx_socket_t) -1 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1445 || c[i].read == NULL |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1446 || c[i].read->accept |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1447 || c[i].read->channel |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1448 || c[i].read->resolver) |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1449 { |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1450 continue; |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1451 } |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1452 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1453 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1454 "*%uA shutdown timeout", c[i].number); |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1455 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1456 c[i].close = 1; |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1457 c[i].error = 1; |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1458 |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1459 c[i].read->handler(c[i].read); |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1460 } |
97c99bb43737
Introduced worker_shutdown_timeout.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6821
diff
changeset
|
1461 } |