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,60 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (C) Igor Sysoev
|
4
|
+
* Copyright (C) Nginx, Inc.
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
#ifndef _NGX_MD5_H_INCLUDED_
|
9
|
+
#define _NGX_MD5_H_INCLUDED_
|
10
|
+
|
11
|
+
|
12
|
+
#include <ngx_config.h>
|
13
|
+
#include <ngx_core.h>
|
14
|
+
|
15
|
+
|
16
|
+
#if (NGX_HAVE_MD5)
|
17
|
+
|
18
|
+
#if (NGX_HAVE_OPENSSL_MD5_H)
|
19
|
+
#include <openssl/md5.h>
|
20
|
+
#else
|
21
|
+
#include <md5.h>
|
22
|
+
#endif
|
23
|
+
|
24
|
+
|
25
|
+
typedef MD5_CTX ngx_md5_t;
|
26
|
+
|
27
|
+
|
28
|
+
#if (NGX_OPENSSL_MD5)
|
29
|
+
|
30
|
+
#define ngx_md5_init MD5_Init
|
31
|
+
#define ngx_md5_update MD5_Update
|
32
|
+
#define ngx_md5_final MD5_Final
|
33
|
+
|
34
|
+
#else
|
35
|
+
|
36
|
+
#define ngx_md5_init MD5Init
|
37
|
+
#define ngx_md5_update MD5Update
|
38
|
+
#define ngx_md5_final MD5Final
|
39
|
+
|
40
|
+
#endif
|
41
|
+
|
42
|
+
|
43
|
+
#else /* !NGX_HAVE_MD5 */
|
44
|
+
|
45
|
+
|
46
|
+
typedef struct {
|
47
|
+
uint64_t bytes;
|
48
|
+
uint32_t a, b, c, d;
|
49
|
+
u_char buffer[64];
|
50
|
+
} ngx_md5_t;
|
51
|
+
|
52
|
+
|
53
|
+
void ngx_md5_init(ngx_md5_t *ctx);
|
54
|
+
void ngx_md5_update(ngx_md5_t *ctx, const void *data, size_t size);
|
55
|
+
void ngx_md5_final(u_char result[16], ngx_md5_t *ctx);
|
56
|
+
|
57
|
+
|
58
|
+
#endif
|
59
|
+
|
60
|
+
#endif /* _NGX_MD5_H_INCLUDED_ */
|
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (C) Austin Appleby
|
4
|
+
*/
|
5
|
+
|
6
|
+
|
7
|
+
#include <ngx_config.h>
|
8
|
+
#include <ngx_core.h>
|
9
|
+
|
10
|
+
|
11
|
+
uint32_t
|
12
|
+
ngx_murmur_hash2(u_char *data, size_t len)
|
13
|
+
{
|
14
|
+
uint32_t h, k;
|
15
|
+
|
16
|
+
h = 0 ^ len;
|
17
|
+
|
18
|
+
while (len >= 4) {
|
19
|
+
k = data[0];
|
20
|
+
k |= data[1] << 8;
|
21
|
+
k |= data[2] << 16;
|
22
|
+
k |= data[3] << 24;
|
23
|
+
|
24
|
+
k *= 0x5bd1e995;
|
25
|
+
k ^= k >> 24;
|
26
|
+
k *= 0x5bd1e995;
|
27
|
+
|
28
|
+
h *= 0x5bd1e995;
|
29
|
+
h ^= k;
|
30
|
+
|
31
|
+
data += 4;
|
32
|
+
len -= 4;
|
33
|
+
}
|
34
|
+
|
35
|
+
switch (len) {
|
36
|
+
case 3:
|
37
|
+
h ^= data[2] << 16;
|
38
|
+
case 2:
|
39
|
+
h ^= data[1] << 8;
|
40
|
+
case 1:
|
41
|
+
h ^= data[0];
|
42
|
+
h *= 0x5bd1e995;
|
43
|
+
}
|
44
|
+
|
45
|
+
h ^= h >> 13;
|
46
|
+
h *= 0x5bd1e995;
|
47
|
+
h ^= h >> 15;
|
48
|
+
|
49
|
+
return h;
|
50
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (C) Igor Sysoev
|
4
|
+
* Copyright (C) Nginx, Inc.
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
#ifndef _NGX_MURMURHASH_H_INCLUDED_
|
9
|
+
#define _NGX_MURMURHASH_H_INCLUDED_
|
10
|
+
|
11
|
+
|
12
|
+
#include <ngx_config.h>
|
13
|
+
#include <ngx_core.h>
|
14
|
+
|
15
|
+
|
16
|
+
uint32_t ngx_murmur_hash2(u_char *data, size_t len);
|
17
|
+
|
18
|
+
|
19
|
+
#endif /* _NGX_CRC_H_INCLUDED_ */
|
@@ -0,0 +1,882 @@
|
|
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
|
+
/*
|
14
|
+
* open file cache caches
|
15
|
+
* open file handles with stat() info;
|
16
|
+
* directories stat() info;
|
17
|
+
* files and directories errors: not found, access denied, etc.
|
18
|
+
*/
|
19
|
+
|
20
|
+
|
21
|
+
#define NGX_MIN_READ_AHEAD (128 * 1024)
|
22
|
+
|
23
|
+
|
24
|
+
static void ngx_open_file_cache_cleanup(void *data);
|
25
|
+
static ngx_int_t ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of,
|
26
|
+
ngx_log_t *log);
|
27
|
+
static void ngx_open_file_add_event(ngx_open_file_cache_t *cache,
|
28
|
+
ngx_cached_open_file_t *file, ngx_open_file_info_t *of, ngx_log_t *log);
|
29
|
+
static void ngx_open_file_cleanup(void *data);
|
30
|
+
static void ngx_close_cached_file(ngx_open_file_cache_t *cache,
|
31
|
+
ngx_cached_open_file_t *file, ngx_uint_t min_uses, ngx_log_t *log);
|
32
|
+
static void ngx_open_file_del_event(ngx_cached_open_file_t *file);
|
33
|
+
static void ngx_expire_old_cached_files(ngx_open_file_cache_t *cache,
|
34
|
+
ngx_uint_t n, ngx_log_t *log);
|
35
|
+
static void ngx_open_file_cache_rbtree_insert_value(ngx_rbtree_node_t *temp,
|
36
|
+
ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel);
|
37
|
+
static ngx_cached_open_file_t *
|
38
|
+
ngx_open_file_lookup(ngx_open_file_cache_t *cache, ngx_str_t *name,
|
39
|
+
uint32_t hash);
|
40
|
+
static void ngx_open_file_cache_remove(ngx_event_t *ev);
|
41
|
+
|
42
|
+
|
43
|
+
ngx_open_file_cache_t *
|
44
|
+
ngx_open_file_cache_init(ngx_pool_t *pool, ngx_uint_t max, time_t inactive)
|
45
|
+
{
|
46
|
+
ngx_pool_cleanup_t *cln;
|
47
|
+
ngx_open_file_cache_t *cache;
|
48
|
+
|
49
|
+
cache = ngx_palloc(pool, sizeof(ngx_open_file_cache_t));
|
50
|
+
if (cache == NULL) {
|
51
|
+
return NULL;
|
52
|
+
}
|
53
|
+
|
54
|
+
ngx_rbtree_init(&cache->rbtree, &cache->sentinel,
|
55
|
+
ngx_open_file_cache_rbtree_insert_value);
|
56
|
+
|
57
|
+
ngx_queue_init(&cache->expire_queue);
|
58
|
+
|
59
|
+
cache->current = 0;
|
60
|
+
cache->max = max;
|
61
|
+
cache->inactive = inactive;
|
62
|
+
|
63
|
+
cln = ngx_pool_cleanup_add(pool, 0);
|
64
|
+
if (cln == NULL) {
|
65
|
+
return NULL;
|
66
|
+
}
|
67
|
+
|
68
|
+
cln->handler = ngx_open_file_cache_cleanup;
|
69
|
+
cln->data = cache;
|
70
|
+
|
71
|
+
return cache;
|
72
|
+
}
|
73
|
+
|
74
|
+
|
75
|
+
static void
|
76
|
+
ngx_open_file_cache_cleanup(void *data)
|
77
|
+
{
|
78
|
+
ngx_open_file_cache_t *cache = data;
|
79
|
+
|
80
|
+
ngx_queue_t *q;
|
81
|
+
ngx_cached_open_file_t *file;
|
82
|
+
|
83
|
+
ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0,
|
84
|
+
"open file cache cleanup");
|
85
|
+
|
86
|
+
for ( ;; ) {
|
87
|
+
|
88
|
+
if (ngx_queue_empty(&cache->expire_queue)) {
|
89
|
+
break;
|
90
|
+
}
|
91
|
+
|
92
|
+
q = ngx_queue_last(&cache->expire_queue);
|
93
|
+
|
94
|
+
file = ngx_queue_data(q, ngx_cached_open_file_t, queue);
|
95
|
+
|
96
|
+
ngx_queue_remove(q);
|
97
|
+
|
98
|
+
ngx_rbtree_delete(&cache->rbtree, &file->node);
|
99
|
+
|
100
|
+
cache->current--;
|
101
|
+
|
102
|
+
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0,
|
103
|
+
"delete cached open file: %s", file->name);
|
104
|
+
|
105
|
+
if (!file->err && !file->is_dir) {
|
106
|
+
file->close = 1;
|
107
|
+
file->count = 0;
|
108
|
+
ngx_close_cached_file(cache, file, 0, ngx_cycle->log);
|
109
|
+
|
110
|
+
} else {
|
111
|
+
ngx_free(file->name);
|
112
|
+
ngx_free(file);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
if (cache->current) {
|
117
|
+
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
|
118
|
+
"%d items still leave in open file cache",
|
119
|
+
cache->current);
|
120
|
+
}
|
121
|
+
|
122
|
+
if (cache->rbtree.root != cache->rbtree.sentinel) {
|
123
|
+
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
|
124
|
+
"rbtree still is not empty in open file cache");
|
125
|
+
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
ngx_int_t
|
131
|
+
ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,
|
132
|
+
ngx_open_file_info_t *of, ngx_pool_t *pool)
|
133
|
+
{
|
134
|
+
time_t now;
|
135
|
+
uint32_t hash;
|
136
|
+
ngx_int_t rc;
|
137
|
+
ngx_file_info_t fi;
|
138
|
+
ngx_pool_cleanup_t *cln;
|
139
|
+
ngx_cached_open_file_t *file;
|
140
|
+
ngx_pool_cleanup_file_t *clnf;
|
141
|
+
ngx_open_file_cache_cleanup_t *ofcln;
|
142
|
+
|
143
|
+
of->fd = NGX_INVALID_FILE;
|
144
|
+
of->err = 0;
|
145
|
+
|
146
|
+
if (cache == NULL) {
|
147
|
+
|
148
|
+
if (of->test_only) {
|
149
|
+
|
150
|
+
if (ngx_file_info(name->data, &fi) == NGX_FILE_ERROR) {
|
151
|
+
of->err = ngx_errno;
|
152
|
+
of->failed = ngx_file_info_n;
|
153
|
+
return NGX_ERROR;
|
154
|
+
}
|
155
|
+
|
156
|
+
of->uniq = ngx_file_uniq(&fi);
|
157
|
+
of->mtime = ngx_file_mtime(&fi);
|
158
|
+
of->size = ngx_file_size(&fi);
|
159
|
+
of->fs_size = ngx_file_fs_size(&fi);
|
160
|
+
of->is_dir = ngx_is_dir(&fi);
|
161
|
+
of->is_file = ngx_is_file(&fi);
|
162
|
+
of->is_link = ngx_is_link(&fi);
|
163
|
+
of->is_exec = ngx_is_exec(&fi);
|
164
|
+
|
165
|
+
return NGX_OK;
|
166
|
+
}
|
167
|
+
|
168
|
+
cln = ngx_pool_cleanup_add(pool, sizeof(ngx_pool_cleanup_file_t));
|
169
|
+
if (cln == NULL) {
|
170
|
+
return NGX_ERROR;
|
171
|
+
}
|
172
|
+
|
173
|
+
rc = ngx_open_and_stat_file(name->data, of, pool->log);
|
174
|
+
|
175
|
+
if (rc == NGX_OK && !of->is_dir) {
|
176
|
+
cln->handler = ngx_pool_cleanup_file;
|
177
|
+
clnf = cln->data;
|
178
|
+
|
179
|
+
clnf->fd = of->fd;
|
180
|
+
clnf->name = name->data;
|
181
|
+
clnf->log = pool->log;
|
182
|
+
}
|
183
|
+
|
184
|
+
return rc;
|
185
|
+
}
|
186
|
+
|
187
|
+
cln = ngx_pool_cleanup_add(pool, sizeof(ngx_open_file_cache_cleanup_t));
|
188
|
+
if (cln == NULL) {
|
189
|
+
return NGX_ERROR;
|
190
|
+
}
|
191
|
+
|
192
|
+
now = ngx_time();
|
193
|
+
|
194
|
+
hash = ngx_crc32_long(name->data, name->len);
|
195
|
+
|
196
|
+
file = ngx_open_file_lookup(cache, name, hash);
|
197
|
+
|
198
|
+
if (file) {
|
199
|
+
|
200
|
+
file->uses++;
|
201
|
+
|
202
|
+
ngx_queue_remove(&file->queue);
|
203
|
+
|
204
|
+
if (file->fd == NGX_INVALID_FILE && file->err == 0 && !file->is_dir) {
|
205
|
+
|
206
|
+
/* file was not used often enough to keep open */
|
207
|
+
|
208
|
+
rc = ngx_open_and_stat_file(name->data, of, pool->log);
|
209
|
+
|
210
|
+
if (rc != NGX_OK && (of->err == 0 || !of->errors)) {
|
211
|
+
goto failed;
|
212
|
+
}
|
213
|
+
|
214
|
+
goto add_event;
|
215
|
+
}
|
216
|
+
|
217
|
+
if (file->use_event
|
218
|
+
|| (file->event == NULL
|
219
|
+
&& (of->uniq == 0 || of->uniq == file->uniq)
|
220
|
+
&& now - file->created < of->valid))
|
221
|
+
{
|
222
|
+
if (file->err == 0) {
|
223
|
+
|
224
|
+
of->fd = file->fd;
|
225
|
+
of->uniq = file->uniq;
|
226
|
+
of->mtime = file->mtime;
|
227
|
+
of->size = file->size;
|
228
|
+
|
229
|
+
of->is_dir = file->is_dir;
|
230
|
+
of->is_file = file->is_file;
|
231
|
+
of->is_link = file->is_link;
|
232
|
+
of->is_exec = file->is_exec;
|
233
|
+
of->is_directio = file->is_directio;
|
234
|
+
|
235
|
+
if (!file->is_dir) {
|
236
|
+
file->count++;
|
237
|
+
ngx_open_file_add_event(cache, file, of, pool->log);
|
238
|
+
}
|
239
|
+
|
240
|
+
} else {
|
241
|
+
of->err = file->err;
|
242
|
+
of->failed = ngx_open_file_n;
|
243
|
+
}
|
244
|
+
|
245
|
+
goto found;
|
246
|
+
}
|
247
|
+
|
248
|
+
ngx_log_debug4(NGX_LOG_DEBUG_CORE, pool->log, 0,
|
249
|
+
"retest open file: %s, fd:%d, c:%d, e:%d",
|
250
|
+
file->name, file->fd, file->count, file->err);
|
251
|
+
|
252
|
+
if (file->is_dir) {
|
253
|
+
|
254
|
+
/*
|
255
|
+
* chances that directory became file are very small
|
256
|
+
* so test_dir flag allows to use a single syscall
|
257
|
+
* in ngx_file_info() instead of three syscalls
|
258
|
+
*/
|
259
|
+
|
260
|
+
of->test_dir = 1;
|
261
|
+
}
|
262
|
+
|
263
|
+
of->fd = file->fd;
|
264
|
+
of->uniq = file->uniq;
|
265
|
+
|
266
|
+
rc = ngx_open_and_stat_file(name->data, of, pool->log);
|
267
|
+
|
268
|
+
if (rc != NGX_OK && (of->err == 0 || !of->errors)) {
|
269
|
+
goto failed;
|
270
|
+
}
|
271
|
+
|
272
|
+
if (of->is_dir) {
|
273
|
+
|
274
|
+
if (file->is_dir || file->err) {
|
275
|
+
goto update;
|
276
|
+
}
|
277
|
+
|
278
|
+
/* file became directory */
|
279
|
+
|
280
|
+
} else if (of->err == 0) { /* file */
|
281
|
+
|
282
|
+
if (file->is_dir || file->err) {
|
283
|
+
goto add_event;
|
284
|
+
}
|
285
|
+
|
286
|
+
if (of->uniq == file->uniq) {
|
287
|
+
|
288
|
+
if (file->event) {
|
289
|
+
file->use_event = 1;
|
290
|
+
}
|
291
|
+
|
292
|
+
of->is_directio = file->is_directio;
|
293
|
+
|
294
|
+
goto update;
|
295
|
+
}
|
296
|
+
|
297
|
+
/* file was changed */
|
298
|
+
|
299
|
+
} else { /* error to cache */
|
300
|
+
|
301
|
+
if (file->err || file->is_dir) {
|
302
|
+
goto update;
|
303
|
+
}
|
304
|
+
|
305
|
+
/* file was removed, etc. */
|
306
|
+
}
|
307
|
+
|
308
|
+
if (file->count == 0) {
|
309
|
+
|
310
|
+
ngx_open_file_del_event(file);
|
311
|
+
|
312
|
+
if (ngx_close_file(file->fd) == NGX_FILE_ERROR) {
|
313
|
+
ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,
|
314
|
+
ngx_close_file_n " \"%s\" failed",
|
315
|
+
name->data);
|
316
|
+
}
|
317
|
+
|
318
|
+
goto add_event;
|
319
|
+
}
|
320
|
+
|
321
|
+
ngx_rbtree_delete(&cache->rbtree, &file->node);
|
322
|
+
|
323
|
+
cache->current--;
|
324
|
+
|
325
|
+
file->close = 1;
|
326
|
+
|
327
|
+
goto create;
|
328
|
+
}
|
329
|
+
|
330
|
+
/* not found */
|
331
|
+
|
332
|
+
rc = ngx_open_and_stat_file(name->data, of, pool->log);
|
333
|
+
|
334
|
+
if (rc != NGX_OK && (of->err == 0 || !of->errors)) {
|
335
|
+
goto failed;
|
336
|
+
}
|
337
|
+
|
338
|
+
create:
|
339
|
+
|
340
|
+
if (cache->current >= cache->max) {
|
341
|
+
ngx_expire_old_cached_files(cache, 0, pool->log);
|
342
|
+
}
|
343
|
+
|
344
|
+
file = ngx_alloc(sizeof(ngx_cached_open_file_t), pool->log);
|
345
|
+
|
346
|
+
if (file == NULL) {
|
347
|
+
goto failed;
|
348
|
+
}
|
349
|
+
|
350
|
+
file->name = ngx_alloc(name->len + 1, pool->log);
|
351
|
+
|
352
|
+
if (file->name == NULL) {
|
353
|
+
ngx_free(file);
|
354
|
+
file = NULL;
|
355
|
+
goto failed;
|
356
|
+
}
|
357
|
+
|
358
|
+
ngx_cpystrn(file->name, name->data, name->len + 1);
|
359
|
+
|
360
|
+
file->node.key = hash;
|
361
|
+
|
362
|
+
ngx_rbtree_insert(&cache->rbtree, &file->node);
|
363
|
+
|
364
|
+
cache->current++;
|
365
|
+
|
366
|
+
file->uses = 1;
|
367
|
+
file->count = 0;
|
368
|
+
file->use_event = 0;
|
369
|
+
file->event = NULL;
|
370
|
+
|
371
|
+
add_event:
|
372
|
+
|
373
|
+
ngx_open_file_add_event(cache, file, of, pool->log);
|
374
|
+
|
375
|
+
update:
|
376
|
+
|
377
|
+
file->fd = of->fd;
|
378
|
+
file->err = of->err;
|
379
|
+
|
380
|
+
if (of->err == 0) {
|
381
|
+
file->uniq = of->uniq;
|
382
|
+
file->mtime = of->mtime;
|
383
|
+
file->size = of->size;
|
384
|
+
|
385
|
+
file->close = 0;
|
386
|
+
|
387
|
+
file->is_dir = of->is_dir;
|
388
|
+
file->is_file = of->is_file;
|
389
|
+
file->is_link = of->is_link;
|
390
|
+
file->is_exec = of->is_exec;
|
391
|
+
file->is_directio = of->is_directio;
|
392
|
+
|
393
|
+
if (!of->is_dir) {
|
394
|
+
file->count++;
|
395
|
+
}
|
396
|
+
}
|
397
|
+
|
398
|
+
file->created = now;
|
399
|
+
|
400
|
+
found:
|
401
|
+
|
402
|
+
file->accessed = now;
|
403
|
+
|
404
|
+
ngx_queue_insert_head(&cache->expire_queue, &file->queue);
|
405
|
+
|
406
|
+
ngx_log_debug5(NGX_LOG_DEBUG_CORE, pool->log, 0,
|
407
|
+
"cached open file: %s, fd:%d, c:%d, e:%d, u:%d",
|
408
|
+
file->name, file->fd, file->count, file->err, file->uses);
|
409
|
+
|
410
|
+
if (of->err == 0) {
|
411
|
+
|
412
|
+
if (!of->is_dir) {
|
413
|
+
cln->handler = ngx_open_file_cleanup;
|
414
|
+
ofcln = cln->data;
|
415
|
+
|
416
|
+
ofcln->cache = cache;
|
417
|
+
ofcln->file = file;
|
418
|
+
ofcln->min_uses = of->min_uses;
|
419
|
+
ofcln->log = pool->log;
|
420
|
+
}
|
421
|
+
|
422
|
+
return NGX_OK;
|
423
|
+
}
|
424
|
+
|
425
|
+
return NGX_ERROR;
|
426
|
+
|
427
|
+
failed:
|
428
|
+
|
429
|
+
if (file) {
|
430
|
+
ngx_rbtree_delete(&cache->rbtree, &file->node);
|
431
|
+
|
432
|
+
cache->current--;
|
433
|
+
|
434
|
+
if (file->count == 0) {
|
435
|
+
|
436
|
+
if (file->fd != NGX_INVALID_FILE) {
|
437
|
+
if (ngx_close_file(file->fd) == NGX_FILE_ERROR) {
|
438
|
+
ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,
|
439
|
+
ngx_close_file_n " \"%s\" failed",
|
440
|
+
file->name);
|
441
|
+
}
|
442
|
+
}
|
443
|
+
|
444
|
+
ngx_free(file->name);
|
445
|
+
ngx_free(file);
|
446
|
+
|
447
|
+
} else {
|
448
|
+
file->close = 1;
|
449
|
+
}
|
450
|
+
}
|
451
|
+
|
452
|
+
if (of->fd != NGX_INVALID_FILE) {
|
453
|
+
if (ngx_close_file(of->fd) == NGX_FILE_ERROR) {
|
454
|
+
ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,
|
455
|
+
ngx_close_file_n " \"%s\" failed", name->data);
|
456
|
+
}
|
457
|
+
}
|
458
|
+
|
459
|
+
return NGX_ERROR;
|
460
|
+
}
|
461
|
+
|
462
|
+
|
463
|
+
static ngx_int_t
|
464
|
+
ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of, ngx_log_t *log)
|
465
|
+
{
|
466
|
+
ngx_fd_t fd;
|
467
|
+
ngx_file_info_t fi;
|
468
|
+
|
469
|
+
if (of->fd != NGX_INVALID_FILE) {
|
470
|
+
|
471
|
+
if (ngx_file_info(name, &fi) == NGX_FILE_ERROR) {
|
472
|
+
of->failed = ngx_file_info_n;
|
473
|
+
goto failed;
|
474
|
+
}
|
475
|
+
|
476
|
+
if (of->uniq == ngx_file_uniq(&fi)) {
|
477
|
+
goto done;
|
478
|
+
}
|
479
|
+
|
480
|
+
} else if (of->test_dir) {
|
481
|
+
|
482
|
+
if (ngx_file_info(name, &fi) == NGX_FILE_ERROR) {
|
483
|
+
of->failed = ngx_file_info_n;
|
484
|
+
goto failed;
|
485
|
+
}
|
486
|
+
|
487
|
+
if (ngx_is_dir(&fi)) {
|
488
|
+
goto done;
|
489
|
+
}
|
490
|
+
}
|
491
|
+
|
492
|
+
if (!of->log) {
|
493
|
+
|
494
|
+
/*
|
495
|
+
* Use non-blocking open() not to hang on FIFO files, etc.
|
496
|
+
* This flag has no effect on a regular files.
|
497
|
+
*/
|
498
|
+
|
499
|
+
fd = ngx_open_file(name, NGX_FILE_RDONLY|NGX_FILE_NONBLOCK,
|
500
|
+
NGX_FILE_OPEN, 0);
|
501
|
+
|
502
|
+
} else {
|
503
|
+
fd = ngx_open_file(name, NGX_FILE_APPEND, NGX_FILE_CREATE_OR_OPEN,
|
504
|
+
NGX_FILE_DEFAULT_ACCESS);
|
505
|
+
}
|
506
|
+
|
507
|
+
if (fd == NGX_INVALID_FILE) {
|
508
|
+
of->failed = ngx_open_file_n;
|
509
|
+
goto failed;
|
510
|
+
}
|
511
|
+
|
512
|
+
if (ngx_fd_info(fd, &fi) == NGX_FILE_ERROR) {
|
513
|
+
ngx_log_error(NGX_LOG_CRIT, log, ngx_errno,
|
514
|
+
ngx_fd_info_n " \"%s\" failed", name);
|
515
|
+
|
516
|
+
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
|
517
|
+
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
518
|
+
ngx_close_file_n " \"%s\" failed", name);
|
519
|
+
}
|
520
|
+
|
521
|
+
of->fd = NGX_INVALID_FILE;
|
522
|
+
|
523
|
+
return NGX_ERROR;
|
524
|
+
}
|
525
|
+
|
526
|
+
if (ngx_is_dir(&fi)) {
|
527
|
+
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
|
528
|
+
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
529
|
+
ngx_close_file_n " \"%s\" failed", name);
|
530
|
+
}
|
531
|
+
|
532
|
+
of->fd = NGX_INVALID_FILE;
|
533
|
+
|
534
|
+
} else {
|
535
|
+
of->fd = fd;
|
536
|
+
|
537
|
+
if (of->read_ahead && ngx_file_size(&fi) > NGX_MIN_READ_AHEAD) {
|
538
|
+
if (ngx_read_ahead(fd, of->read_ahead) == NGX_ERROR) {
|
539
|
+
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
540
|
+
ngx_read_ahead_n " \"%s\" failed", name);
|
541
|
+
}
|
542
|
+
}
|
543
|
+
|
544
|
+
if (of->directio <= ngx_file_size(&fi)) {
|
545
|
+
if (ngx_directio_on(fd) == NGX_FILE_ERROR) {
|
546
|
+
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
547
|
+
ngx_directio_on_n " \"%s\" failed", name);
|
548
|
+
|
549
|
+
} else {
|
550
|
+
of->is_directio = 1;
|
551
|
+
}
|
552
|
+
}
|
553
|
+
}
|
554
|
+
|
555
|
+
done:
|
556
|
+
|
557
|
+
of->uniq = ngx_file_uniq(&fi);
|
558
|
+
of->mtime = ngx_file_mtime(&fi);
|
559
|
+
of->size = ngx_file_size(&fi);
|
560
|
+
of->fs_size = ngx_file_fs_size(&fi);
|
561
|
+
of->is_dir = ngx_is_dir(&fi);
|
562
|
+
of->is_file = ngx_is_file(&fi);
|
563
|
+
of->is_link = ngx_is_link(&fi);
|
564
|
+
of->is_exec = ngx_is_exec(&fi);
|
565
|
+
|
566
|
+
return NGX_OK;
|
567
|
+
|
568
|
+
failed:
|
569
|
+
|
570
|
+
of->fd = NGX_INVALID_FILE;
|
571
|
+
of->err = ngx_errno;
|
572
|
+
|
573
|
+
return NGX_ERROR;
|
574
|
+
}
|
575
|
+
|
576
|
+
|
577
|
+
/*
|
578
|
+
* we ignore any possible event setting error and
|
579
|
+
* fallback to usual periodic file retests
|
580
|
+
*/
|
581
|
+
|
582
|
+
static void
|
583
|
+
ngx_open_file_add_event(ngx_open_file_cache_t *cache,
|
584
|
+
ngx_cached_open_file_t *file, ngx_open_file_info_t *of, ngx_log_t *log)
|
585
|
+
{
|
586
|
+
ngx_open_file_cache_event_t *fev;
|
587
|
+
|
588
|
+
if (!(ngx_event_flags & NGX_USE_VNODE_EVENT)
|
589
|
+
|| !of->events
|
590
|
+
|| file->event
|
591
|
+
|| of->fd == NGX_INVALID_FILE
|
592
|
+
|| file->uses < of->min_uses)
|
593
|
+
{
|
594
|
+
return;
|
595
|
+
}
|
596
|
+
|
597
|
+
file->use_event = 0;
|
598
|
+
|
599
|
+
file->event = ngx_calloc(sizeof(ngx_event_t), log);
|
600
|
+
if (file->event== NULL) {
|
601
|
+
return;
|
602
|
+
}
|
603
|
+
|
604
|
+
fev = ngx_alloc(sizeof(ngx_open_file_cache_event_t), log);
|
605
|
+
if (fev == NULL) {
|
606
|
+
ngx_free(file->event);
|
607
|
+
file->event = NULL;
|
608
|
+
return;
|
609
|
+
}
|
610
|
+
|
611
|
+
fev->fd = of->fd;
|
612
|
+
fev->file = file;
|
613
|
+
fev->cache = cache;
|
614
|
+
|
615
|
+
file->event->handler = ngx_open_file_cache_remove;
|
616
|
+
file->event->data = fev;
|
617
|
+
|
618
|
+
/*
|
619
|
+
* although vnode event may be called while ngx_cycle->poll
|
620
|
+
* destruction, however, cleanup procedures are run before any
|
621
|
+
* memory freeing and events will be canceled.
|
622
|
+
*/
|
623
|
+
|
624
|
+
file->event->log = ngx_cycle->log;
|
625
|
+
|
626
|
+
if (ngx_add_event(file->event, NGX_VNODE_EVENT, NGX_ONESHOT_EVENT)
|
627
|
+
!= NGX_OK)
|
628
|
+
{
|
629
|
+
ngx_free(file->event->data);
|
630
|
+
ngx_free(file->event);
|
631
|
+
file->event = NULL;
|
632
|
+
return;
|
633
|
+
}
|
634
|
+
|
635
|
+
/*
|
636
|
+
* we do not set file->use_event here because there may be a race
|
637
|
+
* condition: a file may be deleted between opening the file and
|
638
|
+
* adding event, so we rely upon event notification only after
|
639
|
+
* one file revalidation on next file access
|
640
|
+
*/
|
641
|
+
|
642
|
+
return;
|
643
|
+
}
|
644
|
+
|
645
|
+
|
646
|
+
static void
|
647
|
+
ngx_open_file_cleanup(void *data)
|
648
|
+
{
|
649
|
+
ngx_open_file_cache_cleanup_t *c = data;
|
650
|
+
|
651
|
+
c->file->count--;
|
652
|
+
|
653
|
+
ngx_close_cached_file(c->cache, c->file, c->min_uses, c->log);
|
654
|
+
|
655
|
+
/* drop one or two expired open files */
|
656
|
+
ngx_expire_old_cached_files(c->cache, 1, c->log);
|
657
|
+
}
|
658
|
+
|
659
|
+
|
660
|
+
static void
|
661
|
+
ngx_close_cached_file(ngx_open_file_cache_t *cache,
|
662
|
+
ngx_cached_open_file_t *file, ngx_uint_t min_uses, ngx_log_t *log)
|
663
|
+
{
|
664
|
+
ngx_log_debug5(NGX_LOG_DEBUG_CORE, log, 0,
|
665
|
+
"close cached open file: %s, fd:%d, c:%d, u:%d, %d",
|
666
|
+
file->name, file->fd, file->count, file->uses, file->close);
|
667
|
+
|
668
|
+
if (!file->close) {
|
669
|
+
|
670
|
+
file->accessed = ngx_time();
|
671
|
+
|
672
|
+
ngx_queue_remove(&file->queue);
|
673
|
+
|
674
|
+
ngx_queue_insert_head(&cache->expire_queue, &file->queue);
|
675
|
+
|
676
|
+
if (file->uses >= min_uses || file->count) {
|
677
|
+
return;
|
678
|
+
}
|
679
|
+
}
|
680
|
+
|
681
|
+
ngx_open_file_del_event(file);
|
682
|
+
|
683
|
+
if (file->count) {
|
684
|
+
return;
|
685
|
+
}
|
686
|
+
|
687
|
+
if (file->fd != NGX_INVALID_FILE) {
|
688
|
+
|
689
|
+
if (ngx_close_file(file->fd) == NGX_FILE_ERROR) {
|
690
|
+
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
691
|
+
ngx_close_file_n " \"%s\" failed", file->name);
|
692
|
+
}
|
693
|
+
|
694
|
+
file->fd = NGX_INVALID_FILE;
|
695
|
+
}
|
696
|
+
|
697
|
+
if (!file->close) {
|
698
|
+
return;
|
699
|
+
}
|
700
|
+
|
701
|
+
ngx_free(file->name);
|
702
|
+
ngx_free(file);
|
703
|
+
}
|
704
|
+
|
705
|
+
|
706
|
+
static void
|
707
|
+
ngx_open_file_del_event(ngx_cached_open_file_t *file)
|
708
|
+
{
|
709
|
+
if (file->event == NULL) {
|
710
|
+
return;
|
711
|
+
}
|
712
|
+
|
713
|
+
(void) ngx_del_event(file->event, NGX_VNODE_EVENT,
|
714
|
+
file->count ? NGX_FLUSH_EVENT : NGX_CLOSE_EVENT);
|
715
|
+
|
716
|
+
ngx_free(file->event->data);
|
717
|
+
ngx_free(file->event);
|
718
|
+
file->event = NULL;
|
719
|
+
file->use_event = 0;
|
720
|
+
}
|
721
|
+
|
722
|
+
|
723
|
+
static void
|
724
|
+
ngx_expire_old_cached_files(ngx_open_file_cache_t *cache, ngx_uint_t n,
|
725
|
+
ngx_log_t *log)
|
726
|
+
{
|
727
|
+
time_t now;
|
728
|
+
ngx_queue_t *q;
|
729
|
+
ngx_cached_open_file_t *file;
|
730
|
+
|
731
|
+
now = ngx_time();
|
732
|
+
|
733
|
+
/*
|
734
|
+
* n == 1 deletes one or two inactive files
|
735
|
+
* n == 0 deletes least recently used file by force
|
736
|
+
* and one or two inactive files
|
737
|
+
*/
|
738
|
+
|
739
|
+
while (n < 3) {
|
740
|
+
|
741
|
+
if (ngx_queue_empty(&cache->expire_queue)) {
|
742
|
+
return;
|
743
|
+
}
|
744
|
+
|
745
|
+
q = ngx_queue_last(&cache->expire_queue);
|
746
|
+
|
747
|
+
file = ngx_queue_data(q, ngx_cached_open_file_t, queue);
|
748
|
+
|
749
|
+
if (n++ != 0 && now - file->accessed <= cache->inactive) {
|
750
|
+
return;
|
751
|
+
}
|
752
|
+
|
753
|
+
ngx_queue_remove(q);
|
754
|
+
|
755
|
+
ngx_rbtree_delete(&cache->rbtree, &file->node);
|
756
|
+
|
757
|
+
cache->current--;
|
758
|
+
|
759
|
+
ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0,
|
760
|
+
"expire cached open file: %s", file->name);
|
761
|
+
|
762
|
+
if (!file->err && !file->is_dir) {
|
763
|
+
file->close = 1;
|
764
|
+
ngx_close_cached_file(cache, file, 0, log);
|
765
|
+
|
766
|
+
} else {
|
767
|
+
ngx_free(file->name);
|
768
|
+
ngx_free(file);
|
769
|
+
}
|
770
|
+
}
|
771
|
+
}
|
772
|
+
|
773
|
+
|
774
|
+
static void
|
775
|
+
ngx_open_file_cache_rbtree_insert_value(ngx_rbtree_node_t *temp,
|
776
|
+
ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel)
|
777
|
+
{
|
778
|
+
ngx_rbtree_node_t **p;
|
779
|
+
ngx_cached_open_file_t *file, *file_temp;
|
780
|
+
|
781
|
+
for ( ;; ) {
|
782
|
+
|
783
|
+
if (node->key < temp->key) {
|
784
|
+
|
785
|
+
p = &temp->left;
|
786
|
+
|
787
|
+
} else if (node->key > temp->key) {
|
788
|
+
|
789
|
+
p = &temp->right;
|
790
|
+
|
791
|
+
} else { /* node->key == temp->key */
|
792
|
+
|
793
|
+
file = (ngx_cached_open_file_t *) node;
|
794
|
+
file_temp = (ngx_cached_open_file_t *) temp;
|
795
|
+
|
796
|
+
p = (ngx_strcmp(file->name, file_temp->name) < 0)
|
797
|
+
? &temp->left : &temp->right;
|
798
|
+
}
|
799
|
+
|
800
|
+
if (*p == sentinel) {
|
801
|
+
break;
|
802
|
+
}
|
803
|
+
|
804
|
+
temp = *p;
|
805
|
+
}
|
806
|
+
|
807
|
+
*p = node;
|
808
|
+
node->parent = temp;
|
809
|
+
node->left = sentinel;
|
810
|
+
node->right = sentinel;
|
811
|
+
ngx_rbt_red(node);
|
812
|
+
}
|
813
|
+
|
814
|
+
|
815
|
+
static ngx_cached_open_file_t *
|
816
|
+
ngx_open_file_lookup(ngx_open_file_cache_t *cache, ngx_str_t *name,
|
817
|
+
uint32_t hash)
|
818
|
+
{
|
819
|
+
ngx_int_t rc;
|
820
|
+
ngx_rbtree_node_t *node, *sentinel;
|
821
|
+
ngx_cached_open_file_t *file;
|
822
|
+
|
823
|
+
node = cache->rbtree.root;
|
824
|
+
sentinel = cache->rbtree.sentinel;
|
825
|
+
|
826
|
+
while (node != sentinel) {
|
827
|
+
|
828
|
+
if (hash < node->key) {
|
829
|
+
node = node->left;
|
830
|
+
continue;
|
831
|
+
}
|
832
|
+
|
833
|
+
if (hash > node->key) {
|
834
|
+
node = node->right;
|
835
|
+
continue;
|
836
|
+
}
|
837
|
+
|
838
|
+
/* hash == node->key */
|
839
|
+
|
840
|
+
file = (ngx_cached_open_file_t *) node;
|
841
|
+
|
842
|
+
rc = ngx_strcmp(name->data, file->name);
|
843
|
+
|
844
|
+
if (rc == 0) {
|
845
|
+
return file;
|
846
|
+
}
|
847
|
+
|
848
|
+
node = (rc < 0) ? node->left : node->right;
|
849
|
+
}
|
850
|
+
|
851
|
+
return NULL;
|
852
|
+
}
|
853
|
+
|
854
|
+
|
855
|
+
static void
|
856
|
+
ngx_open_file_cache_remove(ngx_event_t *ev)
|
857
|
+
{
|
858
|
+
ngx_cached_open_file_t *file;
|
859
|
+
ngx_open_file_cache_event_t *fev;
|
860
|
+
|
861
|
+
fev = ev->data;
|
862
|
+
file = fev->file;
|
863
|
+
|
864
|
+
ngx_queue_remove(&file->queue);
|
865
|
+
|
866
|
+
ngx_rbtree_delete(&fev->cache->rbtree, &file->node);
|
867
|
+
|
868
|
+
fev->cache->current--;
|
869
|
+
|
870
|
+
/* NGX_ONESHOT_EVENT was already deleted */
|
871
|
+
file->event = NULL;
|
872
|
+
file->use_event = 0;
|
873
|
+
|
874
|
+
file->close = 1;
|
875
|
+
|
876
|
+
ngx_close_cached_file(fev->cache, file, 0, ev->log);
|
877
|
+
|
878
|
+
/* free memory only when fev->cache and fev->file are already not needed */
|
879
|
+
|
880
|
+
ngx_free(ev->data);
|
881
|
+
ngx_free(ev);
|
882
|
+
}
|