Mercurial > hg > nginx-quic
annotate src/core/ngx_cycle.c @ 1909:cbd321d1e1b3
C++ compatibility
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 03 Mar 2008 16:32:16 +0000 |
parents | 45db41a0591c |
children | b56d4b1ebac7 |
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 |
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
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
440
diff
changeset
|
5 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_event.h> |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
611 | 12 static ngx_int_t ngx_test_lockfile(u_char *file, ngx_log_t *log); |
605 | 13 static void ngx_destroy_cycle_pools(ngx_conf_t *conf); |
479 | 14 static ngx_int_t ngx_cmp_sockaddr(struct sockaddr *sa1, struct sockaddr *sa2); |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
15 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
|
16 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
17 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
18 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
|
19 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
|
20 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 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
|
22 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
|
23 |
318
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
24 ngx_uint_t ngx_test_config; |
56496082668b
nginx-0.0.3-2004-04-16-09:14:16 import
Igor Sysoev <igor@sysoev.ru>
parents:
317
diff
changeset
|
25 |
381
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
26 #if (NGX_THREADS) |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
27 ngx_tls_key_t ngx_core_tls_key; |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
337
diff
changeset
|
28 #endif |
02a511569afb
nginx-0.0.7-2004-07-07-19:01:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
337
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 |
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
|
35 #ifdef NGX_ERROR_LOG_PATH |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
diff
changeset
|
36 static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH); |
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
|
37 #else |
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
|
38 static ngx_str_t error_log = ngx_null_string; |
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
|
39 #endif |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
diff
changeset
|
40 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
41 |
563 | 42 ngx_cycle_t * |
43 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
|
44 { |
1740
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
45 void *rv; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
46 char **senv, **env; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
47 u_char *lock_file; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
48 ngx_uint_t i, n; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
49 ngx_log_t *log; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
50 ngx_conf_t conf; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
51 ngx_pool_t *pool; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
52 ngx_cycle_t *cycle, **old; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
53 ngx_shm_zone_t *shm_zone, *oshm_zone; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
54 ngx_slab_pool_t *shpool; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
55 ngx_list_part_t *part, *opart; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
56 ngx_open_file_t *file; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
57 ngx_listening_t *ls, *nls; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
58 ngx_core_conf_t *ccf, *old_ccf; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
59 ngx_core_module_t *module; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
60 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
61 log = old_cycle->log; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
62 |
507 | 63 pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log); |
501 | 64 if (pool == NULL) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
65 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
66 } |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
67 pool->log = log; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
68 |
501 | 69 cycle = ngx_pcalloc(pool, sizeof(ngx_cycle_t)); |
70 if (cycle == NULL) { | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
71 ngx_destroy_pool(pool); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
72 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
73 } |
501 | 74 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
75 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
|
76 cycle->log = log; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
77 cycle->old_cycle = old_cycle; |
337
4feff829a849
nginx-0.0.3-2004-05-19-00:28:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
336
diff
changeset
|
78 cycle->root.len = sizeof(NGX_PREFIX) - 1; |
4feff829a849
nginx-0.0.3-2004-05-19-00:28:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
336
diff
changeset
|
79 cycle->root.data = (u_char *) NGX_PREFIX; |
336
ca9a7f8c86da
nginx-0.0.3-2004-05-18-19:29:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
333
diff
changeset
|
80 |
ca9a7f8c86da
nginx-0.0.3-2004-05-18-19:29:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
333
diff
changeset
|
81 |
605 | 82 cycle->conf_file.len = old_cycle->conf_file.len; |
83 cycle->conf_file.data = ngx_palloc(pool, old_cycle->conf_file.len + 1); | |
84 if (cycle->conf_file.data == NULL) { | |
85 ngx_destroy_pool(pool); | |
86 return NULL; | |
87 } | |
88 ngx_cpystrn(cycle->conf_file.data, old_cycle->conf_file.data, | |
89 old_cycle->conf_file.len + 1); | |
90 | |
91 | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
92 n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10; |
501 | 93 |
94 cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *)); | |
95 if (cycle->pathes.elts == NULL) { | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
96 ngx_destroy_pool(pool); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
97 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
98 } |
501 | 99 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
100 cycle->pathes.nelts = 0; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
101 cycle->pathes.size = sizeof(ngx_path_t *); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
102 cycle->pathes.nalloc = n; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
103 cycle->pathes.pool = pool; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
104 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
105 |
414
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
106 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
|
107 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
|
108 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
|
109 n += part->nelts; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
110 } |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
111 |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
112 } else { |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
113 n = 20; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
114 } |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
115 |
416
b9bd635011de
nginx-0.0.10-2004-09-06-22:45:00 import
Igor Sysoev <igor@sysoev.ru>
parents:
415
diff
changeset
|
116 if (ngx_list_init(&cycle->open_files, pool, n, sizeof(ngx_open_file_t)) |
605 | 117 == NGX_ERROR) |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
diff
changeset
|
118 { |
414
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
119 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
|
120 return NULL; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
121 } |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
122 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
123 |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
124 if (old_cycle->shared_memory.part.nelts) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
125 n = old_cycle->shared_memory.part.nelts; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
126 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
|
127 { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
128 n += part->nelts; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
129 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
130 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
131 } else { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
132 n = 1; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
133 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
134 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
135 if (ngx_list_init(&cycle->shared_memory, pool, n, sizeof(ngx_shm_zone_t)) |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
136 == NGX_ERROR) |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
137 { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
138 ngx_destroy_pool(pool); |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
139 return NULL; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
140 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
141 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
142 |
501 | 143 cycle->new_log = ngx_log_create_errlog(cycle, NULL); |
144 if (cycle->new_log == NULL) { | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
145 ngx_destroy_pool(pool); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
146 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
147 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
148 |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
diff
changeset
|
149 cycle->new_log->file->name = error_log; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
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 n = old_cycle->listening.nelts ? old_cycle->listening.nelts : 10; |
501 | 153 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
154 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
|
155 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
|
156 ngx_destroy_pool(pool); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
157 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
158 } |
501 | 159 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
160 cycle->listening.nelts = 0; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
161 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
|
162 cycle->listening.nalloc = n; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
163 cycle->listening.pool = pool; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
164 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
165 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
166 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
|
167 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
|
168 ngx_destroy_pool(pool); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
169 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
170 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
171 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
172 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
173 for (i = 0; ngx_modules[i]; i++) { |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
174 if (ngx_modules[i]->type != NGX_CORE_MODULE) { |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
175 continue; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
176 } |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
177 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
178 module = ngx_modules[i]->ctx; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
179 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
180 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
|
181 rv = module->create_conf(cycle); |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
182 if (rv == NGX_CONF_ERROR) { |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
183 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
|
184 return NULL; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
185 } |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
186 cycle->conf_ctx[ngx_modules[i]->index] = rv; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
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 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
189 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
190 |
1740
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
191 senv = environ; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
192 |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
193 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
194 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
|
195 /* STUB: init array ? */ |
501 | 196 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
|
197 if (conf.args == NULL) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
198 ngx_destroy_pool(pool); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
199 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
200 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
201 |
593 | 202 conf.temp_pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log); |
203 if (conf.temp_pool == NULL) { | |
204 ngx_destroy_pool(pool); | |
205 return NULL; | |
206 } | |
207 | |
605 | 208 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
209 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
|
210 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
|
211 conf.pool = pool; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
212 conf.log = log; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
213 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
|
214 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
|
215 |
728
e82eed614d4a
turn off startup debug logging introduced by previous commit
Igor Sysoev <igor@sysoev.ru>
parents:
727
diff
changeset
|
216 #if 0 |
455 | 217 log->log_level = NGX_LOG_DEBUG_ALL; |
218 #endif | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
219 |
255
e6938ca7331a
nginx-0.0.2-2004-02-09-23:47:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
249
diff
changeset
|
220 if (ngx_conf_parse(&conf, &cycle->conf_file) != NGX_CONF_OK) { |
605 | 221 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
|
222 return NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
223 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
224 |
320
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
225 if (ngx_test_config) { |
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
226 ngx_log_error(NGX_LOG_INFO, log, 0, |
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
227 "the configuration file %s syntax is ok", |
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
228 cycle->conf_file.data); |
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
229 } |
d621239c30f7
nginx-0.0.3-2004-04-18-23:06:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
318
diff
changeset
|
230 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
231 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
232 for (i = 0; ngx_modules[i]; i++) { |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
233 if (ngx_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
|
234 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
235 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
236 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
237 module = ngx_modules[i]->ctx; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
238 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
239 if (module->init_conf) { |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
240 if (module->init_conf(cycle, cycle->conf_ctx[ngx_modules[i]->index]) |
593 | 241 == 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
|
242 { |
605 | 243 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
|
244 return NULL; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
245 } |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
246 } |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
247 } |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
248 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
249 |
611 | 250 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
|
251 |
461 | 252 #if !(NGX_WIN32) |
611 | 253 |
254 if (ngx_test_config) { | |
255 | |
256 if (ngx_create_pidfile(&ccf->pid, log) != NGX_OK) { | |
257 goto failed; | |
258 } | |
259 | |
260 } else if (!ngx_is_init_cycle(old_cycle)) { | |
261 | |
262 /* | |
263 * we do not create the pid file in the first ngx_init_cycle() call | |
264 * because we need to write the demonized process pid | |
265 */ | |
266 | |
267 old_ccf = (ngx_core_conf_t *) ngx_get_conf(old_cycle->conf_ctx, | |
268 ngx_core_module); | |
269 if (ccf->pid.len != old_ccf->pid.len | |
270 || ngx_strcmp(ccf->pid.data, old_ccf->pid.data) != 0) | |
271 { | |
272 /* new pid file name */ | |
273 | |
274 if (ngx_create_pidfile(&ccf->pid, log) != NGX_OK) { | |
275 goto failed; | |
276 } | |
277 | |
278 ngx_delete_pidfile(old_cycle); | |
279 } | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
280 } |
611 | 281 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
282 #endif |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
283 |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
284 |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
285 if (ngx_test_lockfile(cycle->lock_file.data, log) != NGX_OK) { |
611 | 286 goto failed; |
287 } | |
467 | 288 |
611 | 289 |
290 if (ngx_create_pathes(cycle, ccf->user) != NGX_OK) { | |
291 goto failed; | |
467 | 292 } |
293 | |
294 | |
611 | 295 /* 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
|
296 |
611 | 297 part = &cycle->open_files.part; |
298 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
|
299 |
611 | 300 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
|
301 |
611 | 302 if (i >= part->nelts) { |
303 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
|
304 break; |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
305 } |
611 | 306 part = part->next; |
307 file = part->elts; | |
308 i = 0; | |
309 } | |
310 | |
311 if (file[i].name.data == NULL) { | |
312 continue; | |
313 } | |
314 | |
315 file[i].fd = ngx_open_file(file[i].name.data, NGX_FILE_RDWR, | |
1048
c4f666fc3a7e
ngx_open_file(name, access, create) > ngx_open_file(name, mode, create, access)
Igor Sysoev <igor@sysoev.ru>
parents:
1032
diff
changeset
|
316 NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND, |
c4f666fc3a7e
ngx_open_file(name, access, create) > ngx_open_file(name, mode, create, access)
Igor Sysoev <igor@sysoev.ru>
parents:
1032
diff
changeset
|
317 NGX_FILE_DEFAULT_ACCESS); |
611 | 318 |
319 ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0, | |
320 "log: %p %d \"%s\"", | |
321 &file[i], file[i].fd, file[i].name.data); | |
322 | |
323 if (file[i].fd == NGX_INVALID_FILE) { | |
324 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | |
325 ngx_open_file_n " \"%s\" failed", | |
326 file[i].name.data); | |
327 goto failed; | |
328 } | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
329 |
461 | 330 #if (NGX_WIN32) |
611 | 331 if (ngx_file_append_mode(file[i].fd) != NGX_OK) { |
332 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | |
333 ngx_file_append_mode_n " \"%s\" failed", | |
334 file[i].name.data); | |
335 goto failed; | |
336 } | |
227
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
337 #else |
611 | 338 if (fcntl(file[i].fd, F_SETFD, FD_CLOEXEC) == -1) { |
339 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | |
340 "fcntl(FD_CLOEXEC) \"%s\" failed", | |
341 file[i].name.data); | |
342 goto failed; | |
343 } | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
344 #endif |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
345 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
346 |
317
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
347 cycle->log = cycle->new_log; |
1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
Igor Sysoev <igor@sysoev.ru>
parents:
316
diff
changeset
|
348 pool->log = cycle->new_log; |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
349 |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
diff
changeset
|
350 if (cycle->log->log_level == 0) { |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
diff
changeset
|
351 cycle->log->log_level = NGX_LOG_ERR; |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
diff
changeset
|
352 } |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
diff
changeset
|
353 |
461 | 354 |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
355 /* create shared memory */ |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
356 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
357 part = &cycle->shared_memory.part; |
972 | 358 shm_zone = part->elts; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
359 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
360 for (i = 0; /* void */ ; i++) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
361 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
362 if (i >= part->nelts) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
363 if (part->next == NULL) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
364 break; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
365 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
366 part = part->next; |
972 | 367 shm_zone = part->elts; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
368 i = 0; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
369 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
370 |
979 | 371 if (shm_zone[i].shm.size == 0) { |
372 ngx_log_error(NGX_LOG_EMERG, log, 0, | |
373 "zero size shared memory zone \"%V\"", | |
374 &shm_zone[i].name); | |
375 goto failed; | |
376 } | |
377 | |
1032
899050121f43
quick fix for case when ssl_session_cache defined,
Igor Sysoev <igor@sysoev.ru>
parents:
996
diff
changeset
|
378 if (shm_zone[i].init == NULL) { |
899050121f43
quick fix for case when ssl_session_cache defined,
Igor Sysoev <igor@sysoev.ru>
parents:
996
diff
changeset
|
379 /* unused shared zone */ |
899050121f43
quick fix for case when ssl_session_cache defined,
Igor Sysoev <igor@sysoev.ru>
parents:
996
diff
changeset
|
380 continue; |
899050121f43
quick fix for case when ssl_session_cache defined,
Igor Sysoev <igor@sysoev.ru>
parents:
996
diff
changeset
|
381 } |
899050121f43
quick fix for case when ssl_session_cache defined,
Igor Sysoev <igor@sysoev.ru>
parents:
996
diff
changeset
|
382 |
972 | 383 shm_zone[i].shm.log = cycle->log; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
384 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
385 opart = &old_cycle->shared_memory.part; |
972 | 386 oshm_zone = opart->elts; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
387 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
388 for (n = 0; /* void */ ; n++) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
389 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
390 if (n >= opart->nelts) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
391 if (opart->next == NULL) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
392 break; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
393 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
394 opart = opart->next; |
972 | 395 oshm_zone = opart->elts; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
396 n = 0; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
397 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
398 |
972 | 399 if (shm_zone[i].name.len != oshm_zone[n].name.len) { |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
400 continue; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
401 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
402 |
972 | 403 if (ngx_strncmp(shm_zone[i].name.data, oshm_zone[n].name.data, |
404 shm_zone[i].name.len) | |
405 != 0) | |
406 { | |
407 continue; | |
408 } | |
409 | |
410 if (shm_zone[i].shm.size == oshm_zone[n].shm.size) { | |
411 shm_zone[i].shm.addr = oshm_zone[n].shm.addr; | |
993
1b9a4d92173f
pass the inherited shm_zone data
Igor Sysoev <igor@sysoev.ru>
parents:
979
diff
changeset
|
412 |
1b9a4d92173f
pass the inherited shm_zone data
Igor Sysoev <igor@sysoev.ru>
parents:
979
diff
changeset
|
413 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
|
414 != NGX_OK) |
1b9a4d92173f
pass the inherited shm_zone data
Igor Sysoev <igor@sysoev.ru>
parents:
979
diff
changeset
|
415 { |
1b9a4d92173f
pass the inherited shm_zone data
Igor Sysoev <igor@sysoev.ru>
parents:
979
diff
changeset
|
416 goto failed; |
1b9a4d92173f
pass the inherited shm_zone data
Igor Sysoev <igor@sysoev.ru>
parents:
979
diff
changeset
|
417 } |
1b9a4d92173f
pass the inherited shm_zone data
Igor Sysoev <igor@sysoev.ru>
parents:
979
diff
changeset
|
418 |
996 | 419 goto shm_zone_found; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
420 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
421 |
972 | 422 ngx_shm_free(&oshm_zone[n].shm); |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
423 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
424 break; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
425 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
426 |
972 | 427 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
|
428 goto failed; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
429 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
430 |
972 | 431 shpool = (ngx_slab_pool_t *) shm_zone[i].shm.addr; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
432 |
972 | 433 shpool->end = shm_zone[i].shm.addr + shm_zone[i].shm.size; |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
434 shpool->min_shift = 3; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
435 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
436 #if (NGX_HAVE_ATOMIC_OPS) |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
437 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
438 lock_file = NULL; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
439 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
440 #else |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
441 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
442 lock_file = ngx_palloc(cycle->pool, |
972 | 443 cycle->lock_file.len + shm_zone[i].name.len); |
860
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 if (lock_file == NULL) { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
446 goto failed; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
447 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
448 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
449 (void) ngx_cpystrn(ngx_cpymem(lock_file, cycle->lock_file.data, |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
450 cycle->lock_file.len), |
972 | 451 shm_zone[i].name.data, shm_zone[i].name.len + 1); |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
452 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
453 #endif |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
454 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
455 if (ngx_shmtx_create(&shpool->mutex, (void *) &shpool->lock, lock_file) |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
456 != NGX_OK) |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
457 { |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
458 goto failed; |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
459 } |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
460 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
461 ngx_slab_init(shpool); |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
462 |
993
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], NULL) != NGX_OK) { |
972 | 464 goto failed; |
465 } | |
466 | |
996 | 467 shm_zone_found: |
860
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
468 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
469 continue; |
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 |
201d017ea470
slab allocator in shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
728
diff
changeset
|
472 |
611 | 473 /* handle the listening sockets */ |
461 | 474 |
611 | 475 if (old_cycle->listening.nelts) { |
476 ls = old_cycle->listening.elts; | |
477 for (i = 0; i < old_cycle->listening.nelts; i++) { | |
478 ls[i].remain = 0; | |
479 } | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
480 |
611 | 481 nls = cycle->listening.elts; |
482 for (n = 0; n < cycle->listening.nelts; n++) { | |
461 | 483 |
611 | 484 for (i = 0; i < old_cycle->listening.nelts; i++) { |
485 if (ls[i].ignore) { | |
486 continue; | |
487 } | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
488 |
611 | 489 if (ngx_cmp_sockaddr(nls[n].sockaddr, ls[i].sockaddr) == NGX_OK) |
490 { | |
491 nls[n].fd = ls[i].fd; | |
492 nls[n].previous = &ls[i]; | |
493 ls[i].remain = 1; | |
523 | 494 |
611 | 495 if (ls[n].backlog != nls[i].backlog) { |
496 nls[n].listen = 1; | |
497 } | |
537 | 498 |
523 | 499 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) |
500 | |
611 | 501 /* |
502 * FreeBSD, except the most recent versions, | |
503 * could not remove accept filter | |
504 */ | |
505 nls[n].deferred_accept = ls[i].deferred_accept; | |
523 | 506 |
611 | 507 if (ls[i].accept_filter && nls[n].accept_filter) { |
508 if (ngx_strcmp(ls[i].accept_filter, | |
509 nls[n].accept_filter) | |
510 != 0) | |
511 { | |
523 | 512 nls[n].delete_deferred = 1; |
513 nls[n].add_deferred = 1; | |
514 } | |
611 | 515 |
516 } else if (ls[i].accept_filter) { | |
517 nls[n].delete_deferred = 1; | |
518 | |
519 } else if (nls[n].accept_filter) { | |
520 nls[n].add_deferred = 1; | |
521 } | |
523 | 522 #endif |
523 | |
524 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) | |
525 | |
611 | 526 if (ls[n].deferred_accept && !nls[n].deferred_accept) { |
527 nls[n].delete_deferred = 1; | |
523 | 528 |
611 | 529 } else if (ls[i].deferred_accept != nls[n].deferred_accept) |
530 { | |
531 nls[n].add_deferred = 1; | |
532 } | |
523 | 533 #endif |
611 | 534 break; |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
535 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
536 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
537 |
611 | 538 if (nls[n].fd == -1) { |
539 nls[n].open = 1; | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
540 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
541 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
542 |
611 | 543 } else { |
544 ls = cycle->listening.elts; | |
545 for (i = 0; i < cycle->listening.nelts; i++) { | |
546 ls[i].open = 1; | |
547 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) | |
548 if (ls[i].accept_filter) { | |
549 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
|
550 } |
611 | 551 #endif |
552 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) | |
553 if (ls[i].deferred_accept) { | |
554 ls[i].add_deferred = 1; | |
523 | 555 } |
611 | 556 #endif |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
557 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
558 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
559 |
611 | 560 if (ngx_open_listening_sockets(cycle) != NGX_OK) { |
561 goto failed; | |
562 } | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
563 |
611 | 564 if (!ngx_test_config) { |
565 ngx_configure_listening_socket(cycle); | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
566 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
567 |
249
2a0540287298
nginx-0.0.2-2004-02-03-19:43:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
237
diff
changeset
|
568 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
569 /* 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
|
570 |
461 | 571 #if !(NGX_WIN32) |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
572 |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
573 if (!ngx_test_config && cycle->log->file->fd != STDERR_FILENO) { |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
574 |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
575 ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0, |
461 | 576 "dup2: %p %d \"%s\"", |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
577 cycle->log->file, |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
578 cycle->log->file->fd, cycle->log->file->name.data); |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
579 |
611 | 580 if (dup2(cycle->log->file->fd, STDERR_FILENO) == -1) { |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
581 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
582 "dup2(STDERR) failed"); |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
583 /* fatal */ |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
584 exit(1); |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
585 } |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
586 } |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
587 |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
588 #endif |
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
589 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
590 pool->log = cycle->log; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
591 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
592 for (i = 0; ngx_modules[i]; i++) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
593 if (ngx_modules[i]->init_module) { |
611 | 594 if (ngx_modules[i]->init_module(cycle) != NGX_OK) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
595 /* fatal */ |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
596 exit(1); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
597 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
598 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
599 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
600 |
467 | 601 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
602 /* 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
|
603 |
995
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
604 /* free the unnecessary shared memory */ |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
605 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
606 opart = &old_cycle->shared_memory.part; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
607 oshm_zone = opart->elts; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
608 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
609 for (i = 0; /* void */ ; i++) { |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
610 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
611 if (i >= opart->nelts) { |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
612 if (opart->next == NULL) { |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
613 goto old_shm_zone_done; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
614 } |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
615 opart = opart->next; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
616 oshm_zone = opart->elts; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
617 i = 0; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
618 } |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
619 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
620 part = &cycle->shared_memory.part; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
621 shm_zone = part->elts; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
622 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
623 for (n = 0; /* void */ ; n++) { |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
624 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
625 if (n >= part->nelts) { |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
626 if (part->next == NULL) { |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
627 break; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
628 } |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
629 part = part->next; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
630 shm_zone = part->elts; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
631 n = 0; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
632 } |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
633 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
634 if (oshm_zone[i].name.len == shm_zone[n].name.len |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
635 && ngx_strncmp(oshm_zone[i].name.data, |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
636 shm_zone[n].name.data, |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
637 oshm_zone[i].name.len) |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
638 == 0) |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
639 { |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
640 goto live_shm_zone; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
641 } |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
642 } |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
643 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
644 ngx_shm_free(&oshm_zone[i].shm); |
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 live_shm_zone: |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
647 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
648 continue; |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
649 } |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
650 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
651 old_shm_zone_done: |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
652 |
4b0d9e2b31c6
free the unnecessary shared memory
Igor Sysoev <igor@sysoev.ru>
parents:
994
diff
changeset
|
653 |
994 | 654 /* 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
|
655 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
656 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
|
657 for (i = 0; i < old_cycle->listening.nelts; i++) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
658 if (ls[i].remain) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
659 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
660 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
661 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
662 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
|
663 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, |
543 | 664 ngx_close_socket_n " listening socket on %V failed", |
461 | 665 &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
|
666 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
667 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
668 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
669 |
994 | 670 /* 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
|
671 |
414
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
672 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
|
673 file = part->elts; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
674 |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
675 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
|
676 |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
677 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
|
678 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
|
679 break; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
680 } |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
681 part = part->next; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
682 file = part->elts; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
683 i = 0; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
684 } |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
685 |
449
3b1e8c9df9ad
nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents:
448
diff
changeset
|
686 if (file[i].fd == NGX_INVALID_FILE || file[i].fd == ngx_stderr_fileno) { |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
687 continue; |
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 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
690 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
|
691 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
|
692 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
|
693 file[i].name.data); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
694 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
695 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
696 |
593 | 697 ngx_destroy_pool(conf.temp_pool); |
698 | |
605 | 699 if (ngx_process == NGX_PROCESS_MASTER || ngx_is_init_cycle(old_cycle)) { |
700 | |
1740
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
701 /* |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
702 * perl_destruct() frees environ if it is not the same as it was at |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
703 * perl_construct() time. So we have saved an previous cycle |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
704 * 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
|
705 */ |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
706 |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
707 env = environ; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
708 environ = senv; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
709 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
710 ngx_destroy_pool(old_cycle->pool); |
611 | 711 cycle->old_cycle = NULL; |
712 | |
1740
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
713 environ = env; |
45db41a0591c
restore environ for perl_destruct()
Igor Sysoev <igor@sysoev.ru>
parents:
1704
diff
changeset
|
714 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
715 return cycle; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
716 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
717 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
718 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
719 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
|
720 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
|
721 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
|
722 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
723 "can not create ngx_temp_pool"); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
724 exit(1); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
725 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
726 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
727 n = 10; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
728 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
|
729 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
|
730 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
|
731 exit(1); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
732 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
733 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
|
734 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
|
735 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
|
736 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
|
737 |
509 | 738 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
|
739 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
|
740 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
|
741 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
|
742 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
743 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
744 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
|
745 |
501 | 746 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
|
747 if (old == NULL) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
748 exit(1); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
749 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
750 *old = old_cycle; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
751 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
752 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
|
753 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
|
754 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
|
755 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
756 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
757 return cycle; |
611 | 758 |
759 | |
760 failed: | |
761 | |
1165 | 762 if (!ngx_is_init_cycle(old_cycle)) { |
763 old_ccf = (ngx_core_conf_t *) ngx_get_conf(old_cycle->conf_ctx, | |
764 ngx_core_module); | |
765 if (old_ccf->environment) { | |
766 environ = old_ccf->environment; | |
767 } | |
768 } | |
769 | |
611 | 770 /* rollback the new cycle configuration */ |
771 | |
772 part = &cycle->open_files.part; | |
773 file = part->elts; | |
774 | |
775 for (i = 0; /* void */ ; i++) { | |
776 | |
777 if (i >= part->nelts) { | |
778 if (part->next == NULL) { | |
779 break; | |
780 } | |
781 part = part->next; | |
782 file = part->elts; | |
783 i = 0; | |
784 } | |
785 | |
786 if (file[i].fd == NGX_INVALID_FILE || file[i].fd == ngx_stderr_fileno) { | |
787 continue; | |
788 } | |
789 | |
790 if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) { | |
791 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | |
792 ngx_close_file_n " \"%s\" failed", | |
793 file[i].name.data); | |
794 } | |
795 } | |
796 | |
797 if (ngx_test_config) { | |
798 ngx_destroy_cycle_pools(&conf); | |
799 return NULL; | |
800 } | |
801 | |
802 ls = cycle->listening.elts; | |
803 for (i = 0; i < cycle->listening.nelts; i++) { | |
804 if (ls[i].fd == -1 || !ls[i].open) { | |
805 continue; | |
806 } | |
807 | |
808 if (ngx_close_socket(ls[i].fd) == -1) { | |
809 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, | |
810 ngx_close_socket_n " %V failed", | |
811 &ls[i].addr_text); | |
812 } | |
813 } | |
814 | |
815 ngx_destroy_cycle_pools(&conf); | |
816 | |
817 return NULL; | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
818 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
819 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
820 |
605 | 821 static void |
822 ngx_destroy_cycle_pools(ngx_conf_t *conf) | |
823 { | |
824 ngx_destroy_pool(conf->temp_pool); | |
825 ngx_destroy_pool(conf->pool); | |
826 } | |
827 | |
828 | |
563 | 829 static ngx_int_t |
830 ngx_cmp_sockaddr(struct sockaddr *sa1, struct sockaddr *sa2) | |
461 | 831 { |
832 struct sockaddr_in *sin1, *sin2; | |
833 | |
834 /* AF_INET only */ | |
835 | |
479 | 836 if (sa1->sa_family != AF_INET || sa2->sa_family != AF_INET) { |
461 | 837 return NGX_DECLINED; |
838 } | |
839 | |
479 | 840 sin1 = (struct sockaddr_in *) sa1; |
841 sin2 = (struct sockaddr_in *) sa2; | |
461 | 842 |
843 if (sin1->sin_addr.s_addr != sin2->sin_addr.s_addr) { | |
844 return NGX_DECLINED; | |
845 } | |
846 | |
847 if (sin1->sin_port != sin2->sin_port) { | |
848 return NGX_DECLINED; | |
849 } | |
850 | |
851 return NGX_OK; | |
852 } | |
853 | |
854 | |
855 #if !(NGX_WIN32) | |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
856 |
563 | 857 ngx_int_t |
611 | 858 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
|
859 { |
611 | 860 size_t len; |
337
4feff829a849
nginx-0.0.3-2004-05-19-00:28:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
336
diff
changeset
|
861 ngx_uint_t trunc; |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
862 ngx_file_t file; |
942
7ddc5345fb4f
fix for Linix/ppc64 or FreeBSD/amd64 in 32-bit mode,
Igor Sysoev <igor@sysoev.ru>
parents:
860
diff
changeset
|
863 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
|
864 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
865 ngx_memzero(&file, sizeof(ngx_file_t)); |
543 | 866 |
611 | 867 file.name = *name; |
868 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
|
869 |
611 | 870 trunc = ngx_test_config ? 0 : 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
|
871 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
872 file.fd = ngx_open_file(file.name.data, NGX_FILE_RDWR, |
1048
c4f666fc3a7e
ngx_open_file(name, access, create) > ngx_open_file(name, mode, create, access)
Igor Sysoev <igor@sysoev.ru>
parents:
1032
diff
changeset
|
873 NGX_FILE_CREATE_OR_OPEN|trunc, |
c4f666fc3a7e
ngx_open_file(name, access, create) > ngx_open_file(name, mode, create, access)
Igor Sysoev <igor@sysoev.ru>
parents:
1032
diff
changeset
|
874 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
|
875 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
876 if (file.fd == NGX_INVALID_FILE) { |
611 | 877 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
|
878 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
|
879 return NGX_ERROR; |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
880 } |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
881 |
337
4feff829a849
nginx-0.0.3-2004-05-19-00:28:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
336
diff
changeset
|
882 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
|
883 len = ngx_snprintf(pid, NGX_INT64_LEN + 2, "%P%N", ngx_pid) - pid; |
461 | 884 |
337
4feff829a849
nginx-0.0.3-2004-05-19-00:28:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
336
diff
changeset
|
885 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
|
886 return NGX_ERROR; |
4feff829a849
nginx-0.0.3-2004-05-19-00:28:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
336
diff
changeset
|
887 } |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
888 } |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
889 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
890 if (ngx_close_file(file.fd) == NGX_FILE_ERROR) { |
611 | 891 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
|
892 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
|
893 } |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
894 |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
895 return NGX_OK; |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
896 } |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
897 |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
898 |
563 | 899 void |
900 ngx_delete_pidfile(ngx_cycle_t *cycle) | |
577 | 901 { |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
902 u_char *name; |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
903 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
|
904 |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
905 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
|
906 |
543 | 907 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
|
908 |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
909 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
|
910 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
|
911 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
|
912 } |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
913 } |
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
914 |
311
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
915 #endif |
11ff50a35d6d
nginx-0.0.3-2004-04-12-20:38:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
310
diff
changeset
|
916 |
310
a9a9af2c7370
nginx-0.0.3-2004-04-12-10:10:53 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
917 |
611 | 918 static ngx_int_t |
919 ngx_test_lockfile(u_char *file, ngx_log_t *log) | |
920 { | |
921 #if !(NGX_HAVE_ATOMIC_OPS) | |
922 ngx_fd_t fd; | |
923 | |
1100
01884449985f
fix building on platforms with non-supported atomic operations
Igor Sysoev <igor@sysoev.ru>
parents:
1048
diff
changeset
|
924 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
|
925 NGX_FILE_DEFAULT_ACCESS); |
611 | 926 |
927 if (fd == NGX_INVALID_FILE) { | |
928 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | |
929 ngx_open_file_n " \"%s\" failed", file); | |
930 return NGX_ERROR; | |
931 } | |
932 | |
933 if (ngx_close_file(fd) == NGX_FILE_ERROR) { | |
934 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | |
935 ngx_close_file_n " \"%s\" failed", file); | |
936 } | |
937 | |
938 if (ngx_delete_file(file) == NGX_FILE_ERROR) { | |
939 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | |
940 ngx_delete_file_n " \"%s\" failed", file); | |
941 } | |
942 | |
943 #endif | |
944 | |
945 return NGX_OK; | |
946 } | |
947 | |
948 | |
563 | 949 void |
950 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
|
951 { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
952 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
|
953 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
|
954 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
|
955 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
|
956 |
414
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
957 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
|
958 file = part->elts; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
959 |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
960 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
|
961 |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
962 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
|
963 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
|
964 break; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
965 } |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
966 part = part->next; |
523 | 967 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
|
968 i = 0; |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
969 } |
388a842cbbe1
nginx-0.0.10-2004-09-03-19:50:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
381
diff
changeset
|
970 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
971 if (file[i].name.data == NULL) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
972 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
973 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
974 |
571 | 975 if (file[i].buffer && file[i].pos - file[i].buffer != 0) { |
976 ngx_write_fd(file[i].fd, file[i].buffer, | |
977 file[i].pos - file[i].buffer); | |
978 file[i].pos = file[i].buffer; | |
979 } | |
980 | |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
981 fd = ngx_open_file(file[i].name.data, NGX_FILE_RDWR, |
1048
c4f666fc3a7e
ngx_open_file(name, access, create) > ngx_open_file(name, mode, create, access)
Igor Sysoev <igor@sysoev.ru>
parents:
1032
diff
changeset
|
982 NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND, |
c4f666fc3a7e
ngx_open_file(name, access, create) > ngx_open_file(name, mode, create, access)
Igor Sysoev <igor@sysoev.ru>
parents:
1032
diff
changeset
|
983 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
|
984 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
985 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
|
986 "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
|
987 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
|
988 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
989 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
|
990 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
|
991 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
|
992 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
993 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
994 |
461 | 995 #if (NGX_WIN32) |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
996 if (ngx_file_append_mode(fd) == NGX_ERROR) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
997 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
|
998 ngx_file_append_mode_n " \"%s\" failed", |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
999 file[i].name.data); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1000 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1001 if (ngx_close_file(fd) == NGX_FILE_ERROR) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1002 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
|
1003 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
|
1004 file[i].name.data); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1005 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1006 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1007 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1008 } |
227
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1009 #else |
517 | 1010 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
|
1011 ngx_file_info_t fi; |
452 | 1012 |
1013 if (ngx_file_info((const char *) file[i].name.data, &fi) == -1) { | |
1014 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
1015 ngx_file_info_n " \"%s\" failed", | |
1016 file[i].name.data); | |
1017 | |
1018 if (ngx_close_file(fd) == NGX_FILE_ERROR) { | |
1019 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
1020 ngx_close_file_n " \"%s\" failed", | |
1021 file[i].name.data); | |
1022 } | |
1023 } | |
1024 | |
467 | 1025 if (fi.st_uid != user) { |
1026 if (chown((const char *) file[i].name.data, user, -1) == -1) { | |
1027 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
1028 "chown(\"%s\", %d) failed", | |
1029 file[i].name.data, user); | |
1030 | |
1031 if (ngx_close_file(fd) == NGX_FILE_ERROR) { | |
1032 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
1033 ngx_close_file_n " \"%s\" failed", | |
1034 file[i].name.data); | |
1035 } | |
1036 } | |
1037 } | |
1038 | |
452 | 1039 if ((fi.st_mode & (S_IRUSR|S_IWUSR)) != (S_IRUSR|S_IWUSR)) { |
1040 | |
1041 fi.st_mode |= (S_IRUSR|S_IWUSR); | |
1042 | |
1043 if (chmod((const char *) file[i].name.data, fi.st_mode) == -1) { | |
1044 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
467 | 1045 "chmod() \"%s\" failed", file[i].name.data); |
452 | 1046 |
1047 if (ngx_close_file(fd) == NGX_FILE_ERROR) { | |
1048 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
1049 ngx_close_file_n " \"%s\" failed", | |
1050 file[i].name.data); | |
1051 } | |
1052 } | |
1053 } | |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
1054 } |
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
1055 |
227
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1056 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
|
1057 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
|
1058 "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
|
1059 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
|
1060 |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1061 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
|
1062 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
|
1063 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
|
1064 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
|
1065 } |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1066 |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1067 continue; |
2ba3477070ac
nginx-0.0.1-2004-01-14-21:19:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
220
diff
changeset
|
1068 } |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1069 #endif |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1070 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1071 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
|
1072 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
|
1073 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
|
1074 file[i].name.data); |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1075 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1076 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1077 file[i].fd = fd; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1078 } |
249
2a0540287298
nginx-0.0.2-2004-02-03-19:43:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
237
diff
changeset
|
1079 |
461 | 1080 #if !(NGX_WIN32) |
286
fc8dc489247e
nginx-0.0.2-2004-03-12-00:34:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
1081 |
415
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
diff
changeset
|
1082 if (cycle->log->file->fd != STDERR_FILENO) { |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
diff
changeset
|
1083 if (dup2(cycle->log->file->fd, STDERR_FILENO) == -1) { |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
diff
changeset
|
1084 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
diff
changeset
|
1085 "dup2(STDERR) failed"); |
3c56e834be46
nginx-0.0.10-2004-09-05-23:54:02 import
Igor Sysoev <igor@sysoev.ru>
parents:
414
diff
changeset
|
1086 } |
249
2a0540287298
nginx-0.0.2-2004-02-03-19:43:54 import
Igor Sysoev <igor@sysoev.ru>
parents:
237
diff
changeset
|
1087 } |
286
fc8dc489247e
nginx-0.0.2-2004-03-12-00:34:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
282
diff
changeset
|
1088 |
278
0ba4821f4460
nginx-0.0.2-2004-03-04-10:04:55 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
1089 #endif |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1090 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1091 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1092 |
972 | 1093 ngx_shm_zone_t * |
1094 ngx_shared_memory_add(ngx_conf_t *cf, ngx_str_t *name, size_t size, void *tag) | |
1095 { | |
1096 ngx_uint_t i; | |
1097 ngx_shm_zone_t *shm_zone; | |
1098 ngx_list_part_t *part; | |
1099 | |
1100 part = &cf->cycle->shared_memory.part; | |
1101 shm_zone = part->elts; | |
1102 | |
1103 for (i = 0; /* void */ ; i++) { | |
1104 | |
1105 if (i >= part->nelts) { | |
1106 if (part->next == NULL) { | |
1107 break; | |
1108 } | |
1109 part = part->next; | |
1110 shm_zone = part->elts; | |
1111 i = 0; | |
1112 } | |
1113 | |
1114 if (name->len != shm_zone[i].name.len) { | |
1115 continue; | |
1116 } | |
1117 | |
1118 if (ngx_strncmp(name->data, shm_zone[i].name.data, name->len) != 0) { | |
1119 continue; | |
1120 } | |
1121 | |
1122 if (size && size != shm_zone[i].shm.size) { | |
1123 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1124 "the size %uz of shared memory zone \"%V\" " | |
975 | 1125 "conflicts with already declared size %uz", |
1126 size, &shm_zone[i].name, shm_zone[i].shm.size); | |
972 | 1127 return NULL; |
1128 } | |
1129 | |
1130 if (tag != shm_zone[i].tag) { | |
1131 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1132 "the shared memory zone \"%V\" is " | |
975 | 1133 "already declared for a different use", |
1134 &shm_zone[i].name); | |
972 | 1135 return NULL; |
1136 } | |
1137 | |
1138 return &shm_zone[i]; | |
1139 } | |
1140 | |
1141 shm_zone = ngx_list_push(&cf->cycle->shared_memory); | |
1142 | |
1143 if (shm_zone == NULL) { | |
1144 return NULL; | |
1145 } | |
1146 | |
1147 shm_zone->data = NULL; | |
1148 shm_zone->shm.log = cf->cycle->log; | |
1149 shm_zone->shm.size = size; | |
1150 shm_zone->init = NULL; | |
1151 shm_zone->name = *name; | |
1152 shm_zone->tag = tag; | |
1153 | |
1154 return shm_zone; | |
1155 } | |
1156 | |
1157 | |
563 | 1158 static void |
1159 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
|
1160 { |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
286
diff
changeset
|
1161 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
|
1162 ngx_log_t *log; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1163 ngx_cycle_t **cycle; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1164 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1165 log = ngx_cycle->log; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1166 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
|
1167 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
255
diff
changeset
|
1168 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
|
1169 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1170 live = 0; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1171 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1172 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
|
1173 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
|
1174 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1175 if (cycle[i] == NULL) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1176 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1177 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1178 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1179 found = 0; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1180 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1181 for (n = 0; n < cycle[i]->connection_n; n++) { |
561 | 1182 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
|
1183 found = 1; |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
255
diff
changeset
|
1184 |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
255
diff
changeset
|
1185 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
|
1186 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1187 break; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1188 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1189 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1190 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1191 if (found) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1192 live = 1; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1193 continue; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1194 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1195 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
255
diff
changeset
|
1196 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
|
1197 |
218
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1198 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
|
1199 cycle[i] = NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1200 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1201 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
255
diff
changeset
|
1202 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
|
1203 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1204 if (live) { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1205 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
|
1206 |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1207 } else { |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1208 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
|
1209 ngx_temp_pool = NULL; |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1210 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
|
1211 } |
05592fd7a436
nginx-0.0.1-2004-01-05-23:55:48 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1212 } |