nginxtra 1.0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -0
- data/bin/nginxtra +5 -0
- data/lib/nginxtra.rb +12 -0
- data/lib/nginxtra/action.rb +36 -0
- data/lib/nginxtra/actions/compile.rb +60 -0
- data/lib/nginxtra/actions/install.rb +99 -0
- data/lib/nginxtra/actions/reload.rb +14 -0
- data/lib/nginxtra/actions/restart.rb +15 -0
- data/lib/nginxtra/actions/start.rb +53 -0
- data/lib/nginxtra/actions/status.rb +31 -0
- data/lib/nginxtra/actions/stop.rb +14 -0
- data/lib/nginxtra/cli.rb +77 -0
- data/lib/nginxtra/config.rb +339 -0
- data/lib/nginxtra/error.rb +13 -0
- data/lib/nginxtra/status.rb +57 -0
- data/src/nginx/CHANGES +5630 -0
- data/src/nginx/CHANGES.ru +5716 -0
- data/src/nginx/LICENSE +25 -0
- data/src/nginx/README +3 -0
- data/src/nginx/auto/cc/acc +15 -0
- data/src/nginx/auto/cc/bcc +72 -0
- data/src/nginx/auto/cc/ccc +46 -0
- data/src/nginx/auto/cc/conf +189 -0
- data/src/nginx/auto/cc/gcc +183 -0
- data/src/nginx/auto/cc/icc +121 -0
- data/src/nginx/auto/cc/msvc +138 -0
- data/src/nginx/auto/cc/name +101 -0
- data/src/nginx/auto/cc/owc +104 -0
- data/src/nginx/auto/cc/sunc +158 -0
- data/src/nginx/auto/define +12 -0
- data/src/nginx/auto/endianess +45 -0
- data/src/nginx/auto/feature +123 -0
- data/src/nginx/auto/have +12 -0
- data/src/nginx/auto/have_headers +12 -0
- data/src/nginx/auto/headers +13 -0
- data/src/nginx/auto/include +61 -0
- data/src/nginx/auto/init +51 -0
- data/src/nginx/auto/install +184 -0
- data/src/nginx/auto/lib/conf +83 -0
- data/src/nginx/auto/lib/geoip/conf +79 -0
- data/src/nginx/auto/lib/google-perftools/conf +45 -0
- data/src/nginx/auto/lib/libatomic/conf +43 -0
- data/src/nginx/auto/lib/libatomic/make +14 -0
- data/src/nginx/auto/lib/libgd/conf +83 -0
- data/src/nginx/auto/lib/libxslt/conf +156 -0
- data/src/nginx/auto/lib/make +32 -0
- data/src/nginx/auto/lib/md5/conf +103 -0
- data/src/nginx/auto/lib/md5/make +96 -0
- data/src/nginx/auto/lib/md5/makefile.bcc +22 -0
- data/src/nginx/auto/lib/md5/makefile.msvc +22 -0
- data/src/nginx/auto/lib/md5/makefile.owc +11 -0
- data/src/nginx/auto/lib/openssl/conf +74 -0
- data/src/nginx/auto/lib/openssl/make +67 -0
- data/src/nginx/auto/lib/openssl/makefile.bcc +18 -0
- data/src/nginx/auto/lib/openssl/makefile.msvc +14 -0
- data/src/nginx/auto/lib/pcre/conf +180 -0
- data/src/nginx/auto/lib/pcre/make +64 -0
- data/src/nginx/auto/lib/pcre/makefile.bcc +26 -0
- data/src/nginx/auto/lib/pcre/makefile.msvc +22 -0
- data/src/nginx/auto/lib/pcre/makefile.owc +24 -0
- data/src/nginx/auto/lib/perl/conf +60 -0
- data/src/nginx/auto/lib/perl/make +36 -0
- data/src/nginx/auto/lib/sha1/conf +79 -0
- data/src/nginx/auto/lib/sha1/make +96 -0
- data/src/nginx/auto/lib/sha1/makefile.bcc +22 -0
- data/src/nginx/auto/lib/sha1/makefile.msvc +22 -0
- data/src/nginx/auto/lib/sha1/makefile.owc +11 -0
- data/src/nginx/auto/lib/test +40 -0
- data/src/nginx/auto/lib/zlib/conf +76 -0
- data/src/nginx/auto/lib/zlib/make +114 -0
- data/src/nginx/auto/lib/zlib/makefile.bcc +15 -0
- data/src/nginx/auto/lib/zlib/makefile.msvc +14 -0
- data/src/nginx/auto/lib/zlib/makefile.owc +14 -0
- data/src/nginx/auto/lib/zlib/patch.zlib.h +10 -0
- data/src/nginx/auto/make +417 -0
- data/src/nginx/auto/modules +479 -0
- data/src/nginx/auto/nohave +12 -0
- data/src/nginx/auto/options +490 -0
- data/src/nginx/auto/os/conf +105 -0
- data/src/nginx/auto/os/darwin +116 -0
- data/src/nginx/auto/os/freebsd +136 -0
- data/src/nginx/auto/os/linux +152 -0
- data/src/nginx/auto/os/solaris +60 -0
- data/src/nginx/auto/os/win32 +29 -0
- data/src/nginx/auto/sources +518 -0
- data/src/nginx/auto/stubs +8 -0
- data/src/nginx/auto/summary +114 -0
- data/src/nginx/auto/types/sizeof +83 -0
- data/src/nginx/auto/types/typedef +77 -0
- data/src/nginx/auto/types/uintptr_t +42 -0
- data/src/nginx/auto/types/value +12 -0
- data/src/nginx/auto/unix +719 -0
- data/src/nginx/conf/fastcgi.conf +24 -0
- data/src/nginx/conf/fastcgi_params +23 -0
- data/src/nginx/conf/koi-utf +109 -0
- data/src/nginx/conf/koi-win +103 -0
- data/src/nginx/conf/mime.types +80 -0
- data/src/nginx/conf/nginx.conf +118 -0
- data/src/nginx/conf/scgi_params +15 -0
- data/src/nginx/conf/uwsgi_params +15 -0
- data/src/nginx/conf/win-utf +126 -0
- data/src/nginx/configure +108 -0
- data/src/nginx/contrib/README +15 -0
- data/src/nginx/contrib/geo2nginx.pl +58 -0
- data/src/nginx/contrib/unicode2nginx/koi-utf +131 -0
- data/src/nginx/contrib/unicode2nginx/unicode-to-nginx.pl +45 -0
- data/src/nginx/contrib/unicode2nginx/win-utf +130 -0
- data/src/nginx/html/50x.html +18 -0
- data/src/nginx/html/index.html +8 -0
- data/src/nginx/man/nginx.8 +202 -0
- data/src/nginx/src/core/nginx.c +1333 -0
- data/src/nginx/src/core/nginx.h +20 -0
- data/src/nginx/src/core/ngx_array.c +147 -0
- data/src/nginx/src/core/ngx_array.h +53 -0
- data/src/nginx/src/core/ngx_buf.c +218 -0
- data/src/nginx/src/core/ngx_buf.h +162 -0
- data/src/nginx/src/core/ngx_conf_file.c +1506 -0
- data/src/nginx/src/core/ngx_conf_file.h +348 -0
- data/src/nginx/src/core/ngx_config.h +134 -0
- data/src/nginx/src/core/ngx_connection.c +1074 -0
- data/src/nginx/src/core/ngx_connection.h +195 -0
- data/src/nginx/src/core/ngx_core.h +95 -0
- data/src/nginx/src/core/ngx_cpuinfo.c +139 -0
- data/src/nginx/src/core/ngx_crc.h +39 -0
- data/src/nginx/src/core/ngx_crc32.c +129 -0
- data/src/nginx/src/core/ngx_crc32.h +79 -0
- data/src/nginx/src/core/ngx_crypt.c +238 -0
- data/src/nginx/src/core/ngx_crypt.h +20 -0
- data/src/nginx/src/core/ngx_cycle.c +1379 -0
- data/src/nginx/src/core/ngx_cycle.h +142 -0
- data/src/nginx/src/core/ngx_file.c +993 -0
- data/src/nginx/src/core/ngx_file.h +151 -0
- data/src/nginx/src/core/ngx_hash.c +976 -0
- data/src/nginx/src/core/ngx_hash.h +122 -0
- data/src/nginx/src/core/ngx_inet.c +1008 -0
- data/src/nginx/src/core/ngx_inet.h +120 -0
- data/src/nginx/src/core/ngx_list.c +71 -0
- data/src/nginx/src/core/ngx_list.h +83 -0
- data/src/nginx/src/core/ngx_log.c +459 -0
- data/src/nginx/src/core/ngx_log.h +250 -0
- data/src/nginx/src/core/ngx_md5.c +289 -0
- data/src/nginx/src/core/ngx_md5.h +60 -0
- data/src/nginx/src/core/ngx_murmurhash.c +50 -0
- data/src/nginx/src/core/ngx_murmurhash.h +19 -0
- data/src/nginx/src/core/ngx_open_file_cache.c +882 -0
- data/src/nginx/src/core/ngx_open_file_cache.h +119 -0
- data/src/nginx/src/core/ngx_output_chain.c +673 -0
- data/src/nginx/src/core/ngx_palloc.c +433 -0
- data/src/nginx/src/core/ngx_palloc.h +95 -0
- data/src/nginx/src/core/ngx_parse.c +249 -0
- data/src/nginx/src/core/ngx_parse.h +24 -0
- data/src/nginx/src/core/ngx_queue.c +80 -0
- data/src/nginx/src/core/ngx_queue.h +112 -0
- data/src/nginx/src/core/ngx_radix_tree.c +291 -0
- data/src/nginx/src/core/ngx_radix_tree.h +46 -0
- data/src/nginx/src/core/ngx_rbtree.c +383 -0
- data/src/nginx/src/core/ngx_rbtree.h +84 -0
- data/src/nginx/src/core/ngx_regex.c +206 -0
- data/src/nginx/src/core/ngx_regex.h +56 -0
- data/src/nginx/src/core/ngx_resolver.c +2201 -0
- data/src/nginx/src/core/ngx_resolver.h +149 -0
- data/src/nginx/src/core/ngx_sha1.h +31 -0
- data/src/nginx/src/core/ngx_shmtx.c +284 -0
- data/src/nginx/src/core/ngx_shmtx.h +38 -0
- data/src/nginx/src/core/ngx_slab.c +701 -0
- data/src/nginx/src/core/ngx_slab.h +54 -0
- data/src/nginx/src/core/ngx_spinlock.c +53 -0
- data/src/nginx/src/core/ngx_string.c +1837 -0
- data/src/nginx/src/core/ngx_string.h +231 -0
- data/src/nginx/src/core/ngx_times.c +407 -0
- data/src/nginx/src/core/ngx_times.h +51 -0
- data/src/nginx/src/event/modules/ngx_aio_module.c +171 -0
- data/src/nginx/src/event/modules/ngx_devpoll_module.c +569 -0
- data/src/nginx/src/event/modules/ngx_epoll_module.c +833 -0
- data/src/nginx/src/event/modules/ngx_eventport_module.c +602 -0
- data/src/nginx/src/event/modules/ngx_kqueue_module.c +785 -0
- data/src/nginx/src/event/modules/ngx_poll_module.c +443 -0
- data/src/nginx/src/event/modules/ngx_rtsig_module.c +735 -0
- data/src/nginx/src/event/modules/ngx_select_module.c +435 -0
- data/src/nginx/src/event/modules/ngx_win32_select_module.c +400 -0
- data/src/nginx/src/event/ngx_event.c +1275 -0
- data/src/nginx/src/event/ngx_event.h +573 -0
- data/src/nginx/src/event/ngx_event_accept.c +428 -0
- data/src/nginx/src/event/ngx_event_busy_lock.c +286 -0
- data/src/nginx/src/event/ngx_event_busy_lock.h +65 -0
- data/src/nginx/src/event/ngx_event_connect.c +258 -0
- data/src/nginx/src/event/ngx_event_connect.h +76 -0
- data/src/nginx/src/event/ngx_event_mutex.c +70 -0
- data/src/nginx/src/event/ngx_event_openssl.c +2382 -0
- data/src/nginx/src/event/ngx_event_openssl.h +162 -0
- data/src/nginx/src/event/ngx_event_pipe.c +996 -0
- data/src/nginx/src/event/ngx_event_pipe.h +95 -0
- data/src/nginx/src/event/ngx_event_posted.c +173 -0
- data/src/nginx/src/event/ngx_event_posted.h +75 -0
- data/src/nginx/src/event/ngx_event_timer.c +159 -0
- data/src/nginx/src/event/ngx_event_timer.h +102 -0
- data/src/nginx/src/http/modules/ngx_http_access_module.c +384 -0
- data/src/nginx/src/http/modules/ngx_http_addition_filter_module.c +250 -0
- data/src/nginx/src/http/modules/ngx_http_auth_basic_module.c +478 -0
- data/src/nginx/src/http/modules/ngx_http_autoindex_module.c +701 -0
- data/src/nginx/src/http/modules/ngx_http_browser_module.c +713 -0
- data/src/nginx/src/http/modules/ngx_http_charset_filter_module.c +1681 -0
- data/src/nginx/src/http/modules/ngx_http_chunked_filter_module.c +242 -0
- data/src/nginx/src/http/modules/ngx_http_dav_module.c +1141 -0
- data/src/nginx/src/http/modules/ngx_http_degradation_module.c +243 -0
- data/src/nginx/src/http/modules/ngx_http_empty_gif_module.c +140 -0
- data/src/nginx/src/http/modules/ngx_http_fastcgi_module.c +2916 -0
- data/src/nginx/src/http/modules/ngx_http_flv_module.c +254 -0
- data/src/nginx/src/http/modules/ngx_http_geo_module.c +1441 -0
- data/src/nginx/src/http/modules/ngx_http_geoip_module.c +671 -0
- data/src/nginx/src/http/modules/ngx_http_gzip_filter_module.c +1206 -0
- data/src/nginx/src/http/modules/ngx_http_gzip_static_module.c +299 -0
- data/src/nginx/src/http/modules/ngx_http_headers_filter_module.c +616 -0
- data/src/nginx/src/http/modules/ngx_http_image_filter_module.c +1489 -0
- data/src/nginx/src/http/modules/ngx_http_index_module.c +516 -0
- data/src/nginx/src/http/modules/ngx_http_limit_req_module.c +809 -0
- data/src/nginx/src/http/modules/ngx_http_limit_zone_module.c +553 -0
- data/src/nginx/src/http/modules/ngx_http_log_module.c +1357 -0
- data/src/nginx/src/http/modules/ngx_http_map_module.c +575 -0
- data/src/nginx/src/http/modules/ngx_http_memcached_module.c +624 -0
- data/src/nginx/src/http/modules/ngx_http_mp4_module.c +3000 -0
- data/src/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +143 -0
- data/src/nginx/src/http/modules/ngx_http_proxy_module.c +2831 -0
- data/src/nginx/src/http/modules/ngx_http_random_index_module.c +317 -0
- data/src/nginx/src/http/modules/ngx_http_range_filter_module.c +855 -0
- data/src/nginx/src/http/modules/ngx_http_realip_module.c +476 -0
- data/src/nginx/src/http/modules/ngx_http_referer_module.c +613 -0
- data/src/nginx/src/http/modules/ngx_http_rewrite_module.c +1019 -0
- data/src/nginx/src/http/modules/ngx_http_scgi_module.c +1714 -0
- data/src/nginx/src/http/modules/ngx_http_secure_link_module.c +355 -0
- data/src/nginx/src/http/modules/ngx_http_split_clients_module.c +242 -0
- data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.c +2913 -0
- data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.h +114 -0
- data/src/nginx/src/http/modules/ngx_http_ssl_module.c +652 -0
- data/src/nginx/src/http/modules/ngx_http_ssl_module.h +52 -0
- data/src/nginx/src/http/modules/ngx_http_static_module.c +278 -0
- data/src/nginx/src/http/modules/ngx_http_stub_status_module.c +144 -0
- data/src/nginx/src/http/modules/ngx_http_sub_filter_module.c +716 -0
- data/src/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +237 -0
- data/src/nginx/src/http/modules/ngx_http_userid_filter_module.c +846 -0
- data/src/nginx/src/http/modules/ngx_http_uwsgi_module.c +1774 -0
- data/src/nginx/src/http/modules/ngx_http_xslt_filter_module.c +984 -0
- data/src/nginx/src/http/modules/perl/Makefile.PL +42 -0
- data/src/nginx/src/http/modules/perl/nginx.pm +137 -0
- data/src/nginx/src/http/modules/perl/nginx.xs +986 -0
- data/src/nginx/src/http/modules/perl/ngx_http_perl_module.c +1076 -0
- data/src/nginx/src/http/modules/perl/ngx_http_perl_module.h +67 -0
- data/src/nginx/src/http/modules/perl/typemap +3 -0
- data/src/nginx/src/http/ngx_http.c +2073 -0
- data/src/nginx/src/http/ngx_http.h +160 -0
- data/src/nginx/src/http/ngx_http_busy_lock.c +307 -0
- data/src/nginx/src/http/ngx_http_busy_lock.h +54 -0
- data/src/nginx/src/http/ngx_http_cache.h +148 -0
- data/src/nginx/src/http/ngx_http_config.h +75 -0
- data/src/nginx/src/http/ngx_http_copy_filter_module.c +300 -0
- data/src/nginx/src/http/ngx_http_core_module.c +4736 -0
- data/src/nginx/src/http/ngx_http_core_module.h +541 -0
- data/src/nginx/src/http/ngx_http_file_cache.c +1715 -0
- data/src/nginx/src/http/ngx_http_header_filter_module.c +623 -0
- data/src/nginx/src/http/ngx_http_parse.c +1734 -0
- data/src/nginx/src/http/ngx_http_parse_time.c +276 -0
- data/src/nginx/src/http/ngx_http_postpone_filter_module.c +178 -0
- data/src/nginx/src/http/ngx_http_request.c +3181 -0
- data/src/nginx/src/http/ngx_http_request.h +573 -0
- data/src/nginx/src/http/ngx_http_request_body.c +644 -0
- data/src/nginx/src/http/ngx_http_script.c +1752 -0
- data/src/nginx/src/http/ngx_http_script.h +257 -0
- data/src/nginx/src/http/ngx_http_special_response.c +789 -0
- data/src/nginx/src/http/ngx_http_upstream.c +4555 -0
- data/src/nginx/src/http/ngx_http_upstream.h +350 -0
- data/src/nginx/src/http/ngx_http_upstream_round_robin.c +791 -0
- data/src/nginx/src/http/ngx_http_upstream_round_robin.h +85 -0
- data/src/nginx/src/http/ngx_http_variables.c +2053 -0
- data/src/nginx/src/http/ngx_http_variables.h +115 -0
- data/src/nginx/src/http/ngx_http_write_filter_module.c +315 -0
- data/src/nginx/src/mail/ngx_mail.c +542 -0
- data/src/nginx/src/mail/ngx_mail.h +407 -0
- data/src/nginx/src/mail/ngx_mail_auth_http_module.c +1452 -0
- data/src/nginx/src/mail/ngx_mail_core_module.c +553 -0
- data/src/nginx/src/mail/ngx_mail_handler.c +773 -0
- data/src/nginx/src/mail/ngx_mail_imap_handler.c +457 -0
- data/src/nginx/src/mail/ngx_mail_imap_module.c +253 -0
- data/src/nginx/src/mail/ngx_mail_imap_module.h +39 -0
- data/src/nginx/src/mail/ngx_mail_parse.c +885 -0
- data/src/nginx/src/mail/ngx_mail_pop3_handler.c +500 -0
- data/src/nginx/src/mail/ngx_mail_pop3_module.c +264 -0
- data/src/nginx/src/mail/ngx_mail_pop3_module.h +38 -0
- data/src/nginx/src/mail/ngx_mail_proxy_module.c +1089 -0
- data/src/nginx/src/mail/ngx_mail_smtp_handler.c +872 -0
- data/src/nginx/src/mail/ngx_mail_smtp_module.c +308 -0
- data/src/nginx/src/mail/ngx_mail_smtp_module.h +45 -0
- data/src/nginx/src/mail/ngx_mail_ssl_module.c +491 -0
- data/src/nginx/src/mail/ngx_mail_ssl_module.h +52 -0
- data/src/nginx/src/misc/ngx_cpp_test_module.cpp +27 -0
- data/src/nginx/src/misc/ngx_google_perftools_module.c +126 -0
- data/src/nginx/src/os/unix/ngx_aio_read.c +109 -0
- data/src/nginx/src/os/unix/ngx_aio_read_chain.c +78 -0
- data/src/nginx/src/os/unix/ngx_aio_write.c +109 -0
- data/src/nginx/src/os/unix/ngx_aio_write_chain.c +100 -0
- data/src/nginx/src/os/unix/ngx_alloc.c +90 -0
- data/src/nginx/src/os/unix/ngx_alloc.h +45 -0
- data/src/nginx/src/os/unix/ngx_atomic.h +311 -0
- data/src/nginx/src/os/unix/ngx_channel.c +258 -0
- data/src/nginx/src/os/unix/ngx_channel.h +34 -0
- data/src/nginx/src/os/unix/ngx_daemon.c +69 -0
- data/src/nginx/src/os/unix/ngx_darwin.h +20 -0
- data/src/nginx/src/os/unix/ngx_darwin_config.h +96 -0
- data/src/nginx/src/os/unix/ngx_darwin_init.c +166 -0
- data/src/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +366 -0
- data/src/nginx/src/os/unix/ngx_errno.c +87 -0
- data/src/nginx/src/os/unix/ngx_errno.h +68 -0
- data/src/nginx/src/os/unix/ngx_file_aio_read.c +208 -0
- data/src/nginx/src/os/unix/ngx_files.c +566 -0
- data/src/nginx/src/os/unix/ngx_files.h +343 -0
- data/src/nginx/src/os/unix/ngx_freebsd.h +24 -0
- data/src/nginx/src/os/unix/ngx_freebsd_config.h +119 -0
- data/src/nginx/src/os/unix/ngx_freebsd_init.c +259 -0
- data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +756 -0
- data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +122 -0
- data/src/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +436 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_amd64.h +82 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_ppc.h +155 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_sparc64.h +82 -0
- data/src/nginx/src/os/unix/ngx_gcc_atomic_x86.h +127 -0
- data/src/nginx/src/os/unix/ngx_linux.h +18 -0
- data/src/nginx/src/os/unix/ngx_linux_aio_read.c +137 -0
- data/src/nginx/src/os/unix/ngx_linux_config.h +117 -0
- data/src/nginx/src/os/unix/ngx_linux_init.c +91 -0
- data/src/nginx/src/os/unix/ngx_linux_sendfile_chain.c +378 -0
- data/src/nginx/src/os/unix/ngx_os.h +84 -0
- data/src/nginx/src/os/unix/ngx_posix_config.h +153 -0
- data/src/nginx/src/os/unix/ngx_posix_init.c +124 -0
- data/src/nginx/src/os/unix/ngx_process.c +590 -0
- data/src/nginx/src/os/unix/ngx_process.h +87 -0
- data/src/nginx/src/os/unix/ngx_process_cycle.c +1390 -0
- data/src/nginx/src/os/unix/ngx_process_cycle.h +61 -0
- data/src/nginx/src/os/unix/ngx_pthread_thread.c +278 -0
- data/src/nginx/src/os/unix/ngx_readv_chain.c +258 -0
- data/src/nginx/src/os/unix/ngx_recv.c +180 -0
- data/src/nginx/src/os/unix/ngx_send.c +73 -0
- data/src/nginx/src/os/unix/ngx_setproctitle.c +135 -0
- data/src/nginx/src/os/unix/ngx_setproctitle.h +52 -0
- data/src/nginx/src/os/unix/ngx_shmem.c +126 -0
- data/src/nginx/src/os/unix/ngx_shmem.h +29 -0
- data/src/nginx/src/os/unix/ngx_socket.c +116 -0
- data/src/nginx/src/os/unix/ngx_socket.h +64 -0
- data/src/nginx/src/os/unix/ngx_solaris.h +16 -0
- data/src/nginx/src/os/unix/ngx_solaris_config.h +107 -0
- data/src/nginx/src/os/unix/ngx_solaris_init.c +75 -0
- data/src/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +251 -0
- data/src/nginx/src/os/unix/ngx_sunpro_amd64.il +43 -0
- data/src/nginx/src/os/unix/ngx_sunpro_atomic_sparc64.h +61 -0
- data/src/nginx/src/os/unix/ngx_sunpro_sparc64.il +36 -0
- data/src/nginx/src/os/unix/ngx_sunpro_x86.il +44 -0
- data/src/nginx/src/os/unix/ngx_thread.h +128 -0
- data/src/nginx/src/os/unix/ngx_time.c +104 -0
- data/src/nginx/src/os/unix/ngx_time.h +66 -0
- data/src/nginx/src/os/unix/ngx_udp_recv.c +115 -0
- data/src/nginx/src/os/unix/ngx_user.c +109 -0
- data/src/nginx/src/os/unix/ngx_user.h +24 -0
- data/src/nginx/src/os/unix/ngx_writev_chain.c +181 -0
- data/src/nginx/src/os/unix/rfork_thread.S +73 -0
- metadata +419 -0
@@ -0,0 +1,1275 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (C) Igor Sysoev
|
4
|
+
* Copyright (C) Nginx, Inc.
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
#include <ngx_config.h>
|
9
|
+
#include <ngx_core.h>
|
10
|
+
#include <ngx_event.h>
|
11
|
+
|
12
|
+
|
13
|
+
#define DEFAULT_CONNECTIONS 512
|
14
|
+
|
15
|
+
|
16
|
+
extern ngx_module_t ngx_kqueue_module;
|
17
|
+
extern ngx_module_t ngx_eventport_module;
|
18
|
+
extern ngx_module_t ngx_devpoll_module;
|
19
|
+
extern ngx_module_t ngx_epoll_module;
|
20
|
+
extern ngx_module_t ngx_rtsig_module;
|
21
|
+
extern ngx_module_t ngx_select_module;
|
22
|
+
|
23
|
+
|
24
|
+
static ngx_int_t ngx_event_module_init(ngx_cycle_t *cycle);
|
25
|
+
static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle);
|
26
|
+
static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
27
|
+
|
28
|
+
static char *ngx_event_connections(ngx_conf_t *cf, ngx_command_t *cmd,
|
29
|
+
void *conf);
|
30
|
+
static char *ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
31
|
+
static char *ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd,
|
32
|
+
void *conf);
|
33
|
+
|
34
|
+
static void *ngx_event_create_conf(ngx_cycle_t *cycle);
|
35
|
+
static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf);
|
36
|
+
|
37
|
+
|
38
|
+
static ngx_uint_t ngx_timer_resolution;
|
39
|
+
sig_atomic_t ngx_event_timer_alarm;
|
40
|
+
|
41
|
+
static ngx_uint_t ngx_event_max_module;
|
42
|
+
|
43
|
+
ngx_uint_t ngx_event_flags;
|
44
|
+
ngx_event_actions_t ngx_event_actions;
|
45
|
+
|
46
|
+
|
47
|
+
static ngx_atomic_t connection_counter = 1;
|
48
|
+
ngx_atomic_t *ngx_connection_counter = &connection_counter;
|
49
|
+
|
50
|
+
|
51
|
+
ngx_atomic_t *ngx_accept_mutex_ptr;
|
52
|
+
ngx_shmtx_t ngx_accept_mutex;
|
53
|
+
ngx_uint_t ngx_use_accept_mutex;
|
54
|
+
ngx_uint_t ngx_accept_events;
|
55
|
+
ngx_uint_t ngx_accept_mutex_held;
|
56
|
+
ngx_msec_t ngx_accept_mutex_delay;
|
57
|
+
ngx_int_t ngx_accept_disabled;
|
58
|
+
ngx_file_t ngx_accept_mutex_lock_file;
|
59
|
+
|
60
|
+
|
61
|
+
#if (NGX_STAT_STUB)
|
62
|
+
|
63
|
+
ngx_atomic_t ngx_stat_accepted0;
|
64
|
+
ngx_atomic_t *ngx_stat_accepted = &ngx_stat_accepted0;
|
65
|
+
ngx_atomic_t ngx_stat_handled0;
|
66
|
+
ngx_atomic_t *ngx_stat_handled = &ngx_stat_handled0;
|
67
|
+
ngx_atomic_t ngx_stat_requests0;
|
68
|
+
ngx_atomic_t *ngx_stat_requests = &ngx_stat_requests0;
|
69
|
+
ngx_atomic_t ngx_stat_active0;
|
70
|
+
ngx_atomic_t *ngx_stat_active = &ngx_stat_active0;
|
71
|
+
ngx_atomic_t ngx_stat_reading0;
|
72
|
+
ngx_atomic_t *ngx_stat_reading = &ngx_stat_reading0;
|
73
|
+
ngx_atomic_t ngx_stat_writing0;
|
74
|
+
ngx_atomic_t *ngx_stat_writing = &ngx_stat_writing0;
|
75
|
+
|
76
|
+
#endif
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
static ngx_command_t ngx_events_commands[] = {
|
81
|
+
|
82
|
+
{ ngx_string("events"),
|
83
|
+
NGX_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
|
84
|
+
ngx_events_block,
|
85
|
+
0,
|
86
|
+
0,
|
87
|
+
NULL },
|
88
|
+
|
89
|
+
ngx_null_command
|
90
|
+
};
|
91
|
+
|
92
|
+
|
93
|
+
static ngx_core_module_t ngx_events_module_ctx = {
|
94
|
+
ngx_string("events"),
|
95
|
+
NULL,
|
96
|
+
NULL
|
97
|
+
};
|
98
|
+
|
99
|
+
|
100
|
+
ngx_module_t ngx_events_module = {
|
101
|
+
NGX_MODULE_V1,
|
102
|
+
&ngx_events_module_ctx, /* module context */
|
103
|
+
ngx_events_commands, /* module directives */
|
104
|
+
NGX_CORE_MODULE, /* module type */
|
105
|
+
NULL, /* init master */
|
106
|
+
NULL, /* init module */
|
107
|
+
NULL, /* init process */
|
108
|
+
NULL, /* init thread */
|
109
|
+
NULL, /* exit thread */
|
110
|
+
NULL, /* exit process */
|
111
|
+
NULL, /* exit master */
|
112
|
+
NGX_MODULE_V1_PADDING
|
113
|
+
};
|
114
|
+
|
115
|
+
|
116
|
+
static ngx_str_t event_core_name = ngx_string("event_core");
|
117
|
+
|
118
|
+
|
119
|
+
static ngx_command_t ngx_event_core_commands[] = {
|
120
|
+
|
121
|
+
{ ngx_string("worker_connections"),
|
122
|
+
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
123
|
+
ngx_event_connections,
|
124
|
+
0,
|
125
|
+
0,
|
126
|
+
NULL },
|
127
|
+
|
128
|
+
{ ngx_string("connections"),
|
129
|
+
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
130
|
+
ngx_event_connections,
|
131
|
+
0,
|
132
|
+
0,
|
133
|
+
NULL },
|
134
|
+
|
135
|
+
{ ngx_string("use"),
|
136
|
+
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
137
|
+
ngx_event_use,
|
138
|
+
0,
|
139
|
+
0,
|
140
|
+
NULL },
|
141
|
+
|
142
|
+
{ ngx_string("multi_accept"),
|
143
|
+
NGX_EVENT_CONF|NGX_CONF_FLAG,
|
144
|
+
ngx_conf_set_flag_slot,
|
145
|
+
0,
|
146
|
+
offsetof(ngx_event_conf_t, multi_accept),
|
147
|
+
NULL },
|
148
|
+
|
149
|
+
{ ngx_string("accept_mutex"),
|
150
|
+
NGX_EVENT_CONF|NGX_CONF_FLAG,
|
151
|
+
ngx_conf_set_flag_slot,
|
152
|
+
0,
|
153
|
+
offsetof(ngx_event_conf_t, accept_mutex),
|
154
|
+
NULL },
|
155
|
+
|
156
|
+
{ ngx_string("accept_mutex_delay"),
|
157
|
+
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
158
|
+
ngx_conf_set_msec_slot,
|
159
|
+
0,
|
160
|
+
offsetof(ngx_event_conf_t, accept_mutex_delay),
|
161
|
+
NULL },
|
162
|
+
|
163
|
+
{ ngx_string("debug_connection"),
|
164
|
+
NGX_EVENT_CONF|NGX_CONF_TAKE1,
|
165
|
+
ngx_event_debug_connection,
|
166
|
+
0,
|
167
|
+
0,
|
168
|
+
NULL },
|
169
|
+
|
170
|
+
ngx_null_command
|
171
|
+
};
|
172
|
+
|
173
|
+
|
174
|
+
ngx_event_module_t ngx_event_core_module_ctx = {
|
175
|
+
&event_core_name,
|
176
|
+
ngx_event_create_conf, /* create configuration */
|
177
|
+
ngx_event_init_conf, /* init configuration */
|
178
|
+
|
179
|
+
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
|
180
|
+
};
|
181
|
+
|
182
|
+
|
183
|
+
ngx_module_t ngx_event_core_module = {
|
184
|
+
NGX_MODULE_V1,
|
185
|
+
&ngx_event_core_module_ctx, /* module context */
|
186
|
+
ngx_event_core_commands, /* module directives */
|
187
|
+
NGX_EVENT_MODULE, /* module type */
|
188
|
+
NULL, /* init master */
|
189
|
+
ngx_event_module_init, /* init module */
|
190
|
+
ngx_event_process_init, /* init process */
|
191
|
+
NULL, /* init thread */
|
192
|
+
NULL, /* exit thread */
|
193
|
+
NULL, /* exit process */
|
194
|
+
NULL, /* exit master */
|
195
|
+
NGX_MODULE_V1_PADDING
|
196
|
+
};
|
197
|
+
|
198
|
+
|
199
|
+
void
|
200
|
+
ngx_process_events_and_timers(ngx_cycle_t *cycle)
|
201
|
+
{
|
202
|
+
ngx_uint_t flags;
|
203
|
+
ngx_msec_t timer, delta;
|
204
|
+
|
205
|
+
if (ngx_timer_resolution) {
|
206
|
+
timer = NGX_TIMER_INFINITE;
|
207
|
+
flags = 0;
|
208
|
+
|
209
|
+
} else {
|
210
|
+
timer = ngx_event_find_timer();
|
211
|
+
flags = NGX_UPDATE_TIME;
|
212
|
+
|
213
|
+
#if (NGX_THREADS)
|
214
|
+
|
215
|
+
if (timer == NGX_TIMER_INFINITE || timer > 500) {
|
216
|
+
timer = 500;
|
217
|
+
}
|
218
|
+
|
219
|
+
#endif
|
220
|
+
}
|
221
|
+
|
222
|
+
if (ngx_use_accept_mutex) {
|
223
|
+
if (ngx_accept_disabled > 0) {
|
224
|
+
ngx_accept_disabled--;
|
225
|
+
|
226
|
+
} else {
|
227
|
+
if (ngx_trylock_accept_mutex(cycle) == NGX_ERROR) {
|
228
|
+
return;
|
229
|
+
}
|
230
|
+
|
231
|
+
if (ngx_accept_mutex_held) {
|
232
|
+
flags |= NGX_POST_EVENTS;
|
233
|
+
|
234
|
+
} else {
|
235
|
+
if (timer == NGX_TIMER_INFINITE
|
236
|
+
|| timer > ngx_accept_mutex_delay)
|
237
|
+
{
|
238
|
+
timer = ngx_accept_mutex_delay;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
}
|
242
|
+
}
|
243
|
+
|
244
|
+
delta = ngx_current_msec;
|
245
|
+
|
246
|
+
(void) ngx_process_events(cycle, timer, flags);
|
247
|
+
|
248
|
+
delta = ngx_current_msec - delta;
|
249
|
+
|
250
|
+
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
251
|
+
"timer delta: %M", delta);
|
252
|
+
|
253
|
+
if (ngx_posted_accept_events) {
|
254
|
+
ngx_event_process_posted(cycle, &ngx_posted_accept_events);
|
255
|
+
}
|
256
|
+
|
257
|
+
if (ngx_accept_mutex_held) {
|
258
|
+
ngx_shmtx_unlock(&ngx_accept_mutex);
|
259
|
+
}
|
260
|
+
|
261
|
+
if (delta) {
|
262
|
+
ngx_event_expire_timers();
|
263
|
+
}
|
264
|
+
|
265
|
+
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
266
|
+
"posted events %p", ngx_posted_events);
|
267
|
+
|
268
|
+
if (ngx_posted_events) {
|
269
|
+
if (ngx_threaded) {
|
270
|
+
ngx_wakeup_worker_thread(cycle);
|
271
|
+
|
272
|
+
} else {
|
273
|
+
ngx_event_process_posted(cycle, &ngx_posted_events);
|
274
|
+
}
|
275
|
+
}
|
276
|
+
}
|
277
|
+
|
278
|
+
|
279
|
+
ngx_int_t
|
280
|
+
ngx_handle_read_event(ngx_event_t *rev, ngx_uint_t flags)
|
281
|
+
{
|
282
|
+
if (ngx_event_flags & NGX_USE_CLEAR_EVENT) {
|
283
|
+
|
284
|
+
/* kqueue, epoll */
|
285
|
+
|
286
|
+
if (!rev->active && !rev->ready) {
|
287
|
+
if (ngx_add_event(rev, NGX_READ_EVENT, NGX_CLEAR_EVENT)
|
288
|
+
== NGX_ERROR)
|
289
|
+
{
|
290
|
+
return NGX_ERROR;
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
return NGX_OK;
|
295
|
+
|
296
|
+
} else if (ngx_event_flags & NGX_USE_LEVEL_EVENT) {
|
297
|
+
|
298
|
+
/* select, poll, /dev/poll */
|
299
|
+
|
300
|
+
if (!rev->active && !rev->ready) {
|
301
|
+
if (ngx_add_event(rev, NGX_READ_EVENT, NGX_LEVEL_EVENT)
|
302
|
+
== NGX_ERROR)
|
303
|
+
{
|
304
|
+
return NGX_ERROR;
|
305
|
+
}
|
306
|
+
|
307
|
+
return NGX_OK;
|
308
|
+
}
|
309
|
+
|
310
|
+
if (rev->active && (rev->ready || (flags & NGX_CLOSE_EVENT))) {
|
311
|
+
if (ngx_del_event(rev, NGX_READ_EVENT, NGX_LEVEL_EVENT | flags)
|
312
|
+
== NGX_ERROR)
|
313
|
+
{
|
314
|
+
return NGX_ERROR;
|
315
|
+
}
|
316
|
+
|
317
|
+
return NGX_OK;
|
318
|
+
}
|
319
|
+
|
320
|
+
} else if (ngx_event_flags & NGX_USE_EVENTPORT_EVENT) {
|
321
|
+
|
322
|
+
/* event ports */
|
323
|
+
|
324
|
+
if (!rev->active && !rev->ready) {
|
325
|
+
if (ngx_add_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) {
|
326
|
+
return NGX_ERROR;
|
327
|
+
}
|
328
|
+
|
329
|
+
return NGX_OK;
|
330
|
+
}
|
331
|
+
|
332
|
+
if (rev->oneshot && !rev->ready) {
|
333
|
+
if (ngx_del_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) {
|
334
|
+
return NGX_ERROR;
|
335
|
+
}
|
336
|
+
|
337
|
+
return NGX_OK;
|
338
|
+
}
|
339
|
+
}
|
340
|
+
|
341
|
+
/* aio, iocp, rtsig */
|
342
|
+
|
343
|
+
return NGX_OK;
|
344
|
+
}
|
345
|
+
|
346
|
+
|
347
|
+
ngx_int_t
|
348
|
+
ngx_handle_write_event(ngx_event_t *wev, size_t lowat)
|
349
|
+
{
|
350
|
+
ngx_connection_t *c;
|
351
|
+
|
352
|
+
if (lowat) {
|
353
|
+
c = wev->data;
|
354
|
+
|
355
|
+
if (ngx_send_lowat(c, lowat) == NGX_ERROR) {
|
356
|
+
return NGX_ERROR;
|
357
|
+
}
|
358
|
+
}
|
359
|
+
|
360
|
+
if (ngx_event_flags & NGX_USE_CLEAR_EVENT) {
|
361
|
+
|
362
|
+
/* kqueue, epoll */
|
363
|
+
|
364
|
+
if (!wev->active && !wev->ready) {
|
365
|
+
if (ngx_add_event(wev, NGX_WRITE_EVENT,
|
366
|
+
NGX_CLEAR_EVENT | (lowat ? NGX_LOWAT_EVENT : 0))
|
367
|
+
== NGX_ERROR)
|
368
|
+
{
|
369
|
+
return NGX_ERROR;
|
370
|
+
}
|
371
|
+
}
|
372
|
+
|
373
|
+
return NGX_OK;
|
374
|
+
|
375
|
+
} else if (ngx_event_flags & NGX_USE_LEVEL_EVENT) {
|
376
|
+
|
377
|
+
/* select, poll, /dev/poll */
|
378
|
+
|
379
|
+
if (!wev->active && !wev->ready) {
|
380
|
+
if (ngx_add_event(wev, NGX_WRITE_EVENT, NGX_LEVEL_EVENT)
|
381
|
+
== NGX_ERROR)
|
382
|
+
{
|
383
|
+
return NGX_ERROR;
|
384
|
+
}
|
385
|
+
|
386
|
+
return NGX_OK;
|
387
|
+
}
|
388
|
+
|
389
|
+
if (wev->active && wev->ready) {
|
390
|
+
if (ngx_del_event(wev, NGX_WRITE_EVENT, NGX_LEVEL_EVENT)
|
391
|
+
== NGX_ERROR)
|
392
|
+
{
|
393
|
+
return NGX_ERROR;
|
394
|
+
}
|
395
|
+
|
396
|
+
return NGX_OK;
|
397
|
+
}
|
398
|
+
|
399
|
+
} else if (ngx_event_flags & NGX_USE_EVENTPORT_EVENT) {
|
400
|
+
|
401
|
+
/* event ports */
|
402
|
+
|
403
|
+
if (!wev->active && !wev->ready) {
|
404
|
+
if (ngx_add_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) {
|
405
|
+
return NGX_ERROR;
|
406
|
+
}
|
407
|
+
|
408
|
+
return NGX_OK;
|
409
|
+
}
|
410
|
+
|
411
|
+
if (wev->oneshot && wev->ready) {
|
412
|
+
if (ngx_del_event(wev, NGX_WRITE_EVENT, 0) == NGX_ERROR) {
|
413
|
+
return NGX_ERROR;
|
414
|
+
}
|
415
|
+
|
416
|
+
return NGX_OK;
|
417
|
+
}
|
418
|
+
}
|
419
|
+
|
420
|
+
/* aio, iocp, rtsig */
|
421
|
+
|
422
|
+
return NGX_OK;
|
423
|
+
}
|
424
|
+
|
425
|
+
|
426
|
+
static ngx_int_t
|
427
|
+
ngx_event_module_init(ngx_cycle_t *cycle)
|
428
|
+
{
|
429
|
+
void ***cf;
|
430
|
+
u_char *shared;
|
431
|
+
size_t size, cl;
|
432
|
+
ngx_shm_t shm;
|
433
|
+
ngx_time_t *tp;
|
434
|
+
ngx_core_conf_t *ccf;
|
435
|
+
ngx_event_conf_t *ecf;
|
436
|
+
|
437
|
+
cf = ngx_get_conf(cycle->conf_ctx, ngx_events_module);
|
438
|
+
|
439
|
+
if (cf == NULL) {
|
440
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
|
441
|
+
"no \"events\" section in configuration");
|
442
|
+
return NGX_ERROR;
|
443
|
+
}
|
444
|
+
|
445
|
+
ecf = (*cf)[ngx_event_core_module.ctx_index];
|
446
|
+
|
447
|
+
if (!ngx_test_config && ngx_process <= NGX_PROCESS_MASTER) {
|
448
|
+
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0,
|
449
|
+
"using the \"%s\" event method", ecf->name);
|
450
|
+
}
|
451
|
+
|
452
|
+
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
453
|
+
|
454
|
+
ngx_timer_resolution = ccf->timer_resolution;
|
455
|
+
|
456
|
+
#if !(NGX_WIN32)
|
457
|
+
{
|
458
|
+
ngx_int_t limit;
|
459
|
+
struct rlimit rlmt;
|
460
|
+
|
461
|
+
if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
|
462
|
+
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
463
|
+
"getrlimit(RLIMIT_NOFILE) failed, ignored");
|
464
|
+
|
465
|
+
} else {
|
466
|
+
if (ecf->connections > (ngx_uint_t) rlmt.rlim_cur
|
467
|
+
&& (ccf->rlimit_nofile == NGX_CONF_UNSET
|
468
|
+
|| ecf->connections > (ngx_uint_t) ccf->rlimit_nofile))
|
469
|
+
{
|
470
|
+
limit = (ccf->rlimit_nofile == NGX_CONF_UNSET) ?
|
471
|
+
(ngx_int_t) rlmt.rlim_cur : ccf->rlimit_nofile;
|
472
|
+
|
473
|
+
ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
|
474
|
+
"%ui worker_connections are more than "
|
475
|
+
"open file resource limit: %i",
|
476
|
+
ecf->connections, limit);
|
477
|
+
}
|
478
|
+
}
|
479
|
+
}
|
480
|
+
#endif /* !(NGX_WIN32) */
|
481
|
+
|
482
|
+
|
483
|
+
if (ccf->master == 0) {
|
484
|
+
return NGX_OK;
|
485
|
+
}
|
486
|
+
|
487
|
+
if (ngx_accept_mutex_ptr) {
|
488
|
+
return NGX_OK;
|
489
|
+
}
|
490
|
+
|
491
|
+
|
492
|
+
/* cl should be equal or bigger than cache line size */
|
493
|
+
|
494
|
+
cl = 128;
|
495
|
+
|
496
|
+
size = cl /* ngx_accept_mutex */
|
497
|
+
+ cl /* ngx_connection_counter */
|
498
|
+
+ cl; /* ngx_temp_number */
|
499
|
+
|
500
|
+
#if (NGX_STAT_STUB)
|
501
|
+
|
502
|
+
size += cl /* ngx_stat_accepted */
|
503
|
+
+ cl /* ngx_stat_handled */
|
504
|
+
+ cl /* ngx_stat_requests */
|
505
|
+
+ cl /* ngx_stat_active */
|
506
|
+
+ cl /* ngx_stat_reading */
|
507
|
+
+ cl; /* ngx_stat_writing */
|
508
|
+
|
509
|
+
#endif
|
510
|
+
|
511
|
+
shm.size = size;
|
512
|
+
shm.name.len = sizeof("nginx_shared_zone");
|
513
|
+
shm.name.data = (u_char *) "nginx_shared_zone";
|
514
|
+
shm.log = cycle->log;
|
515
|
+
|
516
|
+
if (ngx_shm_alloc(&shm) != NGX_OK) {
|
517
|
+
return NGX_ERROR;
|
518
|
+
}
|
519
|
+
|
520
|
+
shared = shm.addr;
|
521
|
+
|
522
|
+
ngx_accept_mutex_ptr = (ngx_atomic_t *) shared;
|
523
|
+
ngx_accept_mutex.spin = (ngx_uint_t) -1;
|
524
|
+
|
525
|
+
if (ngx_shmtx_create(&ngx_accept_mutex, shared, cycle->lock_file.data)
|
526
|
+
!= NGX_OK)
|
527
|
+
{
|
528
|
+
return NGX_ERROR;
|
529
|
+
}
|
530
|
+
|
531
|
+
ngx_connection_counter = (ngx_atomic_t *) (shared + 1 * cl);
|
532
|
+
|
533
|
+
(void) ngx_atomic_cmp_set(ngx_connection_counter, 0, 1);
|
534
|
+
|
535
|
+
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
536
|
+
"counter: %p, %d",
|
537
|
+
ngx_connection_counter, *ngx_connection_counter);
|
538
|
+
|
539
|
+
ngx_temp_number = (ngx_atomic_t *) (shared + 2 * cl);
|
540
|
+
|
541
|
+
tp = ngx_timeofday();
|
542
|
+
|
543
|
+
ngx_random_number = (tp->msec << 16) + ngx_pid;
|
544
|
+
|
545
|
+
#if (NGX_STAT_STUB)
|
546
|
+
|
547
|
+
ngx_stat_accepted = (ngx_atomic_t *) (shared + 3 * cl);
|
548
|
+
ngx_stat_handled = (ngx_atomic_t *) (shared + 4 * cl);
|
549
|
+
ngx_stat_requests = (ngx_atomic_t *) (shared + 5 * cl);
|
550
|
+
ngx_stat_active = (ngx_atomic_t *) (shared + 6 * cl);
|
551
|
+
ngx_stat_reading = (ngx_atomic_t *) (shared + 7 * cl);
|
552
|
+
ngx_stat_writing = (ngx_atomic_t *) (shared + 8 * cl);
|
553
|
+
|
554
|
+
#endif
|
555
|
+
|
556
|
+
return NGX_OK;
|
557
|
+
}
|
558
|
+
|
559
|
+
|
560
|
+
#if !(NGX_WIN32)
|
561
|
+
|
562
|
+
void
|
563
|
+
ngx_timer_signal_handler(int signo)
|
564
|
+
{
|
565
|
+
ngx_event_timer_alarm = 1;
|
566
|
+
|
567
|
+
#if 1
|
568
|
+
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ngx_cycle->log, 0, "timer signal");
|
569
|
+
#endif
|
570
|
+
}
|
571
|
+
|
572
|
+
#endif
|
573
|
+
|
574
|
+
|
575
|
+
static ngx_int_t
|
576
|
+
ngx_event_process_init(ngx_cycle_t *cycle)
|
577
|
+
{
|
578
|
+
ngx_uint_t m, i;
|
579
|
+
ngx_event_t *rev, *wev;
|
580
|
+
ngx_listening_t *ls;
|
581
|
+
ngx_connection_t *c, *next, *old;
|
582
|
+
ngx_core_conf_t *ccf;
|
583
|
+
ngx_event_conf_t *ecf;
|
584
|
+
ngx_event_module_t *module;
|
585
|
+
|
586
|
+
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
587
|
+
ecf = ngx_event_get_conf(cycle->conf_ctx, ngx_event_core_module);
|
588
|
+
|
589
|
+
if (ccf->master && ccf->worker_processes > 1 && ecf->accept_mutex) {
|
590
|
+
ngx_use_accept_mutex = 1;
|
591
|
+
ngx_accept_mutex_held = 0;
|
592
|
+
ngx_accept_mutex_delay = ecf->accept_mutex_delay;
|
593
|
+
|
594
|
+
} else {
|
595
|
+
ngx_use_accept_mutex = 0;
|
596
|
+
}
|
597
|
+
|
598
|
+
#if (NGX_THREADS)
|
599
|
+
ngx_posted_events_mutex = ngx_mutex_init(cycle->log, 0);
|
600
|
+
if (ngx_posted_events_mutex == NULL) {
|
601
|
+
return NGX_ERROR;
|
602
|
+
}
|
603
|
+
#endif
|
604
|
+
|
605
|
+
if (ngx_event_timer_init(cycle->log) == NGX_ERROR) {
|
606
|
+
return NGX_ERROR;
|
607
|
+
}
|
608
|
+
|
609
|
+
for (m = 0; ngx_modules[m]; m++) {
|
610
|
+
if (ngx_modules[m]->type != NGX_EVENT_MODULE) {
|
611
|
+
continue;
|
612
|
+
}
|
613
|
+
|
614
|
+
if (ngx_modules[m]->ctx_index != ecf->use) {
|
615
|
+
continue;
|
616
|
+
}
|
617
|
+
|
618
|
+
module = ngx_modules[m]->ctx;
|
619
|
+
|
620
|
+
if (module->actions.init(cycle, ngx_timer_resolution) != NGX_OK) {
|
621
|
+
/* fatal */
|
622
|
+
exit(2);
|
623
|
+
}
|
624
|
+
|
625
|
+
break;
|
626
|
+
}
|
627
|
+
|
628
|
+
#if !(NGX_WIN32)
|
629
|
+
|
630
|
+
if (ngx_timer_resolution && !(ngx_event_flags & NGX_USE_TIMER_EVENT)) {
|
631
|
+
struct sigaction sa;
|
632
|
+
struct itimerval itv;
|
633
|
+
|
634
|
+
ngx_memzero(&sa, sizeof(struct sigaction));
|
635
|
+
sa.sa_handler = ngx_timer_signal_handler;
|
636
|
+
sigemptyset(&sa.sa_mask);
|
637
|
+
|
638
|
+
if (sigaction(SIGALRM, &sa, NULL) == -1) {
|
639
|
+
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
640
|
+
"sigaction(SIGALRM) failed");
|
641
|
+
return NGX_ERROR;
|
642
|
+
}
|
643
|
+
|
644
|
+
itv.it_interval.tv_sec = ngx_timer_resolution / 1000;
|
645
|
+
itv.it_interval.tv_usec = (ngx_timer_resolution % 1000) * 1000;
|
646
|
+
itv.it_value.tv_sec = ngx_timer_resolution / 1000;
|
647
|
+
itv.it_value.tv_usec = (ngx_timer_resolution % 1000 ) * 1000;
|
648
|
+
|
649
|
+
if (setitimer(ITIMER_REAL, &itv, NULL) == -1) {
|
650
|
+
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
651
|
+
"setitimer() failed");
|
652
|
+
}
|
653
|
+
}
|
654
|
+
|
655
|
+
if (ngx_event_flags & NGX_USE_FD_EVENT) {
|
656
|
+
struct rlimit rlmt;
|
657
|
+
|
658
|
+
if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
|
659
|
+
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
660
|
+
"getrlimit(RLIMIT_NOFILE) failed");
|
661
|
+
return NGX_ERROR;
|
662
|
+
}
|
663
|
+
|
664
|
+
cycle->files_n = (ngx_uint_t) rlmt.rlim_cur;
|
665
|
+
|
666
|
+
cycle->files = ngx_calloc(sizeof(ngx_connection_t *) * cycle->files_n,
|
667
|
+
cycle->log);
|
668
|
+
if (cycle->files == NULL) {
|
669
|
+
return NGX_ERROR;
|
670
|
+
}
|
671
|
+
}
|
672
|
+
|
673
|
+
#endif
|
674
|
+
|
675
|
+
cycle->connections =
|
676
|
+
ngx_alloc(sizeof(ngx_connection_t) * cycle->connection_n, cycle->log);
|
677
|
+
if (cycle->connections == NULL) {
|
678
|
+
return NGX_ERROR;
|
679
|
+
}
|
680
|
+
|
681
|
+
c = cycle->connections;
|
682
|
+
|
683
|
+
cycle->read_events = ngx_alloc(sizeof(ngx_event_t) * cycle->connection_n,
|
684
|
+
cycle->log);
|
685
|
+
if (cycle->read_events == NULL) {
|
686
|
+
return NGX_ERROR;
|
687
|
+
}
|
688
|
+
|
689
|
+
rev = cycle->read_events;
|
690
|
+
for (i = 0; i < cycle->connection_n; i++) {
|
691
|
+
rev[i].closed = 1;
|
692
|
+
rev[i].instance = 1;
|
693
|
+
#if (NGX_THREADS)
|
694
|
+
rev[i].lock = &c[i].lock;
|
695
|
+
rev[i].own_lock = &c[i].lock;
|
696
|
+
#endif
|
697
|
+
}
|
698
|
+
|
699
|
+
cycle->write_events = ngx_alloc(sizeof(ngx_event_t) * cycle->connection_n,
|
700
|
+
cycle->log);
|
701
|
+
if (cycle->write_events == NULL) {
|
702
|
+
return NGX_ERROR;
|
703
|
+
}
|
704
|
+
|
705
|
+
wev = cycle->write_events;
|
706
|
+
for (i = 0; i < cycle->connection_n; i++) {
|
707
|
+
wev[i].closed = 1;
|
708
|
+
#if (NGX_THREADS)
|
709
|
+
wev[i].lock = &c[i].lock;
|
710
|
+
wev[i].own_lock = &c[i].lock;
|
711
|
+
#endif
|
712
|
+
}
|
713
|
+
|
714
|
+
i = cycle->connection_n;
|
715
|
+
next = NULL;
|
716
|
+
|
717
|
+
do {
|
718
|
+
i--;
|
719
|
+
|
720
|
+
c[i].data = next;
|
721
|
+
c[i].read = &cycle->read_events[i];
|
722
|
+
c[i].write = &cycle->write_events[i];
|
723
|
+
c[i].fd = (ngx_socket_t) -1;
|
724
|
+
|
725
|
+
next = &c[i];
|
726
|
+
|
727
|
+
#if (NGX_THREADS)
|
728
|
+
c[i].lock = 0;
|
729
|
+
#endif
|
730
|
+
} while (i);
|
731
|
+
|
732
|
+
cycle->free_connections = next;
|
733
|
+
cycle->free_connection_n = cycle->connection_n;
|
734
|
+
|
735
|
+
/* for each listening socket */
|
736
|
+
|
737
|
+
ls = cycle->listening.elts;
|
738
|
+
for (i = 0; i < cycle->listening.nelts; i++) {
|
739
|
+
|
740
|
+
c = ngx_get_connection(ls[i].fd, cycle->log);
|
741
|
+
|
742
|
+
if (c == NULL) {
|
743
|
+
return NGX_ERROR;
|
744
|
+
}
|
745
|
+
|
746
|
+
c->log = &ls[i].log;
|
747
|
+
|
748
|
+
c->listening = &ls[i];
|
749
|
+
ls[i].connection = c;
|
750
|
+
|
751
|
+
rev = c->read;
|
752
|
+
|
753
|
+
rev->log = c->log;
|
754
|
+
rev->accept = 1;
|
755
|
+
|
756
|
+
#if (NGX_HAVE_DEFERRED_ACCEPT)
|
757
|
+
rev->deferred_accept = ls[i].deferred_accept;
|
758
|
+
#endif
|
759
|
+
|
760
|
+
if (!(ngx_event_flags & NGX_USE_IOCP_EVENT)) {
|
761
|
+
if (ls[i].previous) {
|
762
|
+
|
763
|
+
/*
|
764
|
+
* delete the old accept events that were bound to
|
765
|
+
* the old cycle read events array
|
766
|
+
*/
|
767
|
+
|
768
|
+
old = ls[i].previous->connection;
|
769
|
+
|
770
|
+
if (ngx_del_event(old->read, NGX_READ_EVENT, NGX_CLOSE_EVENT)
|
771
|
+
== NGX_ERROR)
|
772
|
+
{
|
773
|
+
return NGX_ERROR;
|
774
|
+
}
|
775
|
+
|
776
|
+
old->fd = (ngx_socket_t) -1;
|
777
|
+
}
|
778
|
+
}
|
779
|
+
|
780
|
+
#if (NGX_WIN32)
|
781
|
+
|
782
|
+
if (ngx_event_flags & NGX_USE_IOCP_EVENT) {
|
783
|
+
ngx_iocp_conf_t *iocpcf;
|
784
|
+
|
785
|
+
rev->handler = ngx_event_acceptex;
|
786
|
+
|
787
|
+
if (ngx_use_accept_mutex) {
|
788
|
+
continue;
|
789
|
+
}
|
790
|
+
|
791
|
+
if (ngx_add_event(rev, 0, NGX_IOCP_ACCEPT) == NGX_ERROR) {
|
792
|
+
return NGX_ERROR;
|
793
|
+
}
|
794
|
+
|
795
|
+
ls[i].log.handler = ngx_acceptex_log_error;
|
796
|
+
|
797
|
+
iocpcf = ngx_event_get_conf(cycle->conf_ctx, ngx_iocp_module);
|
798
|
+
if (ngx_event_post_acceptex(&ls[i], iocpcf->post_acceptex)
|
799
|
+
== NGX_ERROR)
|
800
|
+
{
|
801
|
+
return NGX_ERROR;
|
802
|
+
}
|
803
|
+
|
804
|
+
} else {
|
805
|
+
rev->handler = ngx_event_accept;
|
806
|
+
|
807
|
+
if (ngx_use_accept_mutex) {
|
808
|
+
continue;
|
809
|
+
}
|
810
|
+
|
811
|
+
if (ngx_add_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) {
|
812
|
+
return NGX_ERROR;
|
813
|
+
}
|
814
|
+
}
|
815
|
+
|
816
|
+
#else
|
817
|
+
|
818
|
+
rev->handler = ngx_event_accept;
|
819
|
+
|
820
|
+
if (ngx_use_accept_mutex) {
|
821
|
+
continue;
|
822
|
+
}
|
823
|
+
|
824
|
+
if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
|
825
|
+
if (ngx_add_conn(c) == NGX_ERROR) {
|
826
|
+
return NGX_ERROR;
|
827
|
+
}
|
828
|
+
|
829
|
+
} else {
|
830
|
+
if (ngx_add_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) {
|
831
|
+
return NGX_ERROR;
|
832
|
+
}
|
833
|
+
}
|
834
|
+
|
835
|
+
#endif
|
836
|
+
|
837
|
+
}
|
838
|
+
|
839
|
+
return NGX_OK;
|
840
|
+
}
|
841
|
+
|
842
|
+
|
843
|
+
ngx_int_t
|
844
|
+
ngx_send_lowat(ngx_connection_t *c, size_t lowat)
|
845
|
+
{
|
846
|
+
int sndlowat;
|
847
|
+
|
848
|
+
#if (NGX_HAVE_LOWAT_EVENT)
|
849
|
+
|
850
|
+
if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
|
851
|
+
c->write->available = lowat;
|
852
|
+
return NGX_OK;
|
853
|
+
}
|
854
|
+
|
855
|
+
#endif
|
856
|
+
|
857
|
+
if (lowat == 0 || c->sndlowat) {
|
858
|
+
return NGX_OK;
|
859
|
+
}
|
860
|
+
|
861
|
+
sndlowat = (int) lowat;
|
862
|
+
|
863
|
+
if (setsockopt(c->fd, SOL_SOCKET, SO_SNDLOWAT,
|
864
|
+
(const void *) &sndlowat, sizeof(int))
|
865
|
+
== -1)
|
866
|
+
{
|
867
|
+
ngx_connection_error(c, ngx_socket_errno,
|
868
|
+
"setsockopt(SO_SNDLOWAT) failed");
|
869
|
+
return NGX_ERROR;
|
870
|
+
}
|
871
|
+
|
872
|
+
c->sndlowat = 1;
|
873
|
+
|
874
|
+
return NGX_OK;
|
875
|
+
}
|
876
|
+
|
877
|
+
|
878
|
+
static char *
|
879
|
+
ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
880
|
+
{
|
881
|
+
char *rv;
|
882
|
+
void ***ctx;
|
883
|
+
ngx_uint_t i;
|
884
|
+
ngx_conf_t pcf;
|
885
|
+
ngx_event_module_t *m;
|
886
|
+
|
887
|
+
/* count the number of the event modules and set up their indices */
|
888
|
+
|
889
|
+
ngx_event_max_module = 0;
|
890
|
+
for (i = 0; ngx_modules[i]; i++) {
|
891
|
+
if (ngx_modules[i]->type != NGX_EVENT_MODULE) {
|
892
|
+
continue;
|
893
|
+
}
|
894
|
+
|
895
|
+
ngx_modules[i]->ctx_index = ngx_event_max_module++;
|
896
|
+
}
|
897
|
+
|
898
|
+
ctx = ngx_pcalloc(cf->pool, sizeof(void *));
|
899
|
+
if (ctx == NULL) {
|
900
|
+
return NGX_CONF_ERROR;
|
901
|
+
}
|
902
|
+
|
903
|
+
*ctx = ngx_pcalloc(cf->pool, ngx_event_max_module * sizeof(void *));
|
904
|
+
if (*ctx == NULL) {
|
905
|
+
return NGX_CONF_ERROR;
|
906
|
+
}
|
907
|
+
|
908
|
+
*(void **) conf = ctx;
|
909
|
+
|
910
|
+
for (i = 0; ngx_modules[i]; i++) {
|
911
|
+
if (ngx_modules[i]->type != NGX_EVENT_MODULE) {
|
912
|
+
continue;
|
913
|
+
}
|
914
|
+
|
915
|
+
m = ngx_modules[i]->ctx;
|
916
|
+
|
917
|
+
if (m->create_conf) {
|
918
|
+
(*ctx)[ngx_modules[i]->ctx_index] = m->create_conf(cf->cycle);
|
919
|
+
if ((*ctx)[ngx_modules[i]->ctx_index] == NULL) {
|
920
|
+
return NGX_CONF_ERROR;
|
921
|
+
}
|
922
|
+
}
|
923
|
+
}
|
924
|
+
|
925
|
+
pcf = *cf;
|
926
|
+
cf->ctx = ctx;
|
927
|
+
cf->module_type = NGX_EVENT_MODULE;
|
928
|
+
cf->cmd_type = NGX_EVENT_CONF;
|
929
|
+
|
930
|
+
rv = ngx_conf_parse(cf, NULL);
|
931
|
+
|
932
|
+
*cf = pcf;
|
933
|
+
|
934
|
+
if (rv != NGX_CONF_OK)
|
935
|
+
return rv;
|
936
|
+
|
937
|
+
for (i = 0; ngx_modules[i]; i++) {
|
938
|
+
if (ngx_modules[i]->type != NGX_EVENT_MODULE) {
|
939
|
+
continue;
|
940
|
+
}
|
941
|
+
|
942
|
+
m = ngx_modules[i]->ctx;
|
943
|
+
|
944
|
+
if (m->init_conf) {
|
945
|
+
rv = m->init_conf(cf->cycle, (*ctx)[ngx_modules[i]->ctx_index]);
|
946
|
+
if (rv != NGX_CONF_OK) {
|
947
|
+
return rv;
|
948
|
+
}
|
949
|
+
}
|
950
|
+
}
|
951
|
+
|
952
|
+
return NGX_CONF_OK;
|
953
|
+
}
|
954
|
+
|
955
|
+
|
956
|
+
static char *
|
957
|
+
ngx_event_connections(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
958
|
+
{
|
959
|
+
ngx_event_conf_t *ecf = conf;
|
960
|
+
|
961
|
+
ngx_str_t *value;
|
962
|
+
|
963
|
+
if (ecf->connections != NGX_CONF_UNSET_UINT) {
|
964
|
+
return "is duplicate";
|
965
|
+
}
|
966
|
+
|
967
|
+
if (ngx_strcmp(cmd->name.data, "connections") == 0) {
|
968
|
+
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
969
|
+
"the \"connections\" directive is deprecated, "
|
970
|
+
"use the \"worker_connections\" directive instead");
|
971
|
+
}
|
972
|
+
|
973
|
+
value = cf->args->elts;
|
974
|
+
ecf->connections = ngx_atoi(value[1].data, value[1].len);
|
975
|
+
if (ecf->connections == (ngx_uint_t) NGX_ERROR) {
|
976
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
977
|
+
"invalid number \"%V\"", &value[1]);
|
978
|
+
|
979
|
+
return NGX_CONF_ERROR;
|
980
|
+
}
|
981
|
+
|
982
|
+
cf->cycle->connection_n = ecf->connections;
|
983
|
+
|
984
|
+
return NGX_CONF_OK;
|
985
|
+
}
|
986
|
+
|
987
|
+
|
988
|
+
static char *
|
989
|
+
ngx_event_use(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
990
|
+
{
|
991
|
+
ngx_event_conf_t *ecf = conf;
|
992
|
+
|
993
|
+
ngx_int_t m;
|
994
|
+
ngx_str_t *value;
|
995
|
+
ngx_event_conf_t *old_ecf;
|
996
|
+
ngx_event_module_t *module;
|
997
|
+
|
998
|
+
if (ecf->use != NGX_CONF_UNSET_UINT) {
|
999
|
+
return "is duplicate";
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
value = cf->args->elts;
|
1003
|
+
|
1004
|
+
if (cf->cycle->old_cycle->conf_ctx) {
|
1005
|
+
old_ecf = ngx_event_get_conf(cf->cycle->old_cycle->conf_ctx,
|
1006
|
+
ngx_event_core_module);
|
1007
|
+
} else {
|
1008
|
+
old_ecf = NULL;
|
1009
|
+
}
|
1010
|
+
|
1011
|
+
|
1012
|
+
for (m = 0; ngx_modules[m]; m++) {
|
1013
|
+
if (ngx_modules[m]->type != NGX_EVENT_MODULE) {
|
1014
|
+
continue;
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
module = ngx_modules[m]->ctx;
|
1018
|
+
if (module->name->len == value[1].len) {
|
1019
|
+
if (ngx_strcmp(module->name->data, value[1].data) == 0) {
|
1020
|
+
ecf->use = ngx_modules[m]->ctx_index;
|
1021
|
+
ecf->name = module->name->data;
|
1022
|
+
|
1023
|
+
if (ngx_process == NGX_PROCESS_SINGLE
|
1024
|
+
&& old_ecf
|
1025
|
+
&& old_ecf->use != ecf->use)
|
1026
|
+
{
|
1027
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1028
|
+
"when the server runs without a master process "
|
1029
|
+
"the \"%V\" event type must be the same as "
|
1030
|
+
"in previous configuration - \"%s\" "
|
1031
|
+
"and it cannot be changed on the fly, "
|
1032
|
+
"to change it you need to stop server "
|
1033
|
+
"and start it again",
|
1034
|
+
&value[1], old_ecf->name);
|
1035
|
+
|
1036
|
+
return NGX_CONF_ERROR;
|
1037
|
+
}
|
1038
|
+
|
1039
|
+
return NGX_CONF_OK;
|
1040
|
+
}
|
1041
|
+
}
|
1042
|
+
}
|
1043
|
+
|
1044
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1045
|
+
"invalid event type \"%V\"", &value[1]);
|
1046
|
+
|
1047
|
+
return NGX_CONF_ERROR;
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
|
1051
|
+
static char *
|
1052
|
+
ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
1053
|
+
{
|
1054
|
+
#if (NGX_DEBUG)
|
1055
|
+
ngx_event_conf_t *ecf = conf;
|
1056
|
+
|
1057
|
+
ngx_int_t rc;
|
1058
|
+
ngx_str_t *value;
|
1059
|
+
ngx_event_debug_t *dc;
|
1060
|
+
struct hostent *h;
|
1061
|
+
ngx_cidr_t cidr;
|
1062
|
+
|
1063
|
+
value = cf->args->elts;
|
1064
|
+
|
1065
|
+
dc = ngx_array_push(&ecf->debug_connection);
|
1066
|
+
if (dc == NULL) {
|
1067
|
+
return NGX_CONF_ERROR;
|
1068
|
+
}
|
1069
|
+
|
1070
|
+
rc = ngx_ptocidr(&value[1], &cidr);
|
1071
|
+
|
1072
|
+
if (rc == NGX_DONE) {
|
1073
|
+
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
1074
|
+
"low address bits of %V are meaningless", &value[1]);
|
1075
|
+
rc = NGX_OK;
|
1076
|
+
}
|
1077
|
+
|
1078
|
+
if (rc == NGX_OK) {
|
1079
|
+
|
1080
|
+
/* AF_INET only */
|
1081
|
+
|
1082
|
+
if (cidr.family != AF_INET) {
|
1083
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1084
|
+
"\"debug_connection\" supports IPv4 only");
|
1085
|
+
return NGX_CONF_ERROR;
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
dc->mask = cidr.u.in.mask;
|
1089
|
+
dc->addr = cidr.u.in.addr;
|
1090
|
+
|
1091
|
+
return NGX_CONF_OK;
|
1092
|
+
}
|
1093
|
+
|
1094
|
+
h = gethostbyname((char *) value[1].data);
|
1095
|
+
|
1096
|
+
if (h == NULL || h->h_addr_list[0] == NULL) {
|
1097
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1098
|
+
"host \"%s\" not found", value[1].data);
|
1099
|
+
return NGX_CONF_ERROR;
|
1100
|
+
}
|
1101
|
+
|
1102
|
+
dc->mask = 0xffffffff;
|
1103
|
+
dc->addr = *(in_addr_t *)(h->h_addr_list[0]);
|
1104
|
+
|
1105
|
+
#else
|
1106
|
+
|
1107
|
+
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
1108
|
+
"\"debug_connection\" is ignored, you need to rebuild "
|
1109
|
+
"nginx using --with-debug option to enable it");
|
1110
|
+
|
1111
|
+
#endif
|
1112
|
+
|
1113
|
+
return NGX_CONF_OK;
|
1114
|
+
}
|
1115
|
+
|
1116
|
+
|
1117
|
+
static void *
|
1118
|
+
ngx_event_create_conf(ngx_cycle_t *cycle)
|
1119
|
+
{
|
1120
|
+
ngx_event_conf_t *ecf;
|
1121
|
+
|
1122
|
+
ecf = ngx_palloc(cycle->pool, sizeof(ngx_event_conf_t));
|
1123
|
+
if (ecf == NULL) {
|
1124
|
+
return NULL;
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
ecf->connections = NGX_CONF_UNSET_UINT;
|
1128
|
+
ecf->use = NGX_CONF_UNSET_UINT;
|
1129
|
+
ecf->multi_accept = NGX_CONF_UNSET;
|
1130
|
+
ecf->accept_mutex = NGX_CONF_UNSET;
|
1131
|
+
ecf->accept_mutex_delay = NGX_CONF_UNSET_MSEC;
|
1132
|
+
ecf->name = (void *) NGX_CONF_UNSET;
|
1133
|
+
|
1134
|
+
#if (NGX_DEBUG)
|
1135
|
+
|
1136
|
+
if (ngx_array_init(&ecf->debug_connection, cycle->pool, 4,
|
1137
|
+
sizeof(ngx_event_debug_t)) == NGX_ERROR)
|
1138
|
+
{
|
1139
|
+
return NULL;
|
1140
|
+
}
|
1141
|
+
|
1142
|
+
#endif
|
1143
|
+
|
1144
|
+
return ecf;
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
|
1148
|
+
static char *
|
1149
|
+
ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
|
1150
|
+
{
|
1151
|
+
ngx_event_conf_t *ecf = conf;
|
1152
|
+
|
1153
|
+
#if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL)
|
1154
|
+
int fd;
|
1155
|
+
#endif
|
1156
|
+
#if (NGX_HAVE_RTSIG)
|
1157
|
+
ngx_uint_t rtsig;
|
1158
|
+
ngx_core_conf_t *ccf;
|
1159
|
+
#endif
|
1160
|
+
ngx_int_t i;
|
1161
|
+
ngx_module_t *module;
|
1162
|
+
ngx_event_module_t *event_module;
|
1163
|
+
|
1164
|
+
module = NULL;
|
1165
|
+
|
1166
|
+
#if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL)
|
1167
|
+
|
1168
|
+
fd = epoll_create(100);
|
1169
|
+
|
1170
|
+
if (fd != -1) {
|
1171
|
+
close(fd);
|
1172
|
+
module = &ngx_epoll_module;
|
1173
|
+
|
1174
|
+
} else if (ngx_errno != NGX_ENOSYS) {
|
1175
|
+
module = &ngx_epoll_module;
|
1176
|
+
}
|
1177
|
+
|
1178
|
+
#endif
|
1179
|
+
|
1180
|
+
#if (NGX_HAVE_RTSIG)
|
1181
|
+
|
1182
|
+
if (module == NULL) {
|
1183
|
+
module = &ngx_rtsig_module;
|
1184
|
+
rtsig = 1;
|
1185
|
+
|
1186
|
+
} else {
|
1187
|
+
rtsig = 0;
|
1188
|
+
}
|
1189
|
+
|
1190
|
+
#endif
|
1191
|
+
|
1192
|
+
#if (NGX_HAVE_DEVPOLL)
|
1193
|
+
|
1194
|
+
module = &ngx_devpoll_module;
|
1195
|
+
|
1196
|
+
#endif
|
1197
|
+
|
1198
|
+
#if (NGX_HAVE_KQUEUE)
|
1199
|
+
|
1200
|
+
module = &ngx_kqueue_module;
|
1201
|
+
|
1202
|
+
#endif
|
1203
|
+
|
1204
|
+
#if (NGX_HAVE_SELECT)
|
1205
|
+
|
1206
|
+
if (module == NULL) {
|
1207
|
+
module = &ngx_select_module;
|
1208
|
+
}
|
1209
|
+
|
1210
|
+
#endif
|
1211
|
+
|
1212
|
+
if (module == NULL) {
|
1213
|
+
for (i = 0; ngx_modules[i]; i++) {
|
1214
|
+
|
1215
|
+
if (ngx_modules[i]->type != NGX_EVENT_MODULE) {
|
1216
|
+
continue;
|
1217
|
+
}
|
1218
|
+
|
1219
|
+
event_module = ngx_modules[i]->ctx;
|
1220
|
+
|
1221
|
+
if (ngx_strcmp(event_module->name->data, event_core_name.data) == 0)
|
1222
|
+
{
|
1223
|
+
continue;
|
1224
|
+
}
|
1225
|
+
|
1226
|
+
module = ngx_modules[i];
|
1227
|
+
break;
|
1228
|
+
}
|
1229
|
+
}
|
1230
|
+
|
1231
|
+
if (module == NULL) {
|
1232
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, "no events module found");
|
1233
|
+
return NGX_CONF_ERROR;
|
1234
|
+
}
|
1235
|
+
|
1236
|
+
ngx_conf_init_uint_value(ecf->connections, DEFAULT_CONNECTIONS);
|
1237
|
+
cycle->connection_n = ecf->connections;
|
1238
|
+
|
1239
|
+
ngx_conf_init_uint_value(ecf->use, module->ctx_index);
|
1240
|
+
|
1241
|
+
event_module = module->ctx;
|
1242
|
+
ngx_conf_init_ptr_value(ecf->name, event_module->name->data);
|
1243
|
+
|
1244
|
+
ngx_conf_init_value(ecf->multi_accept, 0);
|
1245
|
+
ngx_conf_init_value(ecf->accept_mutex, 1);
|
1246
|
+
ngx_conf_init_msec_value(ecf->accept_mutex_delay, 500);
|
1247
|
+
|
1248
|
+
|
1249
|
+
#if (NGX_HAVE_RTSIG)
|
1250
|
+
|
1251
|
+
if (!rtsig) {
|
1252
|
+
return NGX_CONF_OK;
|
1253
|
+
}
|
1254
|
+
|
1255
|
+
if (ecf->accept_mutex) {
|
1256
|
+
return NGX_CONF_OK;
|
1257
|
+
}
|
1258
|
+
|
1259
|
+
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
1260
|
+
|
1261
|
+
if (ccf->worker_processes == 0) {
|
1262
|
+
return NGX_CONF_OK;
|
1263
|
+
}
|
1264
|
+
|
1265
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
|
1266
|
+
"the \"rtsig\" method requires \"accept_mutex\" to be on");
|
1267
|
+
|
1268
|
+
return NGX_CONF_ERROR;
|
1269
|
+
|
1270
|
+
#else
|
1271
|
+
|
1272
|
+
return NGX_CONF_OK;
|
1273
|
+
|
1274
|
+
#endif
|
1275
|
+
}
|