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,1379 @@
|
|
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
|
+
static void ngx_destroy_cycle_pools(ngx_conf_t *conf);
|
14
|
+
static ngx_int_t ngx_cmp_sockaddr(struct sockaddr *sa1, struct sockaddr *sa2);
|
15
|
+
static ngx_int_t ngx_init_zone_pool(ngx_cycle_t *cycle,
|
16
|
+
ngx_shm_zone_t *shm_zone);
|
17
|
+
static ngx_int_t ngx_test_lockfile(u_char *file, ngx_log_t *log);
|
18
|
+
static void ngx_clean_old_cycles(ngx_event_t *ev);
|
19
|
+
|
20
|
+
|
21
|
+
volatile ngx_cycle_t *ngx_cycle;
|
22
|
+
ngx_array_t ngx_old_cycles;
|
23
|
+
|
24
|
+
static ngx_pool_t *ngx_temp_pool;
|
25
|
+
static ngx_event_t ngx_cleaner_event;
|
26
|
+
|
27
|
+
ngx_uint_t ngx_test_config;
|
28
|
+
ngx_uint_t ngx_quiet_mode;
|
29
|
+
|
30
|
+
#if (NGX_THREADS)
|
31
|
+
ngx_tls_key_t ngx_core_tls_key;
|
32
|
+
#endif
|
33
|
+
|
34
|
+
|
35
|
+
/* STUB NAME */
|
36
|
+
static ngx_connection_t dumb;
|
37
|
+
/* STUB */
|
38
|
+
|
39
|
+
static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH);
|
40
|
+
|
41
|
+
|
42
|
+
ngx_cycle_t *
|
43
|
+
ngx_init_cycle(ngx_cycle_t *old_cycle)
|
44
|
+
{
|
45
|
+
void *rv;
|
46
|
+
char **senv, **env;
|
47
|
+
ngx_uint_t i, n;
|
48
|
+
ngx_log_t *log;
|
49
|
+
ngx_time_t *tp;
|
50
|
+
ngx_conf_t conf;
|
51
|
+
ngx_pool_t *pool;
|
52
|
+
ngx_cycle_t *cycle, **old;
|
53
|
+
ngx_shm_zone_t *shm_zone, *oshm_zone;
|
54
|
+
ngx_list_part_t *part, *opart;
|
55
|
+
ngx_open_file_t *file;
|
56
|
+
ngx_listening_t *ls, *nls;
|
57
|
+
ngx_core_conf_t *ccf, *old_ccf;
|
58
|
+
ngx_core_module_t *module;
|
59
|
+
char hostname[NGX_MAXHOSTNAMELEN];
|
60
|
+
|
61
|
+
ngx_timezone_update();
|
62
|
+
|
63
|
+
/* force localtime update with a new timezone */
|
64
|
+
|
65
|
+
tp = ngx_timeofday();
|
66
|
+
tp->sec = 0;
|
67
|
+
|
68
|
+
ngx_time_update();
|
69
|
+
|
70
|
+
|
71
|
+
log = old_cycle->log;
|
72
|
+
|
73
|
+
pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log);
|
74
|
+
if (pool == NULL) {
|
75
|
+
return NULL;
|
76
|
+
}
|
77
|
+
pool->log = log;
|
78
|
+
|
79
|
+
cycle = ngx_pcalloc(pool, sizeof(ngx_cycle_t));
|
80
|
+
if (cycle == NULL) {
|
81
|
+
ngx_destroy_pool(pool);
|
82
|
+
return NULL;
|
83
|
+
}
|
84
|
+
|
85
|
+
cycle->pool = pool;
|
86
|
+
cycle->log = log;
|
87
|
+
cycle->new_log.log_level = NGX_LOG_ERR;
|
88
|
+
cycle->old_cycle = old_cycle;
|
89
|
+
|
90
|
+
cycle->conf_prefix.len = old_cycle->conf_prefix.len;
|
91
|
+
cycle->conf_prefix.data = ngx_pstrdup(pool, &old_cycle->conf_prefix);
|
92
|
+
if (cycle->conf_prefix.data == NULL) {
|
93
|
+
ngx_destroy_pool(pool);
|
94
|
+
return NULL;
|
95
|
+
}
|
96
|
+
|
97
|
+
cycle->prefix.len = old_cycle->prefix.len;
|
98
|
+
cycle->prefix.data = ngx_pstrdup(pool, &old_cycle->prefix);
|
99
|
+
if (cycle->prefix.data == NULL) {
|
100
|
+
ngx_destroy_pool(pool);
|
101
|
+
return NULL;
|
102
|
+
}
|
103
|
+
|
104
|
+
cycle->conf_file.len = old_cycle->conf_file.len;
|
105
|
+
cycle->conf_file.data = ngx_pnalloc(pool, old_cycle->conf_file.len + 1);
|
106
|
+
if (cycle->conf_file.data == NULL) {
|
107
|
+
ngx_destroy_pool(pool);
|
108
|
+
return NULL;
|
109
|
+
}
|
110
|
+
ngx_cpystrn(cycle->conf_file.data, old_cycle->conf_file.data,
|
111
|
+
old_cycle->conf_file.len + 1);
|
112
|
+
|
113
|
+
cycle->conf_param.len = old_cycle->conf_param.len;
|
114
|
+
cycle->conf_param.data = ngx_pstrdup(pool, &old_cycle->conf_param);
|
115
|
+
if (cycle->conf_param.data == NULL) {
|
116
|
+
ngx_destroy_pool(pool);
|
117
|
+
return NULL;
|
118
|
+
}
|
119
|
+
|
120
|
+
|
121
|
+
n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10;
|
122
|
+
|
123
|
+
cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *));
|
124
|
+
if (cycle->pathes.elts == NULL) {
|
125
|
+
ngx_destroy_pool(pool);
|
126
|
+
return NULL;
|
127
|
+
}
|
128
|
+
|
129
|
+
cycle->pathes.nelts = 0;
|
130
|
+
cycle->pathes.size = sizeof(ngx_path_t *);
|
131
|
+
cycle->pathes.nalloc = n;
|
132
|
+
cycle->pathes.pool = pool;
|
133
|
+
|
134
|
+
|
135
|
+
if (old_cycle->open_files.part.nelts) {
|
136
|
+
n = old_cycle->open_files.part.nelts;
|
137
|
+
for (part = old_cycle->open_files.part.next; part; part = part->next) {
|
138
|
+
n += part->nelts;
|
139
|
+
}
|
140
|
+
|
141
|
+
} else {
|
142
|
+
n = 20;
|
143
|
+
}
|
144
|
+
|
145
|
+
if (ngx_list_init(&cycle->open_files, pool, n, sizeof(ngx_open_file_t))
|
146
|
+
!= NGX_OK)
|
147
|
+
{
|
148
|
+
ngx_destroy_pool(pool);
|
149
|
+
return NULL;
|
150
|
+
}
|
151
|
+
|
152
|
+
|
153
|
+
if (old_cycle->shared_memory.part.nelts) {
|
154
|
+
n = old_cycle->shared_memory.part.nelts;
|
155
|
+
for (part = old_cycle->shared_memory.part.next; part; part = part->next)
|
156
|
+
{
|
157
|
+
n += part->nelts;
|
158
|
+
}
|
159
|
+
|
160
|
+
} else {
|
161
|
+
n = 1;
|
162
|
+
}
|
163
|
+
|
164
|
+
if (ngx_list_init(&cycle->shared_memory, pool, n, sizeof(ngx_shm_zone_t))
|
165
|
+
!= NGX_OK)
|
166
|
+
{
|
167
|
+
ngx_destroy_pool(pool);
|
168
|
+
return NULL;
|
169
|
+
}
|
170
|
+
|
171
|
+
n = old_cycle->listening.nelts ? old_cycle->listening.nelts : 10;
|
172
|
+
|
173
|
+
cycle->listening.elts = ngx_pcalloc(pool, n * sizeof(ngx_listening_t));
|
174
|
+
if (cycle->listening.elts == NULL) {
|
175
|
+
ngx_destroy_pool(pool);
|
176
|
+
return NULL;
|
177
|
+
}
|
178
|
+
|
179
|
+
cycle->listening.nelts = 0;
|
180
|
+
cycle->listening.size = sizeof(ngx_listening_t);
|
181
|
+
cycle->listening.nalloc = n;
|
182
|
+
cycle->listening.pool = pool;
|
183
|
+
|
184
|
+
|
185
|
+
ngx_queue_init(&cycle->reusable_connections_queue);
|
186
|
+
|
187
|
+
|
188
|
+
cycle->conf_ctx = ngx_pcalloc(pool, ngx_max_module * sizeof(void *));
|
189
|
+
if (cycle->conf_ctx == NULL) {
|
190
|
+
ngx_destroy_pool(pool);
|
191
|
+
return NULL;
|
192
|
+
}
|
193
|
+
|
194
|
+
|
195
|
+
if (gethostname(hostname, NGX_MAXHOSTNAMELEN) == -1) {
|
196
|
+
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "gethostname() failed");
|
197
|
+
ngx_destroy_pool(pool);
|
198
|
+
return NULL;
|
199
|
+
}
|
200
|
+
|
201
|
+
/* on Linux gethostname() silently truncates name that does not fit */
|
202
|
+
|
203
|
+
hostname[NGX_MAXHOSTNAMELEN - 1] = '\0';
|
204
|
+
cycle->hostname.len = ngx_strlen(hostname);
|
205
|
+
|
206
|
+
cycle->hostname.data = ngx_pnalloc(pool, cycle->hostname.len);
|
207
|
+
if (cycle->hostname.data == NULL) {
|
208
|
+
ngx_destroy_pool(pool);
|
209
|
+
return NULL;
|
210
|
+
}
|
211
|
+
|
212
|
+
ngx_strlow(cycle->hostname.data, (u_char *) hostname, cycle->hostname.len);
|
213
|
+
|
214
|
+
|
215
|
+
for (i = 0; ngx_modules[i]; i++) {
|
216
|
+
if (ngx_modules[i]->type != NGX_CORE_MODULE) {
|
217
|
+
continue;
|
218
|
+
}
|
219
|
+
|
220
|
+
module = ngx_modules[i]->ctx;
|
221
|
+
|
222
|
+
if (module->create_conf) {
|
223
|
+
rv = module->create_conf(cycle);
|
224
|
+
if (rv == NULL) {
|
225
|
+
ngx_destroy_pool(pool);
|
226
|
+
return NULL;
|
227
|
+
}
|
228
|
+
cycle->conf_ctx[ngx_modules[i]->index] = rv;
|
229
|
+
}
|
230
|
+
}
|
231
|
+
|
232
|
+
|
233
|
+
senv = environ;
|
234
|
+
|
235
|
+
|
236
|
+
ngx_memzero(&conf, sizeof(ngx_conf_t));
|
237
|
+
/* STUB: init array ? */
|
238
|
+
conf.args = ngx_array_create(pool, 10, sizeof(ngx_str_t));
|
239
|
+
if (conf.args == NULL) {
|
240
|
+
ngx_destroy_pool(pool);
|
241
|
+
return NULL;
|
242
|
+
}
|
243
|
+
|
244
|
+
conf.temp_pool = ngx_create_pool(NGX_CYCLE_POOL_SIZE, log);
|
245
|
+
if (conf.temp_pool == NULL) {
|
246
|
+
ngx_destroy_pool(pool);
|
247
|
+
return NULL;
|
248
|
+
}
|
249
|
+
|
250
|
+
|
251
|
+
conf.ctx = cycle->conf_ctx;
|
252
|
+
conf.cycle = cycle;
|
253
|
+
conf.pool = pool;
|
254
|
+
conf.log = log;
|
255
|
+
conf.module_type = NGX_CORE_MODULE;
|
256
|
+
conf.cmd_type = NGX_MAIN_CONF;
|
257
|
+
|
258
|
+
#if 0
|
259
|
+
log->log_level = NGX_LOG_DEBUG_ALL;
|
260
|
+
#endif
|
261
|
+
|
262
|
+
if (ngx_conf_param(&conf) != NGX_CONF_OK) {
|
263
|
+
environ = senv;
|
264
|
+
ngx_destroy_cycle_pools(&conf);
|
265
|
+
return NULL;
|
266
|
+
}
|
267
|
+
|
268
|
+
if (ngx_conf_parse(&conf, &cycle->conf_file) != NGX_CONF_OK) {
|
269
|
+
environ = senv;
|
270
|
+
ngx_destroy_cycle_pools(&conf);
|
271
|
+
return NULL;
|
272
|
+
}
|
273
|
+
|
274
|
+
if (ngx_test_config && !ngx_quiet_mode) {
|
275
|
+
ngx_log_stderr(0, "the configuration file %s syntax is ok",
|
276
|
+
cycle->conf_file.data);
|
277
|
+
}
|
278
|
+
|
279
|
+
for (i = 0; ngx_modules[i]; i++) {
|
280
|
+
if (ngx_modules[i]->type != NGX_CORE_MODULE) {
|
281
|
+
continue;
|
282
|
+
}
|
283
|
+
|
284
|
+
module = ngx_modules[i]->ctx;
|
285
|
+
|
286
|
+
if (module->init_conf) {
|
287
|
+
if (module->init_conf(cycle, cycle->conf_ctx[ngx_modules[i]->index])
|
288
|
+
== NGX_CONF_ERROR)
|
289
|
+
{
|
290
|
+
environ = senv;
|
291
|
+
ngx_destroy_cycle_pools(&conf);
|
292
|
+
return NULL;
|
293
|
+
}
|
294
|
+
}
|
295
|
+
}
|
296
|
+
|
297
|
+
if (ngx_process == NGX_PROCESS_SIGNALLER) {
|
298
|
+
return cycle;
|
299
|
+
}
|
300
|
+
|
301
|
+
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
302
|
+
|
303
|
+
if (ngx_test_config) {
|
304
|
+
|
305
|
+
if (ngx_create_pidfile(&ccf->pid, log) != NGX_OK) {
|
306
|
+
goto failed;
|
307
|
+
}
|
308
|
+
|
309
|
+
} else if (!ngx_is_init_cycle(old_cycle)) {
|
310
|
+
|
311
|
+
/*
|
312
|
+
* we do not create the pid file in the first ngx_init_cycle() call
|
313
|
+
* because we need to write the demonized process pid
|
314
|
+
*/
|
315
|
+
|
316
|
+
old_ccf = (ngx_core_conf_t *) ngx_get_conf(old_cycle->conf_ctx,
|
317
|
+
ngx_core_module);
|
318
|
+
if (ccf->pid.len != old_ccf->pid.len
|
319
|
+
|| ngx_strcmp(ccf->pid.data, old_ccf->pid.data) != 0)
|
320
|
+
{
|
321
|
+
/* new pid file name */
|
322
|
+
|
323
|
+
if (ngx_create_pidfile(&ccf->pid, log) != NGX_OK) {
|
324
|
+
goto failed;
|
325
|
+
}
|
326
|
+
|
327
|
+
ngx_delete_pidfile(old_cycle);
|
328
|
+
}
|
329
|
+
}
|
330
|
+
|
331
|
+
|
332
|
+
if (ngx_test_lockfile(cycle->lock_file.data, log) != NGX_OK) {
|
333
|
+
goto failed;
|
334
|
+
}
|
335
|
+
|
336
|
+
|
337
|
+
if (ngx_create_pathes(cycle, ccf->user) != NGX_OK) {
|
338
|
+
goto failed;
|
339
|
+
}
|
340
|
+
|
341
|
+
|
342
|
+
if (cycle->new_log.file == NULL) {
|
343
|
+
cycle->new_log.file = ngx_conf_open_file(cycle, &error_log);
|
344
|
+
if (cycle->new_log.file == NULL) {
|
345
|
+
goto failed;
|
346
|
+
}
|
347
|
+
}
|
348
|
+
|
349
|
+
/* open the new files */
|
350
|
+
|
351
|
+
part = &cycle->open_files.part;
|
352
|
+
file = part->elts;
|
353
|
+
|
354
|
+
for (i = 0; /* void */ ; i++) {
|
355
|
+
|
356
|
+
if (i >= part->nelts) {
|
357
|
+
if (part->next == NULL) {
|
358
|
+
break;
|
359
|
+
}
|
360
|
+
part = part->next;
|
361
|
+
file = part->elts;
|
362
|
+
i = 0;
|
363
|
+
}
|
364
|
+
|
365
|
+
if (file[i].name.len == 0) {
|
366
|
+
continue;
|
367
|
+
}
|
368
|
+
|
369
|
+
file[i].fd = ngx_open_file(file[i].name.data,
|
370
|
+
NGX_FILE_APPEND,
|
371
|
+
NGX_FILE_CREATE_OR_OPEN,
|
372
|
+
NGX_FILE_DEFAULT_ACCESS);
|
373
|
+
|
374
|
+
ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,
|
375
|
+
"log: %p %d \"%s\"",
|
376
|
+
&file[i], file[i].fd, file[i].name.data);
|
377
|
+
|
378
|
+
if (file[i].fd == NGX_INVALID_FILE) {
|
379
|
+
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
380
|
+
ngx_open_file_n " \"%s\" failed",
|
381
|
+
file[i].name.data);
|
382
|
+
goto failed;
|
383
|
+
}
|
384
|
+
|
385
|
+
#if !(NGX_WIN32)
|
386
|
+
if (fcntl(file[i].fd, F_SETFD, FD_CLOEXEC) == -1) {
|
387
|
+
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
388
|
+
"fcntl(FD_CLOEXEC) \"%s\" failed",
|
389
|
+
file[i].name.data);
|
390
|
+
goto failed;
|
391
|
+
}
|
392
|
+
#endif
|
393
|
+
}
|
394
|
+
|
395
|
+
cycle->log = &cycle->new_log;
|
396
|
+
pool->log = &cycle->new_log;
|
397
|
+
|
398
|
+
|
399
|
+
/* create shared memory */
|
400
|
+
|
401
|
+
part = &cycle->shared_memory.part;
|
402
|
+
shm_zone = part->elts;
|
403
|
+
|
404
|
+
for (i = 0; /* void */ ; i++) {
|
405
|
+
|
406
|
+
if (i >= part->nelts) {
|
407
|
+
if (part->next == NULL) {
|
408
|
+
break;
|
409
|
+
}
|
410
|
+
part = part->next;
|
411
|
+
shm_zone = part->elts;
|
412
|
+
i = 0;
|
413
|
+
}
|
414
|
+
|
415
|
+
if (shm_zone[i].shm.size == 0) {
|
416
|
+
ngx_log_error(NGX_LOG_EMERG, log, 0,
|
417
|
+
"zero size shared memory zone \"%V\"",
|
418
|
+
&shm_zone[i].shm.name);
|
419
|
+
goto failed;
|
420
|
+
}
|
421
|
+
|
422
|
+
shm_zone[i].shm.log = cycle->log;
|
423
|
+
|
424
|
+
opart = &old_cycle->shared_memory.part;
|
425
|
+
oshm_zone = opart->elts;
|
426
|
+
|
427
|
+
for (n = 0; /* void */ ; n++) {
|
428
|
+
|
429
|
+
if (n >= opart->nelts) {
|
430
|
+
if (opart->next == NULL) {
|
431
|
+
break;
|
432
|
+
}
|
433
|
+
opart = opart->next;
|
434
|
+
oshm_zone = opart->elts;
|
435
|
+
n = 0;
|
436
|
+
}
|
437
|
+
|
438
|
+
if (shm_zone[i].shm.name.len != oshm_zone[n].shm.name.len) {
|
439
|
+
continue;
|
440
|
+
}
|
441
|
+
|
442
|
+
if (ngx_strncmp(shm_zone[i].shm.name.data,
|
443
|
+
oshm_zone[n].shm.name.data,
|
444
|
+
shm_zone[i].shm.name.len)
|
445
|
+
!= 0)
|
446
|
+
{
|
447
|
+
continue;
|
448
|
+
}
|
449
|
+
|
450
|
+
if (shm_zone[i].shm.size == oshm_zone[n].shm.size) {
|
451
|
+
shm_zone[i].shm.addr = oshm_zone[n].shm.addr;
|
452
|
+
|
453
|
+
if (shm_zone[i].init(&shm_zone[i], oshm_zone[n].data)
|
454
|
+
!= NGX_OK)
|
455
|
+
{
|
456
|
+
goto failed;
|
457
|
+
}
|
458
|
+
|
459
|
+
goto shm_zone_found;
|
460
|
+
}
|
461
|
+
|
462
|
+
ngx_shm_free(&oshm_zone[n].shm);
|
463
|
+
|
464
|
+
break;
|
465
|
+
}
|
466
|
+
|
467
|
+
if (ngx_shm_alloc(&shm_zone[i].shm) != NGX_OK) {
|
468
|
+
goto failed;
|
469
|
+
}
|
470
|
+
|
471
|
+
if (ngx_init_zone_pool(cycle, &shm_zone[i]) != NGX_OK) {
|
472
|
+
goto failed;
|
473
|
+
}
|
474
|
+
|
475
|
+
if (shm_zone[i].init(&shm_zone[i], NULL) != NGX_OK) {
|
476
|
+
goto failed;
|
477
|
+
}
|
478
|
+
|
479
|
+
shm_zone_found:
|
480
|
+
|
481
|
+
continue;
|
482
|
+
}
|
483
|
+
|
484
|
+
|
485
|
+
/* handle the listening sockets */
|
486
|
+
|
487
|
+
if (old_cycle->listening.nelts) {
|
488
|
+
ls = old_cycle->listening.elts;
|
489
|
+
for (i = 0; i < old_cycle->listening.nelts; i++) {
|
490
|
+
ls[i].remain = 0;
|
491
|
+
}
|
492
|
+
|
493
|
+
nls = cycle->listening.elts;
|
494
|
+
for (n = 0; n < cycle->listening.nelts; n++) {
|
495
|
+
|
496
|
+
for (i = 0; i < old_cycle->listening.nelts; i++) {
|
497
|
+
if (ls[i].ignore) {
|
498
|
+
continue;
|
499
|
+
}
|
500
|
+
|
501
|
+
if (ngx_cmp_sockaddr(nls[n].sockaddr, ls[i].sockaddr) == NGX_OK)
|
502
|
+
{
|
503
|
+
nls[n].fd = ls[i].fd;
|
504
|
+
nls[n].previous = &ls[i];
|
505
|
+
ls[i].remain = 1;
|
506
|
+
|
507
|
+
if (ls[n].backlog != nls[i].backlog) {
|
508
|
+
nls[n].listen = 1;
|
509
|
+
}
|
510
|
+
|
511
|
+
#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
|
512
|
+
|
513
|
+
/*
|
514
|
+
* FreeBSD, except the most recent versions,
|
515
|
+
* could not remove accept filter
|
516
|
+
*/
|
517
|
+
nls[n].deferred_accept = ls[i].deferred_accept;
|
518
|
+
|
519
|
+
if (ls[i].accept_filter && nls[n].accept_filter) {
|
520
|
+
if (ngx_strcmp(ls[i].accept_filter,
|
521
|
+
nls[n].accept_filter)
|
522
|
+
!= 0)
|
523
|
+
{
|
524
|
+
nls[n].delete_deferred = 1;
|
525
|
+
nls[n].add_deferred = 1;
|
526
|
+
}
|
527
|
+
|
528
|
+
} else if (ls[i].accept_filter) {
|
529
|
+
nls[n].delete_deferred = 1;
|
530
|
+
|
531
|
+
} else if (nls[n].accept_filter) {
|
532
|
+
nls[n].add_deferred = 1;
|
533
|
+
}
|
534
|
+
#endif
|
535
|
+
|
536
|
+
#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
|
537
|
+
|
538
|
+
if (ls[n].deferred_accept && !nls[n].deferred_accept) {
|
539
|
+
nls[n].delete_deferred = 1;
|
540
|
+
|
541
|
+
} else if (ls[i].deferred_accept != nls[n].deferred_accept)
|
542
|
+
{
|
543
|
+
nls[n].add_deferred = 1;
|
544
|
+
}
|
545
|
+
#endif
|
546
|
+
break;
|
547
|
+
}
|
548
|
+
}
|
549
|
+
|
550
|
+
if (nls[n].fd == -1) {
|
551
|
+
nls[n].open = 1;
|
552
|
+
}
|
553
|
+
}
|
554
|
+
|
555
|
+
} else {
|
556
|
+
ls = cycle->listening.elts;
|
557
|
+
for (i = 0; i < cycle->listening.nelts; i++) {
|
558
|
+
ls[i].open = 1;
|
559
|
+
#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
|
560
|
+
if (ls[i].accept_filter) {
|
561
|
+
ls[i].add_deferred = 1;
|
562
|
+
}
|
563
|
+
#endif
|
564
|
+
#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
|
565
|
+
if (ls[i].deferred_accept) {
|
566
|
+
ls[i].add_deferred = 1;
|
567
|
+
}
|
568
|
+
#endif
|
569
|
+
}
|
570
|
+
}
|
571
|
+
|
572
|
+
if (ngx_open_listening_sockets(cycle) != NGX_OK) {
|
573
|
+
goto failed;
|
574
|
+
}
|
575
|
+
|
576
|
+
if (!ngx_test_config) {
|
577
|
+
ngx_configure_listening_sockets(cycle);
|
578
|
+
}
|
579
|
+
|
580
|
+
|
581
|
+
/* commit the new cycle configuration */
|
582
|
+
|
583
|
+
if (!ngx_use_stderr && cycle->log->file->fd != ngx_stderr) {
|
584
|
+
|
585
|
+
if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {
|
586
|
+
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
587
|
+
ngx_set_stderr_n " failed");
|
588
|
+
}
|
589
|
+
}
|
590
|
+
|
591
|
+
pool->log = cycle->log;
|
592
|
+
|
593
|
+
for (i = 0; ngx_modules[i]; i++) {
|
594
|
+
if (ngx_modules[i]->init_module) {
|
595
|
+
if (ngx_modules[i]->init_module(cycle) != NGX_OK) {
|
596
|
+
/* fatal */
|
597
|
+
exit(1);
|
598
|
+
}
|
599
|
+
}
|
600
|
+
}
|
601
|
+
|
602
|
+
|
603
|
+
/* close and delete stuff that lefts from an old cycle */
|
604
|
+
|
605
|
+
/* free the unnecessary shared memory */
|
606
|
+
|
607
|
+
opart = &old_cycle->shared_memory.part;
|
608
|
+
oshm_zone = opart->elts;
|
609
|
+
|
610
|
+
for (i = 0; /* void */ ; i++) {
|
611
|
+
|
612
|
+
if (i >= opart->nelts) {
|
613
|
+
if (opart->next == NULL) {
|
614
|
+
goto old_shm_zone_done;
|
615
|
+
}
|
616
|
+
opart = opart->next;
|
617
|
+
oshm_zone = opart->elts;
|
618
|
+
i = 0;
|
619
|
+
}
|
620
|
+
|
621
|
+
part = &cycle->shared_memory.part;
|
622
|
+
shm_zone = part->elts;
|
623
|
+
|
624
|
+
for (n = 0; /* void */ ; n++) {
|
625
|
+
|
626
|
+
if (n >= part->nelts) {
|
627
|
+
if (part->next == NULL) {
|
628
|
+
break;
|
629
|
+
}
|
630
|
+
part = part->next;
|
631
|
+
shm_zone = part->elts;
|
632
|
+
n = 0;
|
633
|
+
}
|
634
|
+
|
635
|
+
if (oshm_zone[i].shm.name.len == shm_zone[n].shm.name.len
|
636
|
+
&& ngx_strncmp(oshm_zone[i].shm.name.data,
|
637
|
+
shm_zone[n].shm.name.data,
|
638
|
+
oshm_zone[i].shm.name.len)
|
639
|
+
== 0)
|
640
|
+
{
|
641
|
+
goto live_shm_zone;
|
642
|
+
}
|
643
|
+
}
|
644
|
+
|
645
|
+
ngx_shm_free(&oshm_zone[i].shm);
|
646
|
+
|
647
|
+
live_shm_zone:
|
648
|
+
|
649
|
+
continue;
|
650
|
+
}
|
651
|
+
|
652
|
+
old_shm_zone_done:
|
653
|
+
|
654
|
+
|
655
|
+
/* close the unnecessary listening sockets */
|
656
|
+
|
657
|
+
ls = old_cycle->listening.elts;
|
658
|
+
for (i = 0; i < old_cycle->listening.nelts; i++) {
|
659
|
+
|
660
|
+
if (ls[i].remain || ls[i].fd == -1) {
|
661
|
+
continue;
|
662
|
+
}
|
663
|
+
|
664
|
+
if (ngx_close_socket(ls[i].fd) == -1) {
|
665
|
+
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
666
|
+
ngx_close_socket_n " listening socket on %V failed",
|
667
|
+
&ls[i].addr_text);
|
668
|
+
}
|
669
|
+
|
670
|
+
#if (NGX_HAVE_UNIX_DOMAIN)
|
671
|
+
|
672
|
+
if (ls[i].sockaddr->sa_family == AF_UNIX) {
|
673
|
+
u_char *name;
|
674
|
+
|
675
|
+
name = ls[i].addr_text.data + sizeof("unix:") - 1;
|
676
|
+
|
677
|
+
ngx_log_error(NGX_LOG_WARN, cycle->log, 0,
|
678
|
+
"deleting socket %s", name);
|
679
|
+
|
680
|
+
if (ngx_delete_file(name) == -1) {
|
681
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
|
682
|
+
ngx_delete_file_n " %s failed", name);
|
683
|
+
}
|
684
|
+
}
|
685
|
+
|
686
|
+
#endif
|
687
|
+
}
|
688
|
+
|
689
|
+
|
690
|
+
/* close the unnecessary open files */
|
691
|
+
|
692
|
+
part = &old_cycle->open_files.part;
|
693
|
+
file = part->elts;
|
694
|
+
|
695
|
+
for (i = 0; /* void */ ; i++) {
|
696
|
+
|
697
|
+
if (i >= part->nelts) {
|
698
|
+
if (part->next == NULL) {
|
699
|
+
break;
|
700
|
+
}
|
701
|
+
part = part->next;
|
702
|
+
file = part->elts;
|
703
|
+
i = 0;
|
704
|
+
}
|
705
|
+
|
706
|
+
if (file[i].fd == NGX_INVALID_FILE || file[i].fd == ngx_stderr) {
|
707
|
+
continue;
|
708
|
+
}
|
709
|
+
|
710
|
+
if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) {
|
711
|
+
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
712
|
+
ngx_close_file_n " \"%s\" failed",
|
713
|
+
file[i].name.data);
|
714
|
+
}
|
715
|
+
}
|
716
|
+
|
717
|
+
ngx_destroy_pool(conf.temp_pool);
|
718
|
+
|
719
|
+
if (ngx_process == NGX_PROCESS_MASTER || ngx_is_init_cycle(old_cycle)) {
|
720
|
+
|
721
|
+
/*
|
722
|
+
* perl_destruct() frees environ, if it is not the same as it was at
|
723
|
+
* perl_construct() time, therefore we save the previous cycle
|
724
|
+
* environment before ngx_conf_parse() where it will be changed.
|
725
|
+
*/
|
726
|
+
|
727
|
+
env = environ;
|
728
|
+
environ = senv;
|
729
|
+
|
730
|
+
ngx_destroy_pool(old_cycle->pool);
|
731
|
+
cycle->old_cycle = NULL;
|
732
|
+
|
733
|
+
environ = env;
|
734
|
+
|
735
|
+
return cycle;
|
736
|
+
}
|
737
|
+
|
738
|
+
|
739
|
+
if (ngx_temp_pool == NULL) {
|
740
|
+
ngx_temp_pool = ngx_create_pool(128, cycle->log);
|
741
|
+
if (ngx_temp_pool == NULL) {
|
742
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
|
743
|
+
"could not create ngx_temp_pool");
|
744
|
+
exit(1);
|
745
|
+
}
|
746
|
+
|
747
|
+
n = 10;
|
748
|
+
ngx_old_cycles.elts = ngx_pcalloc(ngx_temp_pool,
|
749
|
+
n * sizeof(ngx_cycle_t *));
|
750
|
+
if (ngx_old_cycles.elts == NULL) {
|
751
|
+
exit(1);
|
752
|
+
}
|
753
|
+
ngx_old_cycles.nelts = 0;
|
754
|
+
ngx_old_cycles.size = sizeof(ngx_cycle_t *);
|
755
|
+
ngx_old_cycles.nalloc = n;
|
756
|
+
ngx_old_cycles.pool = ngx_temp_pool;
|
757
|
+
|
758
|
+
ngx_cleaner_event.handler = ngx_clean_old_cycles;
|
759
|
+
ngx_cleaner_event.log = cycle->log;
|
760
|
+
ngx_cleaner_event.data = &dumb;
|
761
|
+
dumb.fd = (ngx_socket_t) -1;
|
762
|
+
}
|
763
|
+
|
764
|
+
ngx_temp_pool->log = cycle->log;
|
765
|
+
|
766
|
+
old = ngx_array_push(&ngx_old_cycles);
|
767
|
+
if (old == NULL) {
|
768
|
+
exit(1);
|
769
|
+
}
|
770
|
+
*old = old_cycle;
|
771
|
+
|
772
|
+
if (!ngx_cleaner_event.timer_set) {
|
773
|
+
ngx_add_timer(&ngx_cleaner_event, 30000);
|
774
|
+
ngx_cleaner_event.timer_set = 1;
|
775
|
+
}
|
776
|
+
|
777
|
+
return cycle;
|
778
|
+
|
779
|
+
|
780
|
+
failed:
|
781
|
+
|
782
|
+
if (!ngx_is_init_cycle(old_cycle)) {
|
783
|
+
old_ccf = (ngx_core_conf_t *) ngx_get_conf(old_cycle->conf_ctx,
|
784
|
+
ngx_core_module);
|
785
|
+
if (old_ccf->environment) {
|
786
|
+
environ = old_ccf->environment;
|
787
|
+
}
|
788
|
+
}
|
789
|
+
|
790
|
+
/* rollback the new cycle configuration */
|
791
|
+
|
792
|
+
part = &cycle->open_files.part;
|
793
|
+
file = part->elts;
|
794
|
+
|
795
|
+
for (i = 0; /* void */ ; i++) {
|
796
|
+
|
797
|
+
if (i >= part->nelts) {
|
798
|
+
if (part->next == NULL) {
|
799
|
+
break;
|
800
|
+
}
|
801
|
+
part = part->next;
|
802
|
+
file = part->elts;
|
803
|
+
i = 0;
|
804
|
+
}
|
805
|
+
|
806
|
+
if (file[i].fd == NGX_INVALID_FILE || file[i].fd == ngx_stderr) {
|
807
|
+
continue;
|
808
|
+
}
|
809
|
+
|
810
|
+
if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) {
|
811
|
+
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
812
|
+
ngx_close_file_n " \"%s\" failed",
|
813
|
+
file[i].name.data);
|
814
|
+
}
|
815
|
+
}
|
816
|
+
|
817
|
+
if (ngx_test_config) {
|
818
|
+
ngx_destroy_cycle_pools(&conf);
|
819
|
+
return NULL;
|
820
|
+
}
|
821
|
+
|
822
|
+
ls = cycle->listening.elts;
|
823
|
+
for (i = 0; i < cycle->listening.nelts; i++) {
|
824
|
+
if (ls[i].fd == -1 || !ls[i].open) {
|
825
|
+
continue;
|
826
|
+
}
|
827
|
+
|
828
|
+
if (ngx_close_socket(ls[i].fd) == -1) {
|
829
|
+
ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
|
830
|
+
ngx_close_socket_n " %V failed",
|
831
|
+
&ls[i].addr_text);
|
832
|
+
}
|
833
|
+
}
|
834
|
+
|
835
|
+
ngx_destroy_cycle_pools(&conf);
|
836
|
+
|
837
|
+
return NULL;
|
838
|
+
}
|
839
|
+
|
840
|
+
|
841
|
+
static void
|
842
|
+
ngx_destroy_cycle_pools(ngx_conf_t *conf)
|
843
|
+
{
|
844
|
+
ngx_destroy_pool(conf->temp_pool);
|
845
|
+
ngx_destroy_pool(conf->pool);
|
846
|
+
}
|
847
|
+
|
848
|
+
|
849
|
+
static ngx_int_t
|
850
|
+
ngx_cmp_sockaddr(struct sockaddr *sa1, struct sockaddr *sa2)
|
851
|
+
{
|
852
|
+
struct sockaddr_in *sin1, *sin2;
|
853
|
+
#if (NGX_HAVE_INET6)
|
854
|
+
struct sockaddr_in6 *sin61, *sin62;
|
855
|
+
#endif
|
856
|
+
#if (NGX_HAVE_UNIX_DOMAIN)
|
857
|
+
struct sockaddr_un *saun1, *saun2;
|
858
|
+
#endif
|
859
|
+
|
860
|
+
if (sa1->sa_family != sa2->sa_family) {
|
861
|
+
return NGX_DECLINED;
|
862
|
+
}
|
863
|
+
|
864
|
+
switch (sa1->sa_family) {
|
865
|
+
|
866
|
+
#if (NGX_HAVE_INET6)
|
867
|
+
case AF_INET6:
|
868
|
+
sin61 = (struct sockaddr_in6 *) sa1;
|
869
|
+
sin62 = (struct sockaddr_in6 *) sa2;
|
870
|
+
|
871
|
+
if (sin61->sin6_port != sin62->sin6_port) {
|
872
|
+
return NGX_DECLINED;
|
873
|
+
}
|
874
|
+
|
875
|
+
if (ngx_memcmp(&sin61->sin6_addr, &sin62->sin6_addr, 16) != 0) {
|
876
|
+
return NGX_DECLINED;
|
877
|
+
}
|
878
|
+
|
879
|
+
break;
|
880
|
+
#endif
|
881
|
+
|
882
|
+
#if (NGX_HAVE_UNIX_DOMAIN)
|
883
|
+
case AF_UNIX:
|
884
|
+
saun1 = (struct sockaddr_un *) sa1;
|
885
|
+
saun2 = (struct sockaddr_un *) sa2;
|
886
|
+
|
887
|
+
if (ngx_memcmp(&saun1->sun_path, &saun2->sun_path,
|
888
|
+
sizeof(saun1->sun_path))
|
889
|
+
!= 0)
|
890
|
+
{
|
891
|
+
return NGX_DECLINED;
|
892
|
+
}
|
893
|
+
|
894
|
+
break;
|
895
|
+
#endif
|
896
|
+
|
897
|
+
default: /* AF_INET */
|
898
|
+
|
899
|
+
sin1 = (struct sockaddr_in *) sa1;
|
900
|
+
sin2 = (struct sockaddr_in *) sa2;
|
901
|
+
|
902
|
+
if (sin1->sin_port != sin2->sin_port) {
|
903
|
+
return NGX_DECLINED;
|
904
|
+
}
|
905
|
+
|
906
|
+
if (sin1->sin_addr.s_addr != sin2->sin_addr.s_addr) {
|
907
|
+
return NGX_DECLINED;
|
908
|
+
}
|
909
|
+
|
910
|
+
break;
|
911
|
+
}
|
912
|
+
|
913
|
+
return NGX_OK;
|
914
|
+
}
|
915
|
+
|
916
|
+
|
917
|
+
static ngx_int_t
|
918
|
+
ngx_init_zone_pool(ngx_cycle_t *cycle, ngx_shm_zone_t *zn)
|
919
|
+
{
|
920
|
+
u_char *file;
|
921
|
+
ngx_slab_pool_t *sp;
|
922
|
+
|
923
|
+
sp = (ngx_slab_pool_t *) zn->shm.addr;
|
924
|
+
|
925
|
+
if (zn->shm.exists) {
|
926
|
+
|
927
|
+
if (sp == sp->addr) {
|
928
|
+
return NGX_OK;
|
929
|
+
}
|
930
|
+
|
931
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
|
932
|
+
"shared zone \"%V\" has no equal addresses: %p vs %p",
|
933
|
+
&zn->shm.name, sp->addr, sp);
|
934
|
+
return NGX_ERROR;
|
935
|
+
}
|
936
|
+
|
937
|
+
sp->end = zn->shm.addr + zn->shm.size;
|
938
|
+
sp->min_shift = 3;
|
939
|
+
sp->addr = zn->shm.addr;
|
940
|
+
|
941
|
+
#if (NGX_HAVE_ATOMIC_OPS)
|
942
|
+
|
943
|
+
file = NULL;
|
944
|
+
|
945
|
+
#else
|
946
|
+
|
947
|
+
file = ngx_pnalloc(cycle->pool, cycle->lock_file.len + zn->shm.name.len);
|
948
|
+
if (file == NULL) {
|
949
|
+
return NGX_ERROR;
|
950
|
+
}
|
951
|
+
|
952
|
+
(void) ngx_sprintf(file, "%V%V%Z", &cycle->lock_file, &zn->shm.name);
|
953
|
+
|
954
|
+
#endif
|
955
|
+
|
956
|
+
if (ngx_shmtx_create(&sp->mutex, (void *) &sp->lock, file) != NGX_OK) {
|
957
|
+
return NGX_ERROR;
|
958
|
+
}
|
959
|
+
|
960
|
+
ngx_slab_init(sp);
|
961
|
+
|
962
|
+
return NGX_OK;
|
963
|
+
}
|
964
|
+
|
965
|
+
|
966
|
+
ngx_int_t
|
967
|
+
ngx_create_pidfile(ngx_str_t *name, ngx_log_t *log)
|
968
|
+
{
|
969
|
+
size_t len;
|
970
|
+
ngx_uint_t create;
|
971
|
+
ngx_file_t file;
|
972
|
+
u_char pid[NGX_INT64_LEN + 2];
|
973
|
+
|
974
|
+
if (ngx_process > NGX_PROCESS_MASTER) {
|
975
|
+
return NGX_OK;
|
976
|
+
}
|
977
|
+
|
978
|
+
ngx_memzero(&file, sizeof(ngx_file_t));
|
979
|
+
|
980
|
+
file.name = *name;
|
981
|
+
file.log = log;
|
982
|
+
|
983
|
+
create = ngx_test_config ? NGX_FILE_CREATE_OR_OPEN : NGX_FILE_TRUNCATE;
|
984
|
+
|
985
|
+
file.fd = ngx_open_file(file.name.data, NGX_FILE_RDWR,
|
986
|
+
create, NGX_FILE_DEFAULT_ACCESS);
|
987
|
+
|
988
|
+
if (file.fd == NGX_INVALID_FILE) {
|
989
|
+
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
990
|
+
ngx_open_file_n " \"%s\" failed", file.name.data);
|
991
|
+
return NGX_ERROR;
|
992
|
+
}
|
993
|
+
|
994
|
+
if (!ngx_test_config) {
|
995
|
+
len = ngx_snprintf(pid, NGX_INT64_LEN + 2, "%P%N", ngx_pid) - pid;
|
996
|
+
|
997
|
+
if (ngx_write_file(&file, pid, len, 0) == NGX_ERROR) {
|
998
|
+
return NGX_ERROR;
|
999
|
+
}
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
if (ngx_close_file(file.fd) == NGX_FILE_ERROR) {
|
1003
|
+
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
1004
|
+
ngx_close_file_n " \"%s\" failed", file.name.data);
|
1005
|
+
}
|
1006
|
+
|
1007
|
+
return NGX_OK;
|
1008
|
+
}
|
1009
|
+
|
1010
|
+
|
1011
|
+
void
|
1012
|
+
ngx_delete_pidfile(ngx_cycle_t *cycle)
|
1013
|
+
{
|
1014
|
+
u_char *name;
|
1015
|
+
ngx_core_conf_t *ccf;
|
1016
|
+
|
1017
|
+
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
1018
|
+
|
1019
|
+
name = ngx_new_binary ? ccf->oldpid.data : ccf->pid.data;
|
1020
|
+
|
1021
|
+
if (ngx_delete_file(name) == NGX_FILE_ERROR) {
|
1022
|
+
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
1023
|
+
ngx_delete_file_n " \"%s\" failed", name);
|
1024
|
+
}
|
1025
|
+
}
|
1026
|
+
|
1027
|
+
|
1028
|
+
ngx_int_t
|
1029
|
+
ngx_signal_process(ngx_cycle_t *cycle, char *sig)
|
1030
|
+
{
|
1031
|
+
ssize_t n;
|
1032
|
+
ngx_int_t pid;
|
1033
|
+
ngx_file_t file;
|
1034
|
+
ngx_core_conf_t *ccf;
|
1035
|
+
u_char buf[NGX_INT64_LEN + 2];
|
1036
|
+
|
1037
|
+
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "signal process started");
|
1038
|
+
|
1039
|
+
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
|
1040
|
+
|
1041
|
+
file.name = ccf->pid;
|
1042
|
+
file.log = cycle->log;
|
1043
|
+
|
1044
|
+
file.fd = ngx_open_file(file.name.data, NGX_FILE_RDONLY,
|
1045
|
+
NGX_FILE_OPEN, NGX_FILE_DEFAULT_ACCESS);
|
1046
|
+
|
1047
|
+
if (file.fd == NGX_INVALID_FILE) {
|
1048
|
+
ngx_log_error(NGX_LOG_ERR, cycle->log, ngx_errno,
|
1049
|
+
ngx_open_file_n " \"%s\" failed", file.name.data);
|
1050
|
+
return 1;
|
1051
|
+
}
|
1052
|
+
|
1053
|
+
n = ngx_read_file(&file, buf, NGX_INT64_LEN + 2, 0);
|
1054
|
+
|
1055
|
+
if (ngx_close_file(file.fd) == NGX_FILE_ERROR) {
|
1056
|
+
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
1057
|
+
ngx_close_file_n " \"%s\" failed", file.name.data);
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
if (n == NGX_ERROR) {
|
1061
|
+
return 1;
|
1062
|
+
}
|
1063
|
+
|
1064
|
+
while (n-- && (buf[n] == CR || buf[n] == LF)) { /* void */ }
|
1065
|
+
|
1066
|
+
pid = ngx_atoi(buf, ++n);
|
1067
|
+
|
1068
|
+
if (pid == NGX_ERROR) {
|
1069
|
+
ngx_log_error(NGX_LOG_ERR, cycle->log, 0,
|
1070
|
+
"invalid PID number \"%*s\" in \"%s\"",
|
1071
|
+
n, buf, file.name.data);
|
1072
|
+
return 1;
|
1073
|
+
}
|
1074
|
+
|
1075
|
+
return ngx_os_signal_process(cycle, sig, pid);
|
1076
|
+
|
1077
|
+
}
|
1078
|
+
|
1079
|
+
|
1080
|
+
static ngx_int_t
|
1081
|
+
ngx_test_lockfile(u_char *file, ngx_log_t *log)
|
1082
|
+
{
|
1083
|
+
#if !(NGX_HAVE_ATOMIC_OPS)
|
1084
|
+
ngx_fd_t fd;
|
1085
|
+
|
1086
|
+
fd = ngx_open_file(file, NGX_FILE_RDWR, NGX_FILE_CREATE_OR_OPEN,
|
1087
|
+
NGX_FILE_DEFAULT_ACCESS);
|
1088
|
+
|
1089
|
+
if (fd == NGX_INVALID_FILE) {
|
1090
|
+
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
|
1091
|
+
ngx_open_file_n " \"%s\" failed", file);
|
1092
|
+
return NGX_ERROR;
|
1093
|
+
}
|
1094
|
+
|
1095
|
+
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
|
1096
|
+
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
1097
|
+
ngx_close_file_n " \"%s\" failed", file);
|
1098
|
+
}
|
1099
|
+
|
1100
|
+
if (ngx_delete_file(file) == NGX_FILE_ERROR) {
|
1101
|
+
ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
|
1102
|
+
ngx_delete_file_n " \"%s\" failed", file);
|
1103
|
+
}
|
1104
|
+
|
1105
|
+
#endif
|
1106
|
+
|
1107
|
+
return NGX_OK;
|
1108
|
+
}
|
1109
|
+
|
1110
|
+
|
1111
|
+
void
|
1112
|
+
ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
|
1113
|
+
{
|
1114
|
+
ssize_t n, len;
|
1115
|
+
ngx_fd_t fd;
|
1116
|
+
ngx_uint_t i;
|
1117
|
+
ngx_list_part_t *part;
|
1118
|
+
ngx_open_file_t *file;
|
1119
|
+
|
1120
|
+
part = &cycle->open_files.part;
|
1121
|
+
file = part->elts;
|
1122
|
+
|
1123
|
+
for (i = 0; /* void */ ; i++) {
|
1124
|
+
|
1125
|
+
if (i >= part->nelts) {
|
1126
|
+
if (part->next == NULL) {
|
1127
|
+
break;
|
1128
|
+
}
|
1129
|
+
part = part->next;
|
1130
|
+
file = part->elts;
|
1131
|
+
i = 0;
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
if (file[i].name.len == 0) {
|
1135
|
+
continue;
|
1136
|
+
}
|
1137
|
+
|
1138
|
+
len = file[i].pos - file[i].buffer;
|
1139
|
+
|
1140
|
+
if (file[i].buffer && len != 0) {
|
1141
|
+
|
1142
|
+
n = ngx_write_fd(file[i].fd, file[i].buffer, len);
|
1143
|
+
|
1144
|
+
if (n == NGX_FILE_ERROR) {
|
1145
|
+
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
|
1146
|
+
ngx_write_fd_n " to \"%s\" failed",
|
1147
|
+
file[i].name.data);
|
1148
|
+
|
1149
|
+
} else if (n != len) {
|
1150
|
+
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
|
1151
|
+
ngx_write_fd_n " to \"%s\" was incomplete: %z of %uz",
|
1152
|
+
file[i].name.data, n, len);
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
file[i].pos = file[i].buffer;
|
1156
|
+
}
|
1157
|
+
|
1158
|
+
fd = ngx_open_file(file[i].name.data, NGX_FILE_APPEND,
|
1159
|
+
NGX_FILE_CREATE_OR_OPEN, NGX_FILE_DEFAULT_ACCESS);
|
1160
|
+
|
1161
|
+
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
1162
|
+
"reopen file \"%s\", old:%d new:%d",
|
1163
|
+
file[i].name.data, file[i].fd, fd);
|
1164
|
+
|
1165
|
+
if (fd == NGX_INVALID_FILE) {
|
1166
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
1167
|
+
ngx_open_file_n " \"%s\" failed", file[i].name.data);
|
1168
|
+
continue;
|
1169
|
+
}
|
1170
|
+
|
1171
|
+
#if !(NGX_WIN32)
|
1172
|
+
if (user != (ngx_uid_t) NGX_CONF_UNSET_UINT) {
|
1173
|
+
ngx_file_info_t fi;
|
1174
|
+
|
1175
|
+
if (ngx_file_info((const char *) file[i].name.data, &fi)
|
1176
|
+
== NGX_FILE_ERROR)
|
1177
|
+
{
|
1178
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
1179
|
+
ngx_file_info_n " \"%s\" failed",
|
1180
|
+
file[i].name.data);
|
1181
|
+
|
1182
|
+
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
|
1183
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
1184
|
+
ngx_close_file_n " \"%s\" failed",
|
1185
|
+
file[i].name.data);
|
1186
|
+
}
|
1187
|
+
}
|
1188
|
+
|
1189
|
+
if (fi.st_uid != user) {
|
1190
|
+
if (chown((const char *) file[i].name.data, user, -1) == -1) {
|
1191
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
1192
|
+
"chown(\"%s\", %d) failed",
|
1193
|
+
file[i].name.data, user);
|
1194
|
+
|
1195
|
+
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
|
1196
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
1197
|
+
ngx_close_file_n " \"%s\" failed",
|
1198
|
+
file[i].name.data);
|
1199
|
+
}
|
1200
|
+
}
|
1201
|
+
}
|
1202
|
+
|
1203
|
+
if ((fi.st_mode & (S_IRUSR|S_IWUSR)) != (S_IRUSR|S_IWUSR)) {
|
1204
|
+
|
1205
|
+
fi.st_mode |= (S_IRUSR|S_IWUSR);
|
1206
|
+
|
1207
|
+
if (chmod((const char *) file[i].name.data, fi.st_mode) == -1) {
|
1208
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
1209
|
+
"chmod() \"%s\" failed", file[i].name.data);
|
1210
|
+
|
1211
|
+
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
|
1212
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
1213
|
+
ngx_close_file_n " \"%s\" failed",
|
1214
|
+
file[i].name.data);
|
1215
|
+
}
|
1216
|
+
}
|
1217
|
+
}
|
1218
|
+
}
|
1219
|
+
|
1220
|
+
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
|
1221
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
1222
|
+
"fcntl(FD_CLOEXEC) \"%s\" failed",
|
1223
|
+
file[i].name.data);
|
1224
|
+
|
1225
|
+
if (ngx_close_file(fd) == NGX_FILE_ERROR) {
|
1226
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
1227
|
+
ngx_close_file_n " \"%s\" failed",
|
1228
|
+
file[i].name.data);
|
1229
|
+
}
|
1230
|
+
|
1231
|
+
continue;
|
1232
|
+
}
|
1233
|
+
#endif
|
1234
|
+
|
1235
|
+
if (ngx_close_file(file[i].fd) == NGX_FILE_ERROR) {
|
1236
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
1237
|
+
ngx_close_file_n " \"%s\" failed",
|
1238
|
+
file[i].name.data);
|
1239
|
+
}
|
1240
|
+
|
1241
|
+
file[i].fd = fd;
|
1242
|
+
}
|
1243
|
+
|
1244
|
+
#if !(NGX_WIN32)
|
1245
|
+
|
1246
|
+
if (cycle->log->file->fd != STDERR_FILENO) {
|
1247
|
+
if (dup2(cycle->log->file->fd, STDERR_FILENO) == -1) {
|
1248
|
+
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
|
1249
|
+
"dup2(STDERR) failed");
|
1250
|
+
}
|
1251
|
+
}
|
1252
|
+
|
1253
|
+
#endif
|
1254
|
+
}
|
1255
|
+
|
1256
|
+
|
1257
|
+
ngx_shm_zone_t *
|
1258
|
+
ngx_shared_memory_add(ngx_conf_t *cf, ngx_str_t *name, size_t size, void *tag)
|
1259
|
+
{
|
1260
|
+
ngx_uint_t i;
|
1261
|
+
ngx_shm_zone_t *shm_zone;
|
1262
|
+
ngx_list_part_t *part;
|
1263
|
+
|
1264
|
+
part = &cf->cycle->shared_memory.part;
|
1265
|
+
shm_zone = part->elts;
|
1266
|
+
|
1267
|
+
for (i = 0; /* void */ ; i++) {
|
1268
|
+
|
1269
|
+
if (i >= part->nelts) {
|
1270
|
+
if (part->next == NULL) {
|
1271
|
+
break;
|
1272
|
+
}
|
1273
|
+
part = part->next;
|
1274
|
+
shm_zone = part->elts;
|
1275
|
+
i = 0;
|
1276
|
+
}
|
1277
|
+
|
1278
|
+
if (name->len != shm_zone[i].shm.name.len) {
|
1279
|
+
continue;
|
1280
|
+
}
|
1281
|
+
|
1282
|
+
if (ngx_strncmp(name->data, shm_zone[i].shm.name.data, name->len)
|
1283
|
+
!= 0)
|
1284
|
+
{
|
1285
|
+
continue;
|
1286
|
+
}
|
1287
|
+
|
1288
|
+
if (size && size != shm_zone[i].shm.size) {
|
1289
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1290
|
+
"the size %uz of shared memory zone \"%V\" "
|
1291
|
+
"conflicts with already declared size %uz",
|
1292
|
+
size, &shm_zone[i].shm.name, shm_zone[i].shm.size);
|
1293
|
+
return NULL;
|
1294
|
+
}
|
1295
|
+
|
1296
|
+
if (tag != shm_zone[i].tag) {
|
1297
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1298
|
+
"the shared memory zone \"%V\" is "
|
1299
|
+
"already declared for a different use",
|
1300
|
+
&shm_zone[i].shm.name);
|
1301
|
+
return NULL;
|
1302
|
+
}
|
1303
|
+
|
1304
|
+
return &shm_zone[i];
|
1305
|
+
}
|
1306
|
+
|
1307
|
+
shm_zone = ngx_list_push(&cf->cycle->shared_memory);
|
1308
|
+
|
1309
|
+
if (shm_zone == NULL) {
|
1310
|
+
return NULL;
|
1311
|
+
}
|
1312
|
+
|
1313
|
+
shm_zone->data = NULL;
|
1314
|
+
shm_zone->shm.log = cf->cycle->log;
|
1315
|
+
shm_zone->shm.size = size;
|
1316
|
+
shm_zone->shm.name = *name;
|
1317
|
+
shm_zone->shm.exists = 0;
|
1318
|
+
shm_zone->init = NULL;
|
1319
|
+
shm_zone->tag = tag;
|
1320
|
+
|
1321
|
+
return shm_zone;
|
1322
|
+
}
|
1323
|
+
|
1324
|
+
|
1325
|
+
static void
|
1326
|
+
ngx_clean_old_cycles(ngx_event_t *ev)
|
1327
|
+
{
|
1328
|
+
ngx_uint_t i, n, found, live;
|
1329
|
+
ngx_log_t *log;
|
1330
|
+
ngx_cycle_t **cycle;
|
1331
|
+
|
1332
|
+
log = ngx_cycle->log;
|
1333
|
+
ngx_temp_pool->log = log;
|
1334
|
+
|
1335
|
+
ngx_log_debug0(NGX_LOG_DEBUG_CORE, log, 0, "clean old cycles");
|
1336
|
+
|
1337
|
+
live = 0;
|
1338
|
+
|
1339
|
+
cycle = ngx_old_cycles.elts;
|
1340
|
+
for (i = 0; i < ngx_old_cycles.nelts; i++) {
|
1341
|
+
|
1342
|
+
if (cycle[i] == NULL) {
|
1343
|
+
continue;
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
found = 0;
|
1347
|
+
|
1348
|
+
for (n = 0; n < cycle[i]->connection_n; n++) {
|
1349
|
+
if (cycle[i]->connections[n].fd != (ngx_socket_t) -1) {
|
1350
|
+
found = 1;
|
1351
|
+
|
1352
|
+
ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "live fd:%d", n);
|
1353
|
+
|
1354
|
+
break;
|
1355
|
+
}
|
1356
|
+
}
|
1357
|
+
|
1358
|
+
if (found) {
|
1359
|
+
live = 1;
|
1360
|
+
continue;
|
1361
|
+
}
|
1362
|
+
|
1363
|
+
ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "clean old cycle: %d", i);
|
1364
|
+
|
1365
|
+
ngx_destroy_pool(cycle[i]->pool);
|
1366
|
+
cycle[i] = NULL;
|
1367
|
+
}
|
1368
|
+
|
1369
|
+
ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, "old cycles status: %d", live);
|
1370
|
+
|
1371
|
+
if (live) {
|
1372
|
+
ngx_add_timer(ev, 30000);
|
1373
|
+
|
1374
|
+
} else {
|
1375
|
+
ngx_destroy_pool(ngx_temp_pool);
|
1376
|
+
ngx_temp_pool = NULL;
|
1377
|
+
ngx_old_cycles.nelts = 0;
|
1378
|
+
}
|
1379
|
+
}
|