comparison src/event/ngx_event.c @ 16:74b1868dd3cd NGINX_0_1_8

nginx 0.1.8 *) Bugfix: in the ngx_http_autoindex_module if the long file names were in the listing. *) Feature: the "^~" modifier in the location directive. *) Feature: the proxy_max_temp_file_size directive.
author Igor Sysoev <http://sysoev.ru>
date Sat, 20 Nov 2004 00:00:00 +0300
parents 46833bd150cb
children 6f8b0dc0f8dd
comparison
equal deleted inserted replaced
15:0503cb60c4e4 16:74b1868dd3cd
10 10
11 11
12 #define DEFAULT_CONNECTIONS 512 12 #define DEFAULT_CONNECTIONS 512
13 13
14 14
15 extern ngx_module_t ngx_kqueue_module;
16 extern ngx_module_t ngx_devpoll_module;
17 extern ngx_module_t ngx_epoll_module;
18 extern ngx_module_t ngx_rtsig_module;
15 extern ngx_module_t ngx_select_module; 19 extern ngx_module_t ngx_select_module;
16 extern ngx_event_module_t ngx_select_module_ctx; 20
17
18 #if (HAVE_KQUEUE)
19 #include <ngx_kqueue_module.h>
20 #endif
21
22 #if (HAVE_DEVPOLL)
23 extern ngx_module_t ngx_devpoll_module;
24 extern ngx_event_module_t ngx_devpoll_module_ctx;
25 #endif
26
27 #if (HAVE_EPOLL)
28 extern ngx_module_t ngx_epoll_module;
29 extern ngx_event_module_t ngx_epoll_module_ctx;
30 #endif
31
32 #if (HAVE_RTSIG)
33 extern ngx_module_t ngx_rtsig_module;
34 extern ngx_event_module_t ngx_rtsig_module_ctx;
35 #endif
36
37 #if (HAVE_AIO)
38 #include <ngx_aio_module.h>
39 #endif
40 21
41 static ngx_int_t ngx_event_module_init(ngx_cycle_t *cycle); 22 static ngx_int_t ngx_event_module_init(ngx_cycle_t *cycle);
42 static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle); 23 static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle);
43 static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); 24 static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
44 25
629 if (ngx_process == NGX_PROCESS_SINGLE 610 if (ngx_process == NGX_PROCESS_SINGLE
630 && old_ecf 611 && old_ecf
631 && old_ecf->use != ecf->use) 612 && old_ecf->use != ecf->use)
632 { 613 {
633 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 614 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
634 "when the server runs without a master process " 615 "when the server runs without a master process "
635 "the \"%V\" event type must be the same as " 616 "the \"%V\" event type must be the same as "
636 "in previous configuration - \"%s\" " 617 "in previous configuration - \"%s\" "
637 "and it can not be changed on the fly, " 618 "and it can not be changed on the fly, "
638 "to change it you need to stop server " 619 "to change it you need to stop server "
639 "and start it again", 620 "and start it again",
640 &value[1], old_ecf->name); 621 &value[1], old_ecf->name);
641 622
642 return NGX_CONF_ERROR; 623 return NGX_CONF_ERROR;
643 } 624 }
644 625
645 return NGX_CONF_OK; 626 return NGX_CONF_OK;
724 705
725 706
726 static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf) 707 static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
727 { 708 {
728 ngx_event_conf_t *ecf = conf; 709 ngx_event_conf_t *ecf = conf;
710
711 int fd, rtsig;
712 ngx_int_t i, connections;
713 ngx_module_t *module;
714 ngx_core_conf_t *ccf;
715 ngx_event_module_t *event_module;
716
717 connections = NGX_CONF_UNSET_UINT;
718 module = NULL;
719 rtsig = 0;
720 fd = 0;
721
722 #if (HAVE_EPOLL) && !(TEST_BUILD_EPOLL)
723
724 fd = epoll_create(100);
725
726 if (fd != -1) {
727 close(fd);
728 connections = DEFAULT_CONNECTIONS;
729 module = &ngx_epoll_module;
730
731 } else if (ngx_errno != NGX_ENOSYS) {
732 connections = DEFAULT_CONNECTIONS;
733 module = &ngx_epoll_module;
734 }
735
736 #endif
737
729 #if (HAVE_RTSIG) 738 #if (HAVE_RTSIG)
730 ngx_core_conf_t *ccf; 739
740 if (module == NULL) {
741 connections = DEFAULT_CONNECTIONS;
742 module = &ngx_rtsig_module;
743 rtsig = 1;
744 }
745
746 #endif
747
748 #if (HAVE_DEVPOLL)
749
750 connections = DEFAULT_CONNECTIONS;
751 module = &ngx_devpoll_module;
752
731 #endif 753 #endif
732 754
733 #if (HAVE_KQUEUE) 755 #if (HAVE_KQUEUE)
734 756
735 ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS); 757 connections = DEFAULT_CONNECTIONS;
736 ngx_conf_init_unsigned_value(ecf->use, ngx_kqueue_module.ctx_index); 758 module = &ngx_kqueue_module;
737 ngx_conf_init_ptr_value(ecf->name, ngx_kqueue_module_ctx.name->data); 759
738 760 #endif
739 #elif (HAVE_DEVPOLL) 761
740 762 #if (HAVE_SELECT)
741 ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS); 763
742 ngx_conf_init_unsigned_value(ecf->use, ngx_devpoll_module.ctx_index); 764 if (module == NULL) {
743 ngx_conf_init_ptr_value(ecf->name, ngx_devpoll_module_ctx.name->data);
744
745 #elif (HAVE_EPOLL)
746
747 ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS);
748 ngx_conf_init_unsigned_value(ecf->use, ngx_epoll_module.ctx_index);
749 ngx_conf_init_ptr_value(ecf->name, ngx_epoll_module_ctx.name->data);
750
751 #elif (HAVE_RTSIG)
752
753 ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS);
754 ngx_conf_init_unsigned_value(ecf->use, ngx_rtsig_module.ctx_index);
755 ngx_conf_init_ptr_value(ecf->name, ngx_rtsig_module_ctx.name->data);
756
757 #elif (HAVE_SELECT)
758 765
759 #if (NGX_WIN32) 766 #if (NGX_WIN32)
760 ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS); 767 connections = DEFAULT_CONNECTIONS;
761 #else 768 #else
762 ngx_conf_init_unsigned_value(ecf->connections, 769 connections = FD_SETSIZE < DEFAULT_CONNECTIONS ? FD_SETSIZE:
763 FD_SETSIZE < DEFAULT_CONNECTIONS ? FD_SETSIZE : DEFAULT_CONNECTIONS); 770 DEFAULT_CONNECTIONS;
764 #endif 771 #endif
765 772 module = &ngx_select_module;
766 ngx_conf_init_unsigned_value(ecf->use, ngx_select_module.ctx_index); 773 }
767 ngx_conf_init_ptr_value(ecf->name, ngx_select_module_ctx.name->data); 774
768 775 #endif
769 #else 776
770 777 if (module == NULL) {
771 ngx_int_t i, m; 778 for (i = 0; ngx_modules[i]; i++) {
772 ngx_event_module_t *module; 779 if (ngx_modules[i]->type == NGX_EVENT_MODULE) {
773 780 event_module = ngx_modules[i]->ctx;
774 m = -1; 781
775 module = NULL; 782 if (ngx_strcmp(event_module->name->data, event_core_name.data)
776 783 == 0)
777 for (i = 0; ngx_modules[i]; i++) { 784 {
778 if (ngx_modules[i]->type == NGX_EVENT_MODULE) { 785 continue;
779 module = ngx_modules[i]->ctx; 786 }
780 787
781 if (ngx_strcmp(module->name->data, event_core_name.data) == 0) { 788 module = ngx_modules[i];
782 continue; 789 break;
783 } 790 }
784 791 }
785 m = ngx_modules[i]->ctx_index; 792 }
786 break; 793
787 } 794 if (module == NULL) {
788 }
789
790 if (m == -1) {
791 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "no events module found"); 795 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "no events module found");
792 return NGX_CONF_ERROR; 796 return NGX_CONF_ERROR;
793 } 797 }
794 798
795 ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS); 799 ngx_conf_init_unsigned_value(ecf->connections, connections);
796
797 ngx_conf_init_unsigned_value(ecf->use, m);
798 ngx_conf_init_ptr_value(ecf->name, module->name->data);
799
800 #endif
801
802 cycle->connection_n = ecf->connections; 800 cycle->connection_n = ecf->connections;
801
802 ngx_conf_init_unsigned_value(ecf->use, module->ctx_index);
803
804 event_module = module->ctx;
805 ngx_conf_init_ptr_value(ecf->name, event_module->name->data);
803 806
804 ngx_conf_init_value(ecf->multi_accept, 0); 807 ngx_conf_init_value(ecf->multi_accept, 0);
805 ngx_conf_init_value(ecf->accept_mutex, 1); 808 ngx_conf_init_value(ecf->accept_mutex, 1);
806 ngx_conf_init_msec_value(ecf->accept_mutex_delay, 500); 809 ngx_conf_init_msec_value(ecf->accept_mutex_delay, 500);
807 810
808 #if (HAVE_RTSIG) 811
809 if (ecf->use == ngx_rtsig_module.ctx_index && ecf->accept_mutex == 0) { 812 if (!rtsig || ecf->accept_mutex) {
810 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, 813 return NGX_CONF_OK;
811 ngx_core_module); 814 }
812 if (ccf->worker_processes) { 815
813 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, 816 ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
814 "the \"rtsig\" method requires " 817
815 "\"accept_mutex\" to be on"); 818 if (ccf->worker_processes == 0) {
816 return NGX_CONF_ERROR; 819 return NGX_CONF_OK;
817 } 820 }
818 } 821
819 #endif 822 ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
820 823 "the \"rtsig\" method requires \"accept_mutex\" to be on");
821 return NGX_CONF_OK; 824
825 return NGX_CONF_ERROR;
822 } 826 }
823 827
824 828
825 static char *ngx_accept_mutex_check(ngx_conf_t *cf, void *post, void *data) 829 static char *ngx_accept_mutex_check(ngx_conf_t *cf, void *post, void *data)
826 { 830 {