Mercurial > hg > nginx
comparison src/core/ngx_cycle.c @ 317:1308b98496a2
nginx-0.0.3-2004-04-15-19:34:36 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 15 Apr 2004 15:34:36 +0000 |
parents | a0beefedaf94 |
children | 56496082668b |
comparison
equal
deleted
inserted
replaced
316:a0beefedaf94 | 317:1308b98496a2 |
---|---|
21 | 21 |
22 ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle) | 22 ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle) |
23 { | 23 { |
24 void *rv; | 24 void *rv; |
25 ngx_uint_t i, n, failed; | 25 ngx_uint_t i, n, failed; |
26 ngx_log_t *log, *new_log; | 26 ngx_log_t *log; |
27 ngx_conf_t conf; | 27 ngx_conf_t conf; |
28 ngx_pool_t *pool; | 28 ngx_pool_t *pool; |
29 ngx_cycle_t *cycle, **old; | 29 ngx_cycle_t *cycle, **old; |
30 ngx_socket_t fd; | 30 ngx_socket_t fd; |
31 ngx_open_file_t *file; | 31 ngx_open_file_t *file; |
35 log = old_cycle->log; | 35 log = old_cycle->log; |
36 | 36 |
37 if (!(pool = ngx_create_pool(16 * 1024, log))) { | 37 if (!(pool = ngx_create_pool(16 * 1024, log))) { |
38 return NULL; | 38 return NULL; |
39 } | 39 } |
40 pool->log = log; | |
40 | 41 |
41 if (!(cycle = ngx_pcalloc(pool, sizeof(ngx_cycle_t)))) { | 42 if (!(cycle = ngx_pcalloc(pool, sizeof(ngx_cycle_t)))) { |
42 ngx_destroy_pool(pool); | 43 ngx_destroy_pool(pool); |
43 return NULL; | 44 return NULL; |
44 } | 45 } |
45 cycle->pool = pool; | 46 cycle->pool = pool; |
46 | |
47 pool->log = log; | |
48 cycle->log = log; | 47 cycle->log = log; |
49 | |
50 cycle->old_cycle = old_cycle; | 48 cycle->old_cycle = old_cycle; |
51 cycle->conf_file = old_cycle->conf_file; | 49 cycle->conf_file = old_cycle->conf_file; |
52 | 50 |
53 | 51 |
54 n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10; | 52 n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10; |
72 cycle->open_files.size = sizeof(ngx_open_file_t); | 70 cycle->open_files.size = sizeof(ngx_open_file_t); |
73 cycle->open_files.nalloc = n; | 71 cycle->open_files.nalloc = n; |
74 cycle->open_files.pool = pool; | 72 cycle->open_files.pool = pool; |
75 | 73 |
76 | 74 |
77 if (!(new_log = ngx_log_create_errlog(cycle, NULL))) { | 75 if (!(cycle->new_log = ngx_log_create_errlog(cycle, NULL))) { |
78 ngx_destroy_pool(pool); | 76 ngx_destroy_pool(pool); |
79 return NULL; | 77 return NULL; |
80 } | 78 } |
81 | 79 |
82 | 80 |
125 return NULL; | 123 return NULL; |
126 } | 124 } |
127 | 125 |
128 conf.ctx = cycle->conf_ctx; | 126 conf.ctx = cycle->conf_ctx; |
129 conf.cycle = cycle; | 127 conf.cycle = cycle; |
130 /* STUB */ conf.pool = cycle->pool; | 128 conf.pool = pool; |
131 conf.log = log; | 129 conf.log = log; |
132 conf.module_type = NGX_CORE_MODULE; | 130 conf.module_type = NGX_CORE_MODULE; |
133 conf.cmd_type = NGX_MAIN_CONF; | 131 conf.cmd_type = NGX_MAIN_CONF; |
134 | 132 |
135 cycle->log = new_log; | |
136 | 133 |
137 if (ngx_conf_parse(&conf, &cycle->conf_file) != NGX_CONF_OK) { | 134 if (ngx_conf_parse(&conf, &cycle->conf_file) != NGX_CONF_OK) { |
138 ngx_destroy_pool(pool); | 135 ngx_destroy_pool(pool); |
139 return NULL; | 136 return NULL; |
140 } | 137 } |
141 | 138 |
142 cycle->log = log; | |
143 | 139 |
144 for (i = 0; ngx_modules[i]; i++) { | 140 for (i = 0; ngx_modules[i]; i++) { |
145 if (ngx_modules[i]->type != NGX_CORE_MODULE) { | 141 if (ngx_modules[i]->type != NGX_CORE_MODULE) { |
146 continue; | 142 continue; |
147 } | 143 } |
206 } | 202 } |
207 #endif | 203 #endif |
208 } | 204 } |
209 } | 205 } |
210 | 206 |
211 cycle->log = new_log; | 207 cycle->log = cycle->new_log; |
212 pool->log = new_log; | 208 pool->log = cycle->new_log; |
213 | 209 |
214 if (!failed) { | 210 if (!failed) { |
215 if (old_cycle->listening.nelts) { | 211 if (old_cycle->listening.nelts) { |
216 ls = old_cycle->listening.elts; | 212 ls = old_cycle->listening.elts; |
217 for (i = 0; i < old_cycle->listening.nelts; i++) { | 213 for (i = 0; i < old_cycle->listening.nelts; i++) { |