Mercurial > hg > nginx-vendor-1-0
comparison src/event/ngx_event.c @ 50:72eb30262aac NGINX_0_1_25
nginx 0.1.25
*) Bugfix: nginx did run on Linux parisc.
*) Feature: nginx now does not start under FreeBSD if the sysctl
kern.ipc.somaxconn value is too big.
*) Bugfix: if a request was internally redirected by the
ngx_http_index_module module to the ngx_http_proxy_module or
ngx_http_fastcgi_module modules, then the index file was not closed
after request completion.
*) Feature: the "proxy_pass" can be used in location with regular
expression.
*) Feature: the ngx_http_rewrite_filter_module module supports the
condition like "if ($HTTP_USER_AGENT ~ MSIE)".
*) Bugfix: nginx started too slow if the large number of addresses and
text values were used in the "geo" directive.
*) Change: a variable name must be declared as "$name" in the "geo"
directive. The previous variant without "$" is still supported, but
will be removed soon.
*) Feature: the "%{VARIABLE}v" logging parameter.
*) Feature: the "set $name value" directive.
*) Bugfix: gcc 4.0 compatibility.
*) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Sat, 19 Mar 2005 00:00:00 +0300 |
parents | 6cfc63e68377 |
children | 0d75d65c642f |
comparison
equal
deleted
inserted
replaced
49:93dabbc9efb9 | 50:72eb30262aac |
---|---|
217 + 128 /* ngx_stat_reading */ | 217 + 128 /* ngx_stat_reading */ |
218 + 128; /* ngx_stat_writing */ | 218 + 128; /* ngx_stat_writing */ |
219 | 219 |
220 #endif | 220 #endif |
221 | 221 |
222 if (!(shared = ngx_create_shared_memory(size, cycle->log))) { | 222 shared = ngx_create_shared_memory(size, cycle->log); |
223 if (shared == NULL) { | |
223 return NGX_ERROR; | 224 return NGX_ERROR; |
224 } | 225 } |
225 | 226 |
226 ngx_accept_mutex_ptr = (ngx_atomic_t *) shared; | 227 ngx_accept_mutex_ptr = (ngx_atomic_t *) shared; |
227 ngx_connection_counter = (ngx_atomic_t *) (shared + 128); | 228 ngx_connection_counter = (ngx_atomic_t *) (shared + 128); |
270 ngx_accept_mutex_held = 0; | 271 ngx_accept_mutex_held = 0; |
271 ngx_accept_mutex_delay = ecf->accept_mutex_delay; | 272 ngx_accept_mutex_delay = ecf->accept_mutex_delay; |
272 } | 273 } |
273 | 274 |
274 #if (NGX_THREADS) | 275 #if (NGX_THREADS) |
275 if (!(ngx_posted_events_mutex = ngx_mutex_init(cycle->log, 0))) { | 276 ngx_posted_events_mutex = ngx_mutex_init(cycle->log, 0); |
277 if (ngx_posted_events_mutex == NULL) { | |
276 return NGX_ERROR; | 278 return NGX_ERROR; |
277 } | 279 } |
278 #endif | 280 #endif |
279 | 281 |
280 if (ngx_event_timer_init(cycle->log) == NGX_ERROR) { | 282 if (ngx_event_timer_init(cycle->log) == NGX_ERROR) { |
495 } | 497 } |
496 | 498 |
497 | 499 |
498 static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 500 static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
499 { | 501 { |
500 int m; | 502 char *rv; |
501 char *rv; | |
502 void ***ctx; | 503 void ***ctx; |
504 ngx_uint_t i; | |
503 ngx_conf_t pcf; | 505 ngx_conf_t pcf; |
504 ngx_event_module_t *module; | 506 ngx_event_module_t *m; |
505 | 507 |
506 /* count the number of the event modules and set up their indices */ | 508 /* count the number of the event modules and set up their indices */ |
507 | 509 |
508 ngx_event_max_module = 0; | 510 ngx_event_max_module = 0; |
509 for (m = 0; ngx_modules[m]; m++) { | 511 for (i = 0; ngx_modules[i]; i++) { |
510 if (ngx_modules[m]->type != NGX_EVENT_MODULE) { | 512 if (ngx_modules[i]->type != NGX_EVENT_MODULE) { |
511 continue; | 513 continue; |
512 } | 514 } |
513 | 515 |
514 ngx_modules[m]->ctx_index = ngx_event_max_module++; | 516 ngx_modules[i]->ctx_index = ngx_event_max_module++; |
515 } | 517 } |
516 | 518 |
517 ngx_test_null(ctx, ngx_pcalloc(cf->pool, sizeof(void *)), NGX_CONF_ERROR); | 519 ctx = ngx_pcalloc(cf->pool, sizeof(void *)); |
518 | 520 if (ctx == NULL) { |
519 ngx_test_null(*ctx, | 521 return NGX_CONF_ERROR; |
520 ngx_pcalloc(cf->pool, ngx_event_max_module * sizeof(void *)), | 522 } |
521 NGX_CONF_ERROR); | 523 |
524 *ctx = ngx_pcalloc(cf->pool, ngx_event_max_module * sizeof(void *)); | |
525 if (*ctx == NULL) { | |
526 return NGX_CONF_ERROR; | |
527 } | |
522 | 528 |
523 *(void **) conf = ctx; | 529 *(void **) conf = ctx; |
524 | 530 |
525 for (m = 0; ngx_modules[m]; m++) { | 531 for (i = 0; ngx_modules[i]; i++) { |
526 if (ngx_modules[m]->type != NGX_EVENT_MODULE) { | 532 if (ngx_modules[i]->type != NGX_EVENT_MODULE) { |
527 continue; | 533 continue; |
528 } | 534 } |
529 | 535 |
530 module = ngx_modules[m]->ctx; | 536 m = ngx_modules[i]->ctx; |
531 | 537 |
532 if (module->create_conf) { | 538 if (m->create_conf) { |
533 ngx_test_null((*ctx)[ngx_modules[m]->ctx_index], | 539 (*ctx)[ngx_modules[i]->ctx_index] = m->create_conf(cf->cycle); |
534 module->create_conf(cf->cycle), | 540 if ((*ctx)[ngx_modules[i]->ctx_index] == NULL) { |
535 NGX_CONF_ERROR); | 541 return NGX_CONF_ERROR; |
542 } | |
536 } | 543 } |
537 } | 544 } |
538 | 545 |
539 pcf = *cf; | 546 pcf = *cf; |
540 cf->ctx = ctx; | 547 cf->ctx = ctx; |
541 cf->module_type = NGX_EVENT_MODULE; | 548 cf->module_type = NGX_EVENT_MODULE; |
542 cf->cmd_type = NGX_EVENT_CONF; | 549 cf->cmd_type = NGX_EVENT_CONF; |
550 | |
543 rv = ngx_conf_parse(cf, NULL); | 551 rv = ngx_conf_parse(cf, NULL); |
552 | |
544 *cf = pcf; | 553 *cf = pcf; |
545 | 554 |
546 if (rv != NGX_CONF_OK) | 555 if (rv != NGX_CONF_OK) |
547 return rv; | 556 return rv; |
548 | 557 |
549 for (m = 0; ngx_modules[m]; m++) { | 558 for (i = 0; ngx_modules[i]; i++) { |
550 if (ngx_modules[m]->type != NGX_EVENT_MODULE) { | 559 if (ngx_modules[i]->type != NGX_EVENT_MODULE) { |
551 continue; | 560 continue; |
552 } | 561 } |
553 | 562 |
554 module = ngx_modules[m]->ctx; | 563 m = ngx_modules[i]->ctx; |
555 | 564 |
556 if (module->init_conf) { | 565 if (m->init_conf) { |
557 rv = module->init_conf(cf->cycle, | 566 rv = m->init_conf(cf->cycle, (*ctx)[ngx_modules[i]->ctx_index]); |
558 (*ctx)[ngx_modules[m]->ctx_index]); | |
559 if (rv != NGX_CONF_OK) { | 567 if (rv != NGX_CONF_OK) { |
560 return rv; | 568 return rv; |
561 } | 569 } |
562 } | 570 } |
563 } | 571 } |
666 | 674 |
667 value = cf->args->elts; | 675 value = cf->args->elts; |
668 | 676 |
669 /* AF_INET only */ | 677 /* AF_INET only */ |
670 | 678 |
671 if (!(addr = ngx_push_array(&ecf->debug_connection))) { | 679 addr = ngx_array_push(&ecf->debug_connection); |
680 if (addr == NULL) { | |
672 return NGX_CONF_ERROR; | 681 return NGX_CONF_ERROR; |
673 } | 682 } |
674 | 683 |
675 *addr = inet_addr((char *) value[1].data); | 684 *addr = inet_addr((char *) value[1].data); |
676 | 685 |
702 | 711 |
703 static void *ngx_event_create_conf(ngx_cycle_t *cycle) | 712 static void *ngx_event_create_conf(ngx_cycle_t *cycle) |
704 { | 713 { |
705 ngx_event_conf_t *ecf; | 714 ngx_event_conf_t *ecf; |
706 | 715 |
707 ngx_test_null(ecf, ngx_palloc(cycle->pool, sizeof(ngx_event_conf_t)), | 716 ecf = ngx_palloc(cycle->pool, sizeof(ngx_event_conf_t)); |
708 NGX_CONF_ERROR); | 717 if (ecf == NULL) { |
718 return NGX_CONF_ERROR; | |
719 } | |
709 | 720 |
710 ecf->connections = NGX_CONF_UNSET_UINT; | 721 ecf->connections = NGX_CONF_UNSET_UINT; |
711 ecf->use = NGX_CONF_UNSET_UINT; | 722 ecf->use = NGX_CONF_UNSET_UINT; |
712 ecf->multi_accept = NGX_CONF_UNSET; | 723 ecf->multi_accept = NGX_CONF_UNSET; |
713 ecf->accept_mutex = NGX_CONF_UNSET; | 724 ecf->accept_mutex = NGX_CONF_UNSET; |
714 ecf->accept_mutex_delay = NGX_CONF_UNSET_MSEC; | 725 ecf->accept_mutex_delay = NGX_CONF_UNSET_MSEC; |
715 ecf->name = (void *) NGX_CONF_UNSET; | 726 ecf->name = (void *) NGX_CONF_UNSET; |
716 | 727 |
717 #if (NGX_DEBUG) | 728 #if (NGX_DEBUG) |
718 ngx_init_array(ecf->debug_connection, cycle->pool, 4, sizeof(in_addr_t), | 729 |
719 NGX_CONF_ERROR); | 730 if (ngx_array_init(&ecf->debug_connection, cycle->pool, 4, |
731 sizeof(in_addr_t)) == NGX_ERROR) | |
732 { | |
733 return NGX_CONF_ERROR; | |
734 } | |
735 | |
720 #endif | 736 #endif |
721 | 737 |
722 return ecf; | 738 return ecf; |
723 } | 739 } |
724 | 740 |
725 | 741 |
726 static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf) | 742 static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf) |
727 { | 743 { |
728 ngx_event_conf_t *ecf = conf; | 744 ngx_event_conf_t *ecf = conf; |
729 | 745 |
730 int fd, rtsig; | 746 #if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL) |
747 int fd; | |
748 #endif | |
749 #if (NGX_HAVE_RTSIG) | |
750 ngx_uint_t rtsig; | |
751 #endif | |
731 ngx_int_t i, connections; | 752 ngx_int_t i, connections; |
732 ngx_module_t *module; | 753 ngx_module_t *module; |
733 ngx_core_conf_t *ccf; | 754 ngx_core_conf_t *ccf; |
734 ngx_event_module_t *event_module; | 755 ngx_event_module_t *event_module; |
735 | 756 |
736 connections = NGX_CONF_UNSET_UINT; | 757 connections = NGX_CONF_UNSET_UINT; |
737 module = NULL; | 758 module = NULL; |
738 rtsig = 0; | |
739 fd = 0; | |
740 | 759 |
741 #if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL) | 760 #if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL) |
742 | 761 |
743 fd = epoll_create(100); | 762 fd = epoll_create(100); |
744 | 763 |
758 | 777 |
759 if (module == NULL) { | 778 if (module == NULL) { |
760 connections = DEFAULT_CONNECTIONS; | 779 connections = DEFAULT_CONNECTIONS; |
761 module = &ngx_rtsig_module; | 780 module = &ngx_rtsig_module; |
762 rtsig = 1; | 781 rtsig = 1; |
782 | |
783 } else { | |
784 rtsig = 0; | |
763 } | 785 } |
764 | 786 |
765 #endif | 787 #endif |
766 | 788 |
767 #if (NGX_HAVE_DEVPOLL) | 789 #if (NGX_HAVE_DEVPOLL) |
780 | 802 |
781 #if (NGX_HAVE_SELECT) | 803 #if (NGX_HAVE_SELECT) |
782 | 804 |
783 if (module == NULL) { | 805 if (module == NULL) { |
784 | 806 |
785 #if (NGX_WIN32) | 807 #if (NGX_WIN32 || FD_SETSIZE >= DEFAULT_CONNECTIONS) |
786 connections = DEFAULT_CONNECTIONS; | 808 connections = DEFAULT_CONNECTIONS; |
787 #else | 809 #else |
788 connections = FD_SETSIZE < DEFAULT_CONNECTIONS ? FD_SETSIZE: | 810 connections = FD_SETSIZE; |
789 DEFAULT_CONNECTIONS; | |
790 #endif | 811 #endif |
791 module = &ngx_select_module; | 812 module = &ngx_select_module; |
792 } | 813 } |
793 | 814 |
794 #endif | 815 #endif |
826 ngx_conf_init_value(ecf->multi_accept, 0); | 847 ngx_conf_init_value(ecf->multi_accept, 0); |
827 ngx_conf_init_value(ecf->accept_mutex, 1); | 848 ngx_conf_init_value(ecf->accept_mutex, 1); |
828 ngx_conf_init_msec_value(ecf->accept_mutex_delay, 500); | 849 ngx_conf_init_msec_value(ecf->accept_mutex_delay, 500); |
829 | 850 |
830 | 851 |
831 if (!rtsig || ecf->accept_mutex) { | 852 #if (NGX_HAVE_RTSIG) |
853 | |
854 if (!rtsig) { | |
855 return NGX_CONF_OK; | |
856 } | |
857 | |
858 #endif | |
859 | |
860 if (ecf->accept_mutex) { | |
832 return NGX_CONF_OK; | 861 return NGX_CONF_OK; |
833 } | 862 } |
834 | 863 |
835 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); | 864 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); |
836 | 865 |