Mercurial > hg > nginx
comparison src/core/ngx_cycle.c @ 2758:77264e0157ad
-p and --prefix=
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 27 Apr 2009 11:32:33 +0000 |
parents | d8316f307b6a |
children | 4bd7825fab80 |
comparison
equal
deleted
inserted
replaced
2757:9cc973b46af1 | 2758:77264e0157ad |
---|---|
32 | 32 |
33 /* STUB NAME */ | 33 /* STUB NAME */ |
34 static ngx_connection_t dumb; | 34 static ngx_connection_t dumb; |
35 /* STUB */ | 35 /* STUB */ |
36 | 36 |
37 #ifdef NGX_ERROR_LOG_PATH | |
38 static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH); | 37 static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH); |
39 #else | |
40 static ngx_str_t error_log = ngx_null_string; | |
41 #endif | |
42 | 38 |
43 | 39 |
44 ngx_cycle_t * | 40 ngx_cycle_t * |
45 ngx_init_cycle(ngx_cycle_t *old_cycle) | 41 ngx_init_cycle(ngx_cycle_t *old_cycle) |
46 { | 42 { |
85 } | 81 } |
86 | 82 |
87 cycle->pool = pool; | 83 cycle->pool = pool; |
88 cycle->log = log; | 84 cycle->log = log; |
89 cycle->old_cycle = old_cycle; | 85 cycle->old_cycle = old_cycle; |
90 cycle->root.len = sizeof(NGX_PREFIX) - 1; | 86 |
91 cycle->root.data = (u_char *) NGX_PREFIX; | 87 cycle->conf_prefix.len = old_cycle->conf_prefix.len; |
92 | 88 cycle->conf_prefix.data = ngx_pstrdup(pool, &old_cycle->conf_prefix); |
89 if (cycle->conf_prefix.data == NULL) { | |
90 ngx_destroy_pool(pool); | |
91 return NULL; | |
92 } | |
93 | |
94 cycle->prefix.len = old_cycle->prefix.len; | |
95 cycle->prefix.data = ngx_pstrdup(pool, &old_cycle->prefix); | |
96 if (cycle->prefix.data == NULL) { | |
97 ngx_destroy_pool(pool); | |
98 return NULL; | |
99 } | |
93 | 100 |
94 cycle->conf_file.len = old_cycle->conf_file.len; | 101 cycle->conf_file.len = old_cycle->conf_file.len; |
95 cycle->conf_file.data = ngx_pnalloc(pool, old_cycle->conf_file.len + 1); | 102 cycle->conf_file.data = ngx_pnalloc(pool, old_cycle->conf_file.len + 1); |
96 if (cycle->conf_file.data == NULL) { | 103 if (cycle->conf_file.data == NULL) { |
97 ngx_destroy_pool(pool); | 104 ngx_destroy_pool(pool); |
98 return NULL; | 105 return NULL; |
99 } | 106 } |
100 ngx_cpystrn(cycle->conf_file.data, old_cycle->conf_file.data, | 107 ngx_cpystrn(cycle->conf_file.data, old_cycle->conf_file.data, |
101 old_cycle->conf_file.len + 1); | 108 old_cycle->conf_file.len + 1); |
102 | 109 |
103 | |
104 cycle->conf_param.len = old_cycle->conf_param.len; | 110 cycle->conf_param.len = old_cycle->conf_param.len; |
105 cycle->conf_param.data = ngx_pnalloc(pool, old_cycle->conf_param.len); | 111 cycle->conf_param.data = ngx_pstrdup(pool, &old_cycle->conf_param); |
106 if (cycle->conf_param.data == NULL) { | 112 if (cycle->conf_param.data == NULL) { |
107 ngx_destroy_pool(pool); | 113 ngx_destroy_pool(pool); |
108 return NULL; | 114 return NULL; |
109 } | 115 } |
110 ngx_memcpy(cycle->conf_param.data, old_cycle->conf_param.data, | |
111 old_cycle->conf_param.len); | |
112 | 116 |
113 | 117 |
114 n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10; | 118 n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10; |
115 | 119 |
116 cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *)); | 120 cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *)); |
160 ngx_destroy_pool(pool); | 164 ngx_destroy_pool(pool); |
161 return NULL; | 165 return NULL; |
162 } | 166 } |
163 | 167 |
164 | 168 |
165 cycle->new_log = ngx_log_create_errlog(cycle, NULL); | 169 cycle->new_log = ngx_log_create_errlog(cycle, &error_log); |
166 if (cycle->new_log == NULL) { | 170 if (cycle->new_log == NULL) { |
167 ngx_destroy_pool(pool); | 171 ngx_destroy_pool(pool); |
168 return NULL; | 172 return NULL; |
169 } | 173 } |
170 | |
171 cycle->new_log->file->name = error_log; | |
172 | 174 |
173 | 175 |
174 n = old_cycle->listening.nelts ? old_cycle->listening.nelts : 10; | 176 n = old_cycle->listening.nelts ? old_cycle->listening.nelts : 10; |
175 | 177 |
176 cycle->listening.elts = ngx_pcalloc(pool, n * sizeof(ngx_listening_t)); | 178 cycle->listening.elts = ngx_pcalloc(pool, n * sizeof(ngx_listening_t)); |
348 part = part->next; | 350 part = part->next; |
349 file = part->elts; | 351 file = part->elts; |
350 i = 0; | 352 i = 0; |
351 } | 353 } |
352 | 354 |
353 if (file[i].name.data == NULL) { | 355 if (file[i].name.len == 0) { |
354 continue; | 356 continue; |
355 } | 357 } |
356 | 358 |
357 file[i].fd = ngx_open_file(file[i].name.data, | 359 file[i].fd = ngx_open_file(file[i].name.data, |
358 NGX_FILE_APPEND, | 360 NGX_FILE_APPEND, |
1081 part = part->next; | 1083 part = part->next; |
1082 file = part->elts; | 1084 file = part->elts; |
1083 i = 0; | 1085 i = 0; |
1084 } | 1086 } |
1085 | 1087 |
1086 if (file[i].name.data == NULL) { | 1088 if (file[i].name.len == 0) { |
1087 continue; | 1089 continue; |
1088 } | 1090 } |
1089 | 1091 |
1090 len = file[i].pos - file[i].buffer; | 1092 len = file[i].pos - file[i].buffer; |
1091 | 1093 |