Mercurial > hg > nginx-quic
comparison src/core/nginx.c @ 119:cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 20 Jul 2003 21:15:59 +0000 |
parents | 5bf52498665c |
children | ef8c87afcfc5 |
comparison
equal
deleted
inserted
replaced
118:5bf52498665c | 119:cd54bcbaf3b5 |
---|---|
64 | 64 |
65 | 65 |
66 int main(int argc, char *const *argv) | 66 int main(int argc, char *const *argv) |
67 { | 67 { |
68 int i; | 68 int i; |
69 ngx_fd_t fd; | |
69 ngx_log_t *log; | 70 ngx_log_t *log; |
70 ngx_cycle_t *cycle; | 71 ngx_cycle_t *cycle; |
72 ngx_open_file_t *file; | |
71 ngx_core_conf_t *ccf; | 73 ngx_core_conf_t *ccf; |
72 | 74 |
73 #if (NGX_DEBUG) && (__FreeBSD__) | 75 #if (NGX_DEBUG) && (__FreeBSD__) |
74 #if __FreeBSD_version >= 500014 | 76 #if __FreeBSD_version >= 500014 |
75 _malloc_options | 77 _malloc_options |
148 | 150 |
149 ngx_process_events(ngx_cycle->log); | 151 ngx_process_events(ngx_cycle->log); |
150 | 152 |
151 if (rotate) { | 153 if (rotate) { |
152 ngx_log_debug(ngx_cycle->log, "rotate"); | 154 ngx_log_debug(ngx_cycle->log, "rotate"); |
155 | |
156 file = cycle->open_files.elts; | |
157 for (i = 0; i < cycle->open_files.nelts; i++) { | |
158 if (file[i].name.data == NULL) { | |
159 continue; | |
160 } | |
161 | |
162 fd = ngx_open_file(file[i].name.data, | |
163 NGX_FILE_RDWR, | |
164 NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND); | |
165 | |
166 ngx_log_debug(log, "REOPEN: %d:%d:%s" _ fd _ file[i].fd _ file[i].name.data); | |
167 | |
168 if (fd == NGX_INVALID_FILE) { | |
169 ngx_log_error(NGX_LOG_EMERG, | |
170 ngx_cycle->log, ngx_errno, | |
171 ngx_open_file_n " \"%s\" failed", | |
172 file[i].name.data); | |
173 continue; | |
174 } | |
175 | |
176 #if (WIN32) | |
177 if (ngx_file_append_mode(fd) == NGX_ERROR) { | |
178 ngx_log_error(NGX_LOG_EMERG, | |
179 ngx_cycle->log, ngx_errno, | |
180 ngx_file_append_mode_n | |
181 " \"%s\" failed", | |
182 file[i].name.data); | |
183 | |
184 if (ngx_close_file(fd) == NGX_FILE_ERROR) { | |
185 ngx_log_error(NGX_LOG_EMERG, | |
186 ngx_cycle->log, ngx_errno, | |
187 ngx_close_file_n " \"%s\" failed", | |
188 file[i].name.data); | |
189 } | |
190 | |
191 continue; | |
192 } | |
193 #endif | |
194 | |
195 if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) { | |
196 ngx_log_error(NGX_LOG_EMERG, | |
197 ngx_cycle->log, ngx_errno, | |
198 ngx_close_file_n " \"%s\" failed", | |
199 file[i].name.data); | |
200 } | |
201 | |
202 file[i].fd = fd; | |
203 } | |
153 } | 204 } |
154 | 205 |
155 if (restart) { | 206 if (restart) { |
156 ngx_log_debug(ngx_cycle->log, "restart"); | 207 ngx_log_debug(ngx_cycle->log, "restart"); |
157 break; | 208 break; |
273 | 324 |
274 failed = 0; | 325 failed = 0; |
275 | 326 |
276 file = cycle->open_files.elts; | 327 file = cycle->open_files.elts; |
277 for (i = 0; i < cycle->open_files.nelts; i++) { | 328 for (i = 0; i < cycle->open_files.nelts; i++) { |
278 if (file->name.data == NULL) { | 329 if (file[i].name.data == NULL) { |
279 continue; | 330 continue; |
280 } | 331 } |
281 | 332 |
282 file->fd = ngx_open_file(file->name.data, | 333 file[i].fd = ngx_open_file(file[i].name.data, |
283 NGX_FILE_RDWR, | 334 NGX_FILE_RDWR, |
284 NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND); | 335 NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND); |
285 | 336 |
286 ngx_log_debug(log, "OPEN: %d:%s" _ file->fd _ file->name.data); | 337 ngx_log_debug(log, "OPEN: %d:%s" _ file[i].fd _ file[i].name.data); |
287 | 338 |
288 if (file->fd == NGX_INVALID_FILE) { | 339 if (file[i].fd == NGX_INVALID_FILE) { |
289 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | 340 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, |
290 ngx_open_file_n " \"%s\" failed", | 341 ngx_open_file_n " \"%s\" failed", |
291 file->name.data); | 342 file[i].name.data); |
292 failed = 1; | 343 failed = 1; |
293 break; | 344 break; |
294 } | 345 } |
295 | 346 |
296 /* TODO: Win32 append */ | 347 #if (WIN32) |
348 if (ngx_file_append_mode(file[i].fd) == NGX_ERROR) { | |
349 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | |
350 ngx_file_append_mode_n " \"%s\" failed", | |
351 file[i].name.data); | |
352 failed = 1; | |
353 break; | |
354 } | |
355 #endif | |
297 } | 356 } |
298 | 357 |
299 /* STUB */ cycle->log->log_level = NGX_LOG_DEBUG; | 358 /* STUB */ cycle->log->log_level = NGX_LOG_DEBUG; |
300 | 359 |
301 if (!failed) { | 360 if (!failed) { |
339 | 398 |
340 /* rollback the new cycle configuration */ | 399 /* rollback the new cycle configuration */ |
341 | 400 |
342 file = cycle->open_files.elts; | 401 file = cycle->open_files.elts; |
343 for (i = 0; i < cycle->open_files.nelts; i++) { | 402 for (i = 0; i < cycle->open_files.nelts; i++) { |
344 if (file->fd == NGX_INVALID_FILE) { | 403 if (file[i].fd == NGX_INVALID_FILE) { |
345 continue; | 404 continue; |
346 } | 405 } |
347 | 406 |
348 if (ngx_close_file(file->fd) == NGX_FILE_ERROR) { | 407 if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) { |
349 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | 408 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, |
350 ngx_close_file_n " \"%s\" failed", | 409 ngx_close_file_n " \"%s\" failed", |
351 file->name.data); | 410 file[i].name.data); |
352 } | 411 } |
353 } | 412 } |
354 | 413 |
355 ls = cycle->listening.elts; | 414 ls = cycle->listening.elts; |
356 for (i = 0; i < cycle->listening.nelts; i++) { | 415 for (i = 0; i < cycle->listening.nelts; i++) { |
403 } | 462 } |
404 } | 463 } |
405 | 464 |
406 file = old_cycle->open_files.elts; | 465 file = old_cycle->open_files.elts; |
407 for (i = 0; i < old_cycle->open_files.nelts; i++) { | 466 for (i = 0; i < old_cycle->open_files.nelts; i++) { |
408 if (file->fd == NGX_INVALID_FILE) { | 467 if (file[i].fd == NGX_INVALID_FILE) { |
409 continue; | 468 continue; |
410 } | 469 } |
411 | 470 |
412 if (ngx_close_file(file->fd) == NGX_FILE_ERROR) { | 471 if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) { |
413 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, | 472 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, |
414 ngx_close_file_n " \"%s\" failed", | 473 ngx_close_file_n " \"%s\" failed", |
415 file->name.data); | 474 file[i].name.data); |
416 } | 475 } |
417 } | 476 } |
418 | 477 |
419 | 478 |
420 if (!old_cycle->one_process) { | 479 if (!old_cycle->one_process) { |