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