comparison src/core/nginx.c @ 231:92db0aa1e83f

nginx-0.0.1-2004-01-16-21:29:15 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 16 Jan 2004 18:29:15 +0000
parents 2ba3477070ac
children cd71b95716b4
comparison
equal deleted inserted replaced
230:1119faf4635a 231:92db0aa1e83f
20 char *const *argv; 20 char *const *argv;
21 } ngx_master_ctx_t; 21 } ngx_master_ctx_t;
22 22
23 23
24 static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx); 24 static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx);
25 static void ngx_master_exit(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx);
25 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data); 26 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
26 static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle, char **envp); 27 static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle, char **envp);
27 static ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv); 28 static ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv);
28 static ngx_int_t ngx_core_module_init(ngx_cycle_t *cycle); 29 static ngx_int_t ngx_core_module_init(ngx_cycle_t *cycle);
29 30
264 265
265 ngx_signal = 0; 266 ngx_signal = 0;
266 ngx_new_binary = 0; 267 ngx_new_binary = 0;
267 signo = 0; 268 signo = 0;
268 sent = 0; 269 sent = 0;
270 live = 0;
269 271
270 for ( ;; ) { 272 for ( ;; ) {
271 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "new cycle"); 273 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "new cycle");
272 274
273 if (ngx_process == NGX_PROCESS_MASTER) { 275 if (ngx_process == NGX_PROCESS_MASTER) {
274 ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL, 276 ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL,
275 "worker process", NGX_PROCESS_RESPAWN); 277 "worker process", NGX_PROCESS_RESPAWN);
278 live = 1;
276 279
277 } else { 280 } else {
278 ngx_init_temp_number(); 281 ngx_init_temp_number();
279 282
280 for (i = 0; ngx_modules[i]; i++) { 283 for (i = 0; ngx_modules[i]; i++) {
412 live = 1; 415 live = 1;
413 } 416 }
414 } 417 }
415 418
416 if (!live) { 419 if (!live) {
417 if (ngx_terminate || ngx_quit) { 420 sent = 0;
418 421 }
419 if (ngx_inherited && getppid() > 1) { 422 }
420 name = ctx->pid.name.data; 423
421 424 if (!live && (ngx_terminate || ngx_quit)) {
422 } else { 425 ngx_master_exit(cycle, ctx);
423 name = ctx->name;
424 }
425
426 if (ngx_delete_file(name) == NGX_FILE_ERROR) {
427 ngx_log_error(NGX_LOG_ALERT, cycle->log,
428 ngx_errno,
429 ngx_delete_file_n
430 " \"%s\" failed", name);
431 }
432
433 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exit");
434 exit(0);
435
436 } else {
437 sent = 0;
438 }
439 }
440 } 426 }
441 427
442 if (ngx_terminate) { 428 if (ngx_terminate) {
443 if (delay > 10000) { 429 if (delay > 10000) {
444 signo = SIGKILL; 430 signo = SIGKILL;
528 ngx_reap = 0; 514 ngx_reap = 0;
529 } 515 }
530 516
531 /* STUB */ 517 /* STUB */
532 if (ngx_reopen) { 518 if (ngx_reopen) {
533 ngx_reopen = 0;
534 break; 519 break;
535 } 520 }
536 521
537 if (ngx_reconfigure) { 522 if (ngx_reconfigure) {
538 break; 523 break;
539 } 524 }
540 } 525 }
541 526
542 if (ngx_noaccept) { 527 if (ngx_reopen) {
528 ngx_reopen = 0;
529
530 } else if (ngx_noaccept) {
543 ngx_noaccept = 0; 531 ngx_noaccept = 0;
544 532
545 } else { 533 } else {
546 cycle = ngx_init_cycle(cycle); 534 cycle = ngx_init_cycle(cycle);
547 if (cycle == NULL) { 535 if (cycle == NULL) {
554 542
555 ngx_reconfigure = 0; 543 ngx_reconfigure = 0;
556 break; 544 break;
557 } 545 }
558 } 546 }
547 }
548
549
550 static void ngx_master_exit(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
551 {
552 char *name;
553
554 if (ngx_inherited && getppid() > 1) {
555 name = ctx->pid.name.data;
556
557 } else {
558 name = ctx->name;
559 }
560
561 if (ngx_delete_file(name) == NGX_FILE_ERROR) {
562 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
563 ngx_delete_file_n " \"%s\" failed", name);
564 }
565
566 ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exit");
567 exit(0);
559 } 568 }
560 569
561 570
562 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) 571 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
563 { 572 {