comparison src/core/ngx_cycle.c @ 2945:87da6664fb49 stable-0.7

merge r2897, r2898, r2899, r2901, r2902, r2904, r2905, r2906, r2907, r2909, r2910, r2922, r2923, r2924, r2925, r2929: various win32 fixes: *) use no-threads for Unix builds only *) Win32 returns ERROR_PATH_NOT_FOUND instead of ERROR_FILE_NOT_FOUND *) add trailing zero to a file name in ngx_win32_rename_file() *) fix logging in ngx_win32_rename_file() *) allow shared memory segments more than 4G *) fix memory leak in successful case *) log shared memory name in failure case *) test that zone has the same addresses in different processes *) add drive letter for Win32 root path *) log GetExitCodeProcess()'s errno *) test premature process termination *) fix debug logging *) exit if no workers could not be started *) do not quit old workers if no new workers could not be started *) a signaller process should stop configuration processing just after it is able to get pid file, this allows to not open log files, etc. *) win32 master process had aready closed listening sockets
author Igor Sysoev <igor@sysoev.ru>
date Mon, 15 Jun 2009 09:48:15 +0000
parents 44b2081c015a
children 2efa8d2fcde1
comparison
equal deleted inserted replaced
2944:f892042956e3 2945:87da6664fb49
267 if (ngx_test_config) { 267 if (ngx_test_config) {
268 ngx_log_stderr(0, "the configuration file %s syntax is ok", 268 ngx_log_stderr(0, "the configuration file %s syntax is ok",
269 cycle->conf_file.data); 269 cycle->conf_file.data);
270 } 270 }
271 271
272
273 for (i = 0; ngx_modules[i]; i++) { 272 for (i = 0; ngx_modules[i]; i++) {
274 if (ngx_modules[i]->type != NGX_CORE_MODULE) { 273 if (ngx_modules[i]->type != NGX_CORE_MODULE) {
275 continue; 274 continue;
276 } 275 }
277 276
285 return NULL; 284 return NULL;
286 } 285 }
287 } 286 }
288 } 287 }
289 288
289 if (ngx_process == NGX_PROCESS_SIGNALLER) {
290 return cycle;
291 }
290 292
291 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); 293 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
292 294
293 if (ngx_test_config) { 295 if (ngx_test_config) {
294 296
461 463
462 if (ngx_shm_alloc(&shm_zone[i].shm) != NGX_OK) { 464 if (ngx_shm_alloc(&shm_zone[i].shm) != NGX_OK) {
463 goto failed; 465 goto failed;
464 } 466 }
465 467
466 if (!shm_zone[i].shm.exists) { 468 if (ngx_init_zone_pool(cycle, &shm_zone[i]) != NGX_OK) {
467 469 goto failed;
468 if (ngx_init_zone_pool(cycle, &shm_zone[i]) != NGX_OK) {
469 goto failed;
470 }
471 } 470 }
472 471
473 if (shm_zone[i].init(&shm_zone[i], NULL) != NGX_OK) { 472 if (shm_zone[i].init(&shm_zone[i], NULL) != NGX_OK) {
474 goto failed; 473 goto failed;
475 } 474 }
565 } 564 }
566 #endif 565 #endif
567 } 566 }
568 } 567 }
569 568
570 if (ngx_process != NGX_PROCESS_SIGNALLER) { 569 if (ngx_open_listening_sockets(cycle) != NGX_OK) {
571 if (ngx_open_listening_sockets(cycle) != NGX_OK) { 570 goto failed;
572 goto failed; 571 }
573 } 572
574 573 if (!ngx_test_config) {
575 if (!ngx_test_config) { 574 ngx_configure_listening_sockets(cycle);
576 ngx_configure_listening_sockets(cycle);
577 }
578 } 575 }
579 576
580 577
581 /* commit the new cycle configuration */ 578 /* commit the new cycle configuration */
582 579
654 651
655 /* close the unnecessary listening sockets */ 652 /* close the unnecessary listening sockets */
656 653
657 ls = old_cycle->listening.elts; 654 ls = old_cycle->listening.elts;
658 for (i = 0; i < old_cycle->listening.nelts; i++) { 655 for (i = 0; i < old_cycle->listening.nelts; i++) {
659 if (ls[i].remain) { 656
657 if (ls[i].remain || ls[i].fd == -1) {
660 continue; 658 continue;
661 } 659 }
662 660
663 if (ngx_close_socket(ls[i].fd) == -1) { 661 if (ngx_close_socket(ls[i].fd) == -1) {
664 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno, 662 ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
883 u_char *file; 881 u_char *file;
884 ngx_slab_pool_t *sp; 882 ngx_slab_pool_t *sp;
885 883
886 sp = (ngx_slab_pool_t *) zn->shm.addr; 884 sp = (ngx_slab_pool_t *) zn->shm.addr;
887 885
886 if (zn->shm.exists) {
887
888 if (sp == sp->addr) {
889 return NGX_OK;
890 }
891
892 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
893 "shared zone \"%V\" has no equal addresses: %p vs %p",
894 &zn->shm.name, sp->addr, sp);
895 return NGX_ERROR;
896 }
897
888 sp->end = zn->shm.addr + zn->shm.size; 898 sp->end = zn->shm.addr + zn->shm.size;
889 sp->min_shift = 3; 899 sp->min_shift = 3;
900 sp->addr = zn->shm.addr;
890 901
891 #if (NGX_HAVE_ATOMIC_OPS) 902 #if (NGX_HAVE_ATOMIC_OPS)
892 903
893 file = NULL; 904 file = NULL;
894 905