Mercurial > hg > nginx-quic
comparison src/core/nginx.c @ 207:6e0fef527732
nginx-0.0.1-2003-12-05-20:07:27 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 05 Dec 2003 17:07:27 +0000 |
parents | 267ea1d98683 |
children | e1c815be05ae |
comparison
equal
deleted
inserted
replaced
206:9aa426375256 | 207:6e0fef527732 |
---|---|
11 | 11 |
12 | 12 |
13 static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log); | 13 static ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle, ngx_log_t *log); |
14 static int ngx_open_listening_sockets(ngx_cycle_t *cycle, ngx_log_t *log); | 14 static int ngx_open_listening_sockets(ngx_cycle_t *cycle, ngx_log_t *log); |
15 static void ngx_clean_old_cycles(ngx_event_t *ev); | 15 static void ngx_clean_old_cycles(ngx_event_t *ev); |
16 | |
17 | |
18 #if (NGX_DEBUG) && (__FreeBSD__) | |
19 extern char *malloc_options; | |
20 #endif | |
21 | 16 |
22 | 17 |
23 typedef struct { | 18 typedef struct { |
24 int daemon; | 19 int daemon; |
25 } ngx_core_conf_t; | 20 } ngx_core_conf_t; |
79 ngx_open_file_t *file; | 74 ngx_open_file_t *file; |
80 #if !(WIN32) | 75 #if !(WIN32) |
81 ngx_core_conf_t *ccf; | 76 ngx_core_conf_t *ccf; |
82 #endif | 77 #endif |
83 | 78 |
84 #if (NGX_DEBUG) && (__FreeBSD__) | 79 #if __FreeBSD__ |
85 #if __FreeBSD_version >= 500014 | 80 ngx_debug_init(); |
86 _malloc_options | |
87 #else | |
88 malloc_options | |
89 #endif | |
90 = "J"; | |
91 #endif | 81 #endif |
92 | 82 |
93 /* TODO */ ngx_max_sockets = -1; | 83 /* TODO */ ngx_max_sockets = -1; |
94 | 84 |
95 ngx_time_init(); | 85 ngx_time_init(); |
132 #endif | 122 #endif |
133 | 123 |
134 /* life cycle */ | 124 /* life cycle */ |
135 | 125 |
136 for ( ;; ) { | 126 for ( ;; ) { |
127 #if 0 | |
137 /* STUB */ cycle->log->log_level = NGX_LOG_DEBUG|NGX_LOG_DEBUG_HTTP; | 128 /* STUB */ cycle->log->log_level = NGX_LOG_DEBUG|NGX_LOG_DEBUG_HTTP; |
129 #endif | |
138 | 130 |
139 #if 0 | 131 #if 0 |
140 | 132 |
141 #if !(WIN32) | 133 #if !(WIN32) |
142 ngx_spawn_process(cycle->log); | 134 ngx_spawn_process(cycle->log); |
253 ngx_core_conf_t *ccf; | 245 ngx_core_conf_t *ccf; |
254 ngx_open_file_t *file; | 246 ngx_open_file_t *file; |
255 ngx_listening_t *ls, *nls; | 247 ngx_listening_t *ls, *nls; |
256 | 248 |
257 | 249 |
258 pool = ngx_create_pool(16 * 1024, log); | 250 if (!(pool = ngx_create_pool(16 * 1024, log))) { |
259 if (pool == NULL) { | 251 return NULL; |
260 return NULL; | 252 } |
261 } | 253 |
262 | 254 if (!(cycle = ngx_pcalloc(pool, sizeof(ngx_cycle_t)))) { |
263 cycle = ngx_pcalloc(pool, sizeof(ngx_cycle_t)); | |
264 if (cycle == NULL) { | |
265 ngx_destroy_pool(pool); | 255 ngx_destroy_pool(pool); |
266 return NULL; | 256 return NULL; |
267 } | 257 } |
268 cycle->pool = pool; | 258 cycle->pool = pool; |
269 | 259 |
270 cycle->old_cycle = old_cycle; | 260 cycle->old_cycle = old_cycle; |
271 | 261 |
272 | 262 |
273 n = old_cycle ? old_cycle->pathes.nelts : 10; | 263 n = old_cycle ? old_cycle->pathes.nelts : 10; |
274 cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *)); | 264 if (!(cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *)))) { |
275 if (cycle->pathes.elts == NULL) { | |
276 ngx_destroy_pool(pool); | 265 ngx_destroy_pool(pool); |
277 return NULL; | 266 return NULL; |
278 } | 267 } |
279 cycle->pathes.nelts = 0; | 268 cycle->pathes.nelts = 0; |
280 cycle->pathes.size = sizeof(ngx_path_t *); | 269 cycle->pathes.size = sizeof(ngx_path_t *); |
292 cycle->open_files.size = sizeof(ngx_open_file_t); | 281 cycle->open_files.size = sizeof(ngx_open_file_t); |
293 cycle->open_files.nalloc = n; | 282 cycle->open_files.nalloc = n; |
294 cycle->open_files.pool = pool; | 283 cycle->open_files.pool = pool; |
295 | 284 |
296 | 285 |
297 cycle->log = ngx_log_create_errlog(cycle, NULL); | 286 if (!(cycle->log = ngx_log_create_errlog(cycle, NULL))) { |
298 if (cycle->log == NULL) { | |
299 ngx_destroy_pool(pool); | 287 ngx_destroy_pool(pool); |
300 return NULL; | 288 return NULL; |
301 } | 289 } |
302 | 290 |
303 | 291 |
318 ngx_destroy_pool(pool); | 306 ngx_destroy_pool(pool); |
319 return NULL; | 307 return NULL; |
320 } | 308 } |
321 | 309 |
322 | 310 |
323 ccf = ngx_pcalloc(pool, sizeof(ngx_core_conf_t)); | 311 if (!(ccf = ngx_pcalloc(pool, sizeof(ngx_core_conf_t)))) { |
324 if (ccf == NULL) { | |
325 ngx_destroy_pool(pool); | 312 ngx_destroy_pool(pool); |
326 return NULL; | 313 return NULL; |
327 } | 314 } |
328 ccf->daemon = -1; | 315 ccf->daemon = -1; |
329 ((void **)(cycle->conf_ctx))[ngx_core_module.index] = ccf; | 316 ((void **)(cycle->conf_ctx))[ngx_core_module.index] = ccf; |
384 break; | 371 break; |
385 } | 372 } |
386 #endif | 373 #endif |
387 } | 374 } |
388 | 375 |
376 #if 0 | |
389 /* STUB */ cycle->log->log_level = NGX_LOG_DEBUG; | 377 /* STUB */ cycle->log->log_level = NGX_LOG_DEBUG; |
378 #endif | |
390 | 379 |
391 if (!failed) { | 380 if (!failed) { |
392 if (old_cycle) { | 381 if (old_cycle) { |
393 ls = old_cycle->listening.elts; | 382 ls = old_cycle->listening.elts; |
394 for (i = 0; i < old_cycle->listening.nelts; i++) { | 383 for (i = 0; i < old_cycle->listening.nelts; i++) { |