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