Mercurial > hg > nginx-quic
comparison src/event/ngx_event.c @ 1704:e584e946e198
move condition declarations inside blocks where they are used
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 10 Dec 2007 12:09:51 +0000 |
parents | b590a528fd41 |
children | 7018254cc006 |
comparison
equal
deleted
inserted
replaced
1703:43747661804d | 1704:e584e946e198 |
---|---|
426 ngx_event_module_init(ngx_cycle_t *cycle) | 426 ngx_event_module_init(ngx_cycle_t *cycle) |
427 { | 427 { |
428 void ***cf; | 428 void ***cf; |
429 u_char *shared; | 429 u_char *shared; |
430 size_t size, cl; | 430 size_t size, cl; |
431 ngx_shm_t shm; | |
432 ngx_core_conf_t *ccf; | |
431 ngx_event_conf_t *ecf; | 433 ngx_event_conf_t *ecf; |
432 ngx_core_conf_t *ccf; | |
433 ngx_shm_t shm; | |
434 #if !(NGX_WIN32) | |
435 ngx_int_t limit; | |
436 struct rlimit rlmt; | |
437 #endif | |
438 | 434 |
439 cf = ngx_get_conf(cycle->conf_ctx, ngx_events_module); | 435 cf = ngx_get_conf(cycle->conf_ctx, ngx_events_module); |
440 | 436 |
441 if (cf == NULL) { | 437 if (cf == NULL) { |
442 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, | 438 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, |
454 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); | 450 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
455 | 451 |
456 ngx_timer_resolution = ccf->timer_resolution; | 452 ngx_timer_resolution = ccf->timer_resolution; |
457 | 453 |
458 #if !(NGX_WIN32) | 454 #if !(NGX_WIN32) |
455 { | |
456 ngx_int_t limit; | |
457 struct rlimit rlmt; | |
459 | 458 |
460 if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) { | 459 if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) { |
461 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | 460 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
462 "getrlimit(RLIMIT_NOFILE) failed, ignored"); | 461 "getrlimit(RLIMIT_NOFILE) failed, ignored"); |
463 | 462 |
473 "%ui worker_connections are more than " | 472 "%ui worker_connections are more than " |
474 "open file resource limit: %i", | 473 "open file resource limit: %i", |
475 ecf->connections, limit); | 474 ecf->connections, limit); |
476 } | 475 } |
477 } | 476 } |
478 | 477 } |
479 #endif /* !(NGX_WIN32) */ | 478 #endif /* !(NGX_WIN32) */ |
480 | 479 |
481 | 480 |
482 if (ccf->master == 0) { | 481 if (ccf->master == 0) { |
483 return NGX_OK; | 482 return NGX_OK; |
571 ngx_listening_t *ls; | 570 ngx_listening_t *ls; |
572 ngx_connection_t *c, *next, *old; | 571 ngx_connection_t *c, *next, *old; |
573 ngx_core_conf_t *ccf; | 572 ngx_core_conf_t *ccf; |
574 ngx_event_conf_t *ecf; | 573 ngx_event_conf_t *ecf; |
575 ngx_event_module_t *module; | 574 ngx_event_module_t *module; |
576 #if (NGX_WIN32) | |
577 ngx_iocp_conf_t *iocpcf; | |
578 #else | |
579 struct rlimit rlmt; | |
580 struct sigaction sa; | |
581 struct itimerval itv; | |
582 #endif | |
583 | 575 |
584 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); | 576 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
585 ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module); | 577 ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module); |
586 | 578 |
587 if (ccf->master && ccf->worker_processes > 1 && ecf->accept_mutex) { | 579 if (ccf->master && ccf->worker_processes > 1 && ecf->accept_mutex) { |
623 } | 615 } |
624 | 616 |
625 #if !(NGX_WIN32) | 617 #if !(NGX_WIN32) |
626 | 618 |
627 if (ngx_timer_resolution && !(ngx_event_flags & NGX_USE_TIMER_EVENT)) { | 619 if (ngx_timer_resolution && !(ngx_event_flags & NGX_USE_TIMER_EVENT)) { |
620 struct sigaction sa; | |
621 struct itimerval itv; | |
628 | 622 |
629 ngx_memzero(&sa, sizeof(struct sigaction)); | 623 ngx_memzero(&sa, sizeof(struct sigaction)); |
630 sa.sa_handler = ngx_timer_signal_handler; | 624 sa.sa_handler = ngx_timer_signal_handler; |
631 sigemptyset(&sa.sa_mask); | 625 sigemptyset(&sa.sa_mask); |
632 | 626 |
646 "setitimer() failed"); | 640 "setitimer() failed"); |
647 } | 641 } |
648 } | 642 } |
649 | 643 |
650 if (ngx_event_flags & NGX_USE_FD_EVENT) { | 644 if (ngx_event_flags & NGX_USE_FD_EVENT) { |
645 struct rlimit rlmt; | |
651 | 646 |
652 if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) { | 647 if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) { |
653 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | 648 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, |
654 "getrlimit(RLIMIT_NOFILE) failed"); | 649 "getrlimit(RLIMIT_NOFILE) failed"); |
655 return NGX_ERROR; | 650 return NGX_ERROR; |
772 } | 767 } |
773 | 768 |
774 #if (NGX_WIN32) | 769 #if (NGX_WIN32) |
775 | 770 |
776 if (ngx_event_flags & NGX_USE_IOCP_EVENT) { | 771 if (ngx_event_flags & NGX_USE_IOCP_EVENT) { |
772 ngx_iocp_conf_t *iocpcf; | |
773 | |
777 rev->handler = ngx_event_acceptex; | 774 rev->handler = ngx_event_acceptex; |
778 | 775 |
779 if (ngx_add_event(rev, 0, NGX_IOCP_ACCEPT) == NGX_ERROR) { | 776 if (ngx_add_event(rev, 0, NGX_IOCP_ACCEPT) == NGX_ERROR) { |
780 return NGX_ERROR; | 777 return NGX_ERROR; |
781 } | 778 } |