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