comparison src/core/ngx_cycle.c @ 336:ca9a7f8c86da

nginx-0.0.3-2004-05-18-19:29:08 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 18 May 2004 15:29:08 +0000
parents be40e9893a19
children 4feff829a849
comparison
equal deleted inserted replaced
335:d4241d7787fe 336:ca9a7f8c86da
22 22
23 23
24 ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle) 24 ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
25 { 25 {
26 void *rv; 26 void *rv;
27 u_char *root;
27 ngx_uint_t i, n, failed; 28 ngx_uint_t i, n, failed;
28 ngx_log_t *log; 29 ngx_log_t *log;
29 ngx_conf_t conf; 30 ngx_conf_t conf;
30 ngx_pool_t *pool; 31 ngx_pool_t *pool;
31 ngx_cycle_t *cycle, **old; 32 ngx_cycle_t *cycle, **old;
32 ngx_socket_t fd; 33 ngx_socket_t fd;
33 ngx_open_file_t *file; 34 ngx_open_file_t *file;
34 ngx_listening_t *ls, *nls; 35 ngx_listening_t *ls, *nls;
35 ngx_core_module_t *module; 36 ngx_core_module_t *module;
37 char cwd[NGX_MAX_PATH + 1];
36 38
37 log = old_cycle->log; 39 log = old_cycle->log;
38 40
39 if (!(pool = ngx_create_pool(16 * 1024, log))) { 41 if (!(pool = ngx_create_pool(16 * 1024, log))) {
40 return NULL; 42 return NULL;
47 } 49 }
48 cycle->pool = pool; 50 cycle->pool = pool;
49 cycle->log = log; 51 cycle->log = log;
50 cycle->old_cycle = old_cycle; 52 cycle->old_cycle = old_cycle;
51 cycle->conf_file = old_cycle->conf_file; 53 cycle->conf_file = old_cycle->conf_file;
54
55
56 for (i = cycle->conf_file.len; i > 0; i--) {
57 if (cycle->conf_file.data[i] == '/') {
58 break;
59 }
60 }
61
62 if (i == 0 && cycle->conf_file.data[i] != '/') {
63 if (ngx_getcwd(cwd, NGX_MAX_PATH) == 0) {
64 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
65 ngx_getcwd_n " failed");
66 ngx_destroy_pool(pool);
67 return NULL;
68 }
69
70 for ( /* void */; i < NGX_MAX_PATH && cwd[i]; i++) /* void */;
71 cwd[i] = '/';
72 cwd[i + 1] = '\0';
73
74 root = (u_char *) cwd;
75
76 } else {
77 root = cycle->conf_file.data;
78 }
79
80 cycle->root.len = ++i;
81 cycle->root.data = ngx_palloc(pool, ++i);
82 if (cycle->root.data == NULL) {
83 ngx_destroy_pool(pool);
84 return NULL;
85 }
86
87 ngx_cpystrn(cycle->root.data, root, i);
88
89 ngx_log_error(NGX_LOG_INFO, log, 0, "root: %s", cycle->root.data);
52 90
53 91
54 n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10; 92 n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10;
55 if (!(cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *)))) { 93 if (!(cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *)))) {
56 ngx_destroy_pool(pool); 94 ngx_destroy_pool(pool);