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,162 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Copyright (C) Igor Sysoev
|
4
|
+
* Copyright (C) Nginx, Inc.
|
5
|
+
*/
|
6
|
+
|
7
|
+
|
8
|
+
#ifndef _NGX_EVENT_OPENSSL_H_INCLUDED_
|
9
|
+
#define _NGX_EVENT_OPENSSL_H_INCLUDED_
|
10
|
+
|
11
|
+
|
12
|
+
#include <ngx_config.h>
|
13
|
+
#include <ngx_core.h>
|
14
|
+
|
15
|
+
#include <openssl/ssl.h>
|
16
|
+
#include <openssl/err.h>
|
17
|
+
#include <openssl/conf.h>
|
18
|
+
#include <openssl/engine.h>
|
19
|
+
#include <openssl/evp.h>
|
20
|
+
|
21
|
+
#define NGX_SSL_NAME "OpenSSL"
|
22
|
+
|
23
|
+
|
24
|
+
#define ngx_ssl_session_t SSL_SESSION
|
25
|
+
#define ngx_ssl_conn_t SSL
|
26
|
+
|
27
|
+
|
28
|
+
typedef struct {
|
29
|
+
SSL_CTX *ctx;
|
30
|
+
ngx_log_t *log;
|
31
|
+
} ngx_ssl_t;
|
32
|
+
|
33
|
+
|
34
|
+
typedef struct {
|
35
|
+
ngx_ssl_conn_t *connection;
|
36
|
+
|
37
|
+
ngx_int_t last;
|
38
|
+
ngx_buf_t *buf;
|
39
|
+
|
40
|
+
ngx_connection_handler_pt handler;
|
41
|
+
|
42
|
+
ngx_event_handler_pt saved_read_handler;
|
43
|
+
ngx_event_handler_pt saved_write_handler;
|
44
|
+
|
45
|
+
unsigned handshaked:1;
|
46
|
+
unsigned renegotiation:1;
|
47
|
+
unsigned buffer:1;
|
48
|
+
unsigned no_wait_shutdown:1;
|
49
|
+
unsigned no_send_shutdown:1;
|
50
|
+
} ngx_ssl_connection_t;
|
51
|
+
|
52
|
+
|
53
|
+
#define NGX_SSL_NO_SCACHE -2
|
54
|
+
#define NGX_SSL_NONE_SCACHE -3
|
55
|
+
#define NGX_SSL_NO_BUILTIN_SCACHE -4
|
56
|
+
#define NGX_SSL_DFLT_BUILTIN_SCACHE -5
|
57
|
+
|
58
|
+
|
59
|
+
#define NGX_SSL_MAX_SESSION_SIZE 4096
|
60
|
+
|
61
|
+
typedef struct ngx_ssl_sess_id_s ngx_ssl_sess_id_t;
|
62
|
+
|
63
|
+
struct ngx_ssl_sess_id_s {
|
64
|
+
ngx_rbtree_node_t node;
|
65
|
+
u_char *id;
|
66
|
+
size_t len;
|
67
|
+
u_char *session;
|
68
|
+
ngx_queue_t queue;
|
69
|
+
time_t expire;
|
70
|
+
#if (NGX_PTR_SIZE == 8)
|
71
|
+
void *stub;
|
72
|
+
u_char sess_id[32];
|
73
|
+
#endif
|
74
|
+
};
|
75
|
+
|
76
|
+
|
77
|
+
typedef struct {
|
78
|
+
ngx_rbtree_t session_rbtree;
|
79
|
+
ngx_rbtree_node_t sentinel;
|
80
|
+
ngx_queue_t expire_queue;
|
81
|
+
} ngx_ssl_session_cache_t;
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
#define NGX_SSL_SSLv2 0x0002
|
86
|
+
#define NGX_SSL_SSLv3 0x0004
|
87
|
+
#define NGX_SSL_TLSv1 0x0008
|
88
|
+
#define NGX_SSL_TLSv1_1 0x0010
|
89
|
+
#define NGX_SSL_TLSv1_2 0x0020
|
90
|
+
|
91
|
+
|
92
|
+
#define NGX_SSL_BUFFER 1
|
93
|
+
#define NGX_SSL_CLIENT 2
|
94
|
+
|
95
|
+
#define NGX_SSL_BUFSIZE 16384
|
96
|
+
|
97
|
+
|
98
|
+
ngx_int_t ngx_ssl_init(ngx_log_t *log);
|
99
|
+
ngx_int_t ngx_ssl_create(ngx_ssl_t *ssl, ngx_uint_t protocols, void *data);
|
100
|
+
ngx_int_t ngx_ssl_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl,
|
101
|
+
ngx_str_t *cert, ngx_str_t *key);
|
102
|
+
ngx_int_t ngx_ssl_client_certificate(ngx_conf_t *cf, ngx_ssl_t *ssl,
|
103
|
+
ngx_str_t *cert, ngx_int_t depth);
|
104
|
+
ngx_int_t ngx_ssl_crl(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *crl);
|
105
|
+
RSA *ngx_ssl_rsa512_key_callback(SSL *ssl, int is_export, int key_length);
|
106
|
+
ngx_int_t ngx_ssl_dhparam(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *file);
|
107
|
+
ngx_int_t ngx_ssl_ecdh_curve(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *name);
|
108
|
+
ngx_int_t ngx_ssl_session_cache(ngx_ssl_t *ssl, ngx_str_t *sess_ctx,
|
109
|
+
ssize_t builtin_session_cache, ngx_shm_zone_t *shm_zone, time_t timeout);
|
110
|
+
ngx_int_t ngx_ssl_session_cache_init(ngx_shm_zone_t *shm_zone, void *data);
|
111
|
+
ngx_int_t ngx_ssl_create_connection(ngx_ssl_t *ssl, ngx_connection_t *c,
|
112
|
+
ngx_uint_t flags);
|
113
|
+
|
114
|
+
void ngx_ssl_remove_cached_session(SSL_CTX *ssl, ngx_ssl_session_t *sess);
|
115
|
+
ngx_int_t ngx_ssl_set_session(ngx_connection_t *c, ngx_ssl_session_t *session);
|
116
|
+
#define ngx_ssl_get_session(c) SSL_get1_session(c->ssl->connection)
|
117
|
+
#define ngx_ssl_free_session SSL_SESSION_free
|
118
|
+
#define ngx_ssl_get_connection(ssl_conn) \
|
119
|
+
SSL_get_ex_data(ssl_conn, ngx_ssl_connection_index)
|
120
|
+
#define ngx_ssl_get_server_conf(ssl_ctx) \
|
121
|
+
SSL_CTX_get_ex_data(ssl_ctx, ngx_ssl_server_conf_index)
|
122
|
+
|
123
|
+
|
124
|
+
ngx_int_t ngx_ssl_get_protocol(ngx_connection_t *c, ngx_pool_t *pool,
|
125
|
+
ngx_str_t *s);
|
126
|
+
ngx_int_t ngx_ssl_get_cipher_name(ngx_connection_t *c, ngx_pool_t *pool,
|
127
|
+
ngx_str_t *s);
|
128
|
+
ngx_int_t ngx_ssl_get_session_id(ngx_connection_t *c, ngx_pool_t *pool,
|
129
|
+
ngx_str_t *s);
|
130
|
+
ngx_int_t ngx_ssl_get_raw_certificate(ngx_connection_t *c, ngx_pool_t *pool,
|
131
|
+
ngx_str_t *s);
|
132
|
+
ngx_int_t ngx_ssl_get_certificate(ngx_connection_t *c, ngx_pool_t *pool,
|
133
|
+
ngx_str_t *s);
|
134
|
+
ngx_int_t ngx_ssl_get_subject_dn(ngx_connection_t *c, ngx_pool_t *pool,
|
135
|
+
ngx_str_t *s);
|
136
|
+
ngx_int_t ngx_ssl_get_issuer_dn(ngx_connection_t *c, ngx_pool_t *pool,
|
137
|
+
ngx_str_t *s);
|
138
|
+
ngx_int_t ngx_ssl_get_serial_number(ngx_connection_t *c, ngx_pool_t *pool,
|
139
|
+
ngx_str_t *s);
|
140
|
+
ngx_int_t ngx_ssl_get_client_verify(ngx_connection_t *c, ngx_pool_t *pool,
|
141
|
+
ngx_str_t *s);
|
142
|
+
|
143
|
+
|
144
|
+
ngx_int_t ngx_ssl_handshake(ngx_connection_t *c);
|
145
|
+
ssize_t ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size);
|
146
|
+
ssize_t ngx_ssl_write(ngx_connection_t *c, u_char *data, size_t size);
|
147
|
+
ssize_t ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl);
|
148
|
+
ngx_chain_t *ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in,
|
149
|
+
off_t limit);
|
150
|
+
void ngx_ssl_free_buffer(ngx_connection_t *c);
|
151
|
+
ngx_int_t ngx_ssl_shutdown(ngx_connection_t *c);
|
152
|
+
void ngx_cdecl ngx_ssl_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
|
153
|
+
char *fmt, ...);
|
154
|
+
void ngx_ssl_cleanup_ctx(void *data);
|
155
|
+
|
156
|
+
|
157
|
+
extern int ngx_ssl_connection_index;
|
158
|
+
extern int ngx_ssl_server_conf_index;
|
159
|
+
extern int ngx_ssl_session_cache_index;
|
160
|
+
|
161
|
+
|
162
|
+
#endif /* _NGX_EVENT_OPENSSL_H_INCLUDED_ */
|
@@ -0,0 +1,996 @@
|
|
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
|
+
#include <ngx_event_pipe.h>
|
12
|
+
|
13
|
+
|
14
|
+
static ngx_int_t ngx_event_pipe_read_upstream(ngx_event_pipe_t *p);
|
15
|
+
static ngx_int_t ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p);
|
16
|
+
|
17
|
+
static ngx_int_t ngx_event_pipe_write_chain_to_temp_file(ngx_event_pipe_t *p);
|
18
|
+
static ngx_inline void ngx_event_pipe_remove_shadow_links(ngx_buf_t *buf);
|
19
|
+
static ngx_inline void ngx_event_pipe_free_shadow_raw_buf(ngx_chain_t **free,
|
20
|
+
ngx_buf_t *buf);
|
21
|
+
static ngx_int_t ngx_event_pipe_drain_chains(ngx_event_pipe_t *p);
|
22
|
+
|
23
|
+
|
24
|
+
ngx_int_t
|
25
|
+
ngx_event_pipe(ngx_event_pipe_t *p, ngx_int_t do_write)
|
26
|
+
{
|
27
|
+
u_int flags;
|
28
|
+
ngx_int_t rc;
|
29
|
+
ngx_event_t *rev, *wev;
|
30
|
+
|
31
|
+
for ( ;; ) {
|
32
|
+
if (do_write) {
|
33
|
+
p->log->action = "sending to client";
|
34
|
+
|
35
|
+
rc = ngx_event_pipe_write_to_downstream(p);
|
36
|
+
|
37
|
+
if (rc == NGX_ABORT) {
|
38
|
+
return NGX_ABORT;
|
39
|
+
}
|
40
|
+
|
41
|
+
if (rc == NGX_BUSY) {
|
42
|
+
return NGX_OK;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
p->read = 0;
|
47
|
+
p->upstream_blocked = 0;
|
48
|
+
|
49
|
+
p->log->action = "reading upstream";
|
50
|
+
|
51
|
+
if (ngx_event_pipe_read_upstream(p) == NGX_ABORT) {
|
52
|
+
return NGX_ABORT;
|
53
|
+
}
|
54
|
+
|
55
|
+
if (!p->read && !p->upstream_blocked) {
|
56
|
+
break;
|
57
|
+
}
|
58
|
+
|
59
|
+
do_write = 1;
|
60
|
+
}
|
61
|
+
|
62
|
+
if (p->upstream->fd != -1) {
|
63
|
+
rev = p->upstream->read;
|
64
|
+
|
65
|
+
flags = (rev->eof || rev->error) ? NGX_CLOSE_EVENT : 0;
|
66
|
+
|
67
|
+
if (ngx_handle_read_event(rev, flags) != NGX_OK) {
|
68
|
+
return NGX_ABORT;
|
69
|
+
}
|
70
|
+
|
71
|
+
if (rev->active && !rev->ready) {
|
72
|
+
ngx_add_timer(rev, p->read_timeout);
|
73
|
+
|
74
|
+
} else if (rev->timer_set) {
|
75
|
+
ngx_del_timer(rev);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
if (p->downstream->fd != -1 && p->downstream->data == p->output_ctx) {
|
80
|
+
wev = p->downstream->write;
|
81
|
+
if (ngx_handle_write_event(wev, p->send_lowat) != NGX_OK) {
|
82
|
+
return NGX_ABORT;
|
83
|
+
}
|
84
|
+
|
85
|
+
if (!wev->delayed) {
|
86
|
+
if (wev->active && !wev->ready) {
|
87
|
+
ngx_add_timer(wev, p->send_timeout);
|
88
|
+
|
89
|
+
} else if (wev->timer_set) {
|
90
|
+
ngx_del_timer(wev);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
return NGX_OK;
|
96
|
+
}
|
97
|
+
|
98
|
+
|
99
|
+
static ngx_int_t
|
100
|
+
ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
|
101
|
+
{
|
102
|
+
ssize_t n, size;
|
103
|
+
ngx_int_t rc;
|
104
|
+
ngx_buf_t *b;
|
105
|
+
ngx_chain_t *chain, *cl, *ln;
|
106
|
+
|
107
|
+
if (p->upstream_eof || p->upstream_error || p->upstream_done) {
|
108
|
+
return NGX_OK;
|
109
|
+
}
|
110
|
+
|
111
|
+
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
112
|
+
"pipe read upstream: %d", p->upstream->read->ready);
|
113
|
+
|
114
|
+
for ( ;; ) {
|
115
|
+
|
116
|
+
if (p->upstream_eof || p->upstream_error || p->upstream_done) {
|
117
|
+
break;
|
118
|
+
}
|
119
|
+
|
120
|
+
if (p->preread_bufs == NULL && !p->upstream->read->ready) {
|
121
|
+
break;
|
122
|
+
}
|
123
|
+
|
124
|
+
if (p->preread_bufs) {
|
125
|
+
|
126
|
+
/* use the pre-read bufs if they exist */
|
127
|
+
|
128
|
+
chain = p->preread_bufs;
|
129
|
+
p->preread_bufs = NULL;
|
130
|
+
n = p->preread_size;
|
131
|
+
|
132
|
+
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
133
|
+
"pipe preread: %z", n);
|
134
|
+
|
135
|
+
if (n) {
|
136
|
+
p->read = 1;
|
137
|
+
}
|
138
|
+
|
139
|
+
} else {
|
140
|
+
|
141
|
+
#if (NGX_HAVE_KQUEUE)
|
142
|
+
|
143
|
+
/*
|
144
|
+
* kqueue notifies about the end of file or a pending error.
|
145
|
+
* This test allows not to allocate a buf on these conditions
|
146
|
+
* and not to call c->recv_chain().
|
147
|
+
*/
|
148
|
+
|
149
|
+
if (p->upstream->read->available == 0
|
150
|
+
&& p->upstream->read->pending_eof)
|
151
|
+
{
|
152
|
+
p->upstream->read->ready = 0;
|
153
|
+
p->upstream->read->eof = 0;
|
154
|
+
p->upstream_eof = 1;
|
155
|
+
p->read = 1;
|
156
|
+
|
157
|
+
if (p->upstream->read->kq_errno) {
|
158
|
+
p->upstream->read->error = 1;
|
159
|
+
p->upstream_error = 1;
|
160
|
+
p->upstream_eof = 0;
|
161
|
+
|
162
|
+
ngx_log_error(NGX_LOG_ERR, p->log,
|
163
|
+
p->upstream->read->kq_errno,
|
164
|
+
"kevent() reported that upstream "
|
165
|
+
"closed connection");
|
166
|
+
}
|
167
|
+
|
168
|
+
break;
|
169
|
+
}
|
170
|
+
#endif
|
171
|
+
|
172
|
+
if (p->free_raw_bufs) {
|
173
|
+
|
174
|
+
/* use the free bufs if they exist */
|
175
|
+
|
176
|
+
chain = p->free_raw_bufs;
|
177
|
+
if (p->single_buf) {
|
178
|
+
p->free_raw_bufs = p->free_raw_bufs->next;
|
179
|
+
chain->next = NULL;
|
180
|
+
} else {
|
181
|
+
p->free_raw_bufs = NULL;
|
182
|
+
}
|
183
|
+
|
184
|
+
} else if (p->allocated < p->bufs.num) {
|
185
|
+
|
186
|
+
/* allocate a new buf if it's still allowed */
|
187
|
+
|
188
|
+
b = ngx_create_temp_buf(p->pool, p->bufs.size);
|
189
|
+
if (b == NULL) {
|
190
|
+
return NGX_ABORT;
|
191
|
+
}
|
192
|
+
|
193
|
+
p->allocated++;
|
194
|
+
|
195
|
+
chain = ngx_alloc_chain_link(p->pool);
|
196
|
+
if (chain == NULL) {
|
197
|
+
return NGX_ABORT;
|
198
|
+
}
|
199
|
+
|
200
|
+
chain->buf = b;
|
201
|
+
chain->next = NULL;
|
202
|
+
|
203
|
+
} else if (!p->cacheable
|
204
|
+
&& p->downstream->data == p->output_ctx
|
205
|
+
&& p->downstream->write->ready
|
206
|
+
&& !p->downstream->write->delayed)
|
207
|
+
{
|
208
|
+
/*
|
209
|
+
* if the bufs are not needed to be saved in a cache and
|
210
|
+
* a downstream is ready then write the bufs to a downstream
|
211
|
+
*/
|
212
|
+
|
213
|
+
p->upstream_blocked = 1;
|
214
|
+
|
215
|
+
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
216
|
+
"pipe downstream ready");
|
217
|
+
|
218
|
+
break;
|
219
|
+
|
220
|
+
} else if (p->cacheable
|
221
|
+
|| p->temp_file->offset < p->max_temp_file_size)
|
222
|
+
{
|
223
|
+
|
224
|
+
/*
|
225
|
+
* if it is allowed, then save some bufs from r->in
|
226
|
+
* to a temporary file, and add them to a r->out chain
|
227
|
+
*/
|
228
|
+
|
229
|
+
rc = ngx_event_pipe_write_chain_to_temp_file(p);
|
230
|
+
|
231
|
+
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
232
|
+
"pipe temp offset: %O", p->temp_file->offset);
|
233
|
+
|
234
|
+
if (rc == NGX_BUSY) {
|
235
|
+
break;
|
236
|
+
}
|
237
|
+
|
238
|
+
if (rc == NGX_AGAIN) {
|
239
|
+
if (ngx_event_flags & NGX_USE_LEVEL_EVENT
|
240
|
+
&& p->upstream->read->active
|
241
|
+
&& p->upstream->read->ready)
|
242
|
+
{
|
243
|
+
if (ngx_del_event(p->upstream->read, NGX_READ_EVENT, 0)
|
244
|
+
== NGX_ERROR)
|
245
|
+
{
|
246
|
+
return NGX_ABORT;
|
247
|
+
}
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
if (rc != NGX_OK) {
|
252
|
+
return rc;
|
253
|
+
}
|
254
|
+
|
255
|
+
chain = p->free_raw_bufs;
|
256
|
+
if (p->single_buf) {
|
257
|
+
p->free_raw_bufs = p->free_raw_bufs->next;
|
258
|
+
chain->next = NULL;
|
259
|
+
} else {
|
260
|
+
p->free_raw_bufs = NULL;
|
261
|
+
}
|
262
|
+
|
263
|
+
} else {
|
264
|
+
|
265
|
+
/* there are no bufs to read in */
|
266
|
+
|
267
|
+
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
268
|
+
"no pipe bufs to read in");
|
269
|
+
|
270
|
+
break;
|
271
|
+
}
|
272
|
+
|
273
|
+
n = p->upstream->recv_chain(p->upstream, chain);
|
274
|
+
|
275
|
+
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
276
|
+
"pipe recv chain: %z", n);
|
277
|
+
|
278
|
+
if (p->free_raw_bufs) {
|
279
|
+
chain->next = p->free_raw_bufs;
|
280
|
+
}
|
281
|
+
p->free_raw_bufs = chain;
|
282
|
+
|
283
|
+
if (n == NGX_ERROR) {
|
284
|
+
p->upstream_error = 1;
|
285
|
+
return NGX_ERROR;
|
286
|
+
}
|
287
|
+
|
288
|
+
if (n == NGX_AGAIN) {
|
289
|
+
if (p->single_buf) {
|
290
|
+
ngx_event_pipe_remove_shadow_links(chain->buf);
|
291
|
+
}
|
292
|
+
|
293
|
+
break;
|
294
|
+
}
|
295
|
+
|
296
|
+
p->read = 1;
|
297
|
+
|
298
|
+
if (n == 0) {
|
299
|
+
p->upstream_eof = 1;
|
300
|
+
break;
|
301
|
+
}
|
302
|
+
}
|
303
|
+
|
304
|
+
p->read_length += n;
|
305
|
+
cl = chain;
|
306
|
+
p->free_raw_bufs = NULL;
|
307
|
+
|
308
|
+
while (cl && n > 0) {
|
309
|
+
|
310
|
+
ngx_event_pipe_remove_shadow_links(cl->buf);
|
311
|
+
|
312
|
+
size = cl->buf->end - cl->buf->last;
|
313
|
+
|
314
|
+
if (n >= size) {
|
315
|
+
cl->buf->last = cl->buf->end;
|
316
|
+
|
317
|
+
/* STUB */ cl->buf->num = p->num++;
|
318
|
+
|
319
|
+
if (p->input_filter(p, cl->buf) == NGX_ERROR) {
|
320
|
+
return NGX_ABORT;
|
321
|
+
}
|
322
|
+
|
323
|
+
n -= size;
|
324
|
+
ln = cl;
|
325
|
+
cl = cl->next;
|
326
|
+
ngx_free_chain(p->pool, ln);
|
327
|
+
|
328
|
+
} else {
|
329
|
+
cl->buf->last += n;
|
330
|
+
n = 0;
|
331
|
+
}
|
332
|
+
}
|
333
|
+
|
334
|
+
if (cl) {
|
335
|
+
for (ln = cl; ln->next; ln = ln->next) { /* void */ }
|
336
|
+
|
337
|
+
ln->next = p->free_raw_bufs;
|
338
|
+
p->free_raw_bufs = cl;
|
339
|
+
}
|
340
|
+
}
|
341
|
+
|
342
|
+
#if (NGX_DEBUG)
|
343
|
+
|
344
|
+
for (cl = p->busy; cl; cl = cl->next) {
|
345
|
+
ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
346
|
+
"pipe buf busy s:%d t:%d f:%d "
|
347
|
+
"%p, pos %p, size: %z "
|
348
|
+
"file: %O, size: %z",
|
349
|
+
(cl->buf->shadow ? 1 : 0),
|
350
|
+
cl->buf->temporary, cl->buf->in_file,
|
351
|
+
cl->buf->start, cl->buf->pos,
|
352
|
+
cl->buf->last - cl->buf->pos,
|
353
|
+
cl->buf->file_pos,
|
354
|
+
cl->buf->file_last - cl->buf->file_pos);
|
355
|
+
}
|
356
|
+
|
357
|
+
for (cl = p->out; cl; cl = cl->next) {
|
358
|
+
ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
359
|
+
"pipe buf out s:%d t:%d f:%d "
|
360
|
+
"%p, pos %p, size: %z "
|
361
|
+
"file: %O, size: %z",
|
362
|
+
(cl->buf->shadow ? 1 : 0),
|
363
|
+
cl->buf->temporary, cl->buf->in_file,
|
364
|
+
cl->buf->start, cl->buf->pos,
|
365
|
+
cl->buf->last - cl->buf->pos,
|
366
|
+
cl->buf->file_pos,
|
367
|
+
cl->buf->file_last - cl->buf->file_pos);
|
368
|
+
}
|
369
|
+
|
370
|
+
for (cl = p->in; cl; cl = cl->next) {
|
371
|
+
ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
372
|
+
"pipe buf in s:%d t:%d f:%d "
|
373
|
+
"%p, pos %p, size: %z "
|
374
|
+
"file: %O, size: %z",
|
375
|
+
(cl->buf->shadow ? 1 : 0),
|
376
|
+
cl->buf->temporary, cl->buf->in_file,
|
377
|
+
cl->buf->start, cl->buf->pos,
|
378
|
+
cl->buf->last - cl->buf->pos,
|
379
|
+
cl->buf->file_pos,
|
380
|
+
cl->buf->file_last - cl->buf->file_pos);
|
381
|
+
}
|
382
|
+
|
383
|
+
for (cl = p->free_raw_bufs; cl; cl = cl->next) {
|
384
|
+
ngx_log_debug8(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
385
|
+
"pipe buf free s:%d t:%d f:%d "
|
386
|
+
"%p, pos %p, size: %z "
|
387
|
+
"file: %O, size: %z",
|
388
|
+
(cl->buf->shadow ? 1 : 0),
|
389
|
+
cl->buf->temporary, cl->buf->in_file,
|
390
|
+
cl->buf->start, cl->buf->pos,
|
391
|
+
cl->buf->last - cl->buf->pos,
|
392
|
+
cl->buf->file_pos,
|
393
|
+
cl->buf->file_last - cl->buf->file_pos);
|
394
|
+
}
|
395
|
+
|
396
|
+
#endif
|
397
|
+
|
398
|
+
if ((p->upstream_eof || p->upstream_error) && p->free_raw_bufs) {
|
399
|
+
|
400
|
+
/* STUB */ p->free_raw_bufs->buf->num = p->num++;
|
401
|
+
|
402
|
+
if (p->input_filter(p, p->free_raw_bufs->buf) == NGX_ERROR) {
|
403
|
+
return NGX_ABORT;
|
404
|
+
}
|
405
|
+
|
406
|
+
p->free_raw_bufs = p->free_raw_bufs->next;
|
407
|
+
|
408
|
+
if (p->free_bufs && p->buf_to_file == NULL) {
|
409
|
+
for (cl = p->free_raw_bufs; cl; cl = cl->next) {
|
410
|
+
if (cl->buf->shadow == NULL) {
|
411
|
+
ngx_pfree(p->pool, cl->buf->start);
|
412
|
+
}
|
413
|
+
}
|
414
|
+
}
|
415
|
+
}
|
416
|
+
|
417
|
+
if (p->cacheable && p->in) {
|
418
|
+
if (ngx_event_pipe_write_chain_to_temp_file(p) == NGX_ABORT) {
|
419
|
+
return NGX_ABORT;
|
420
|
+
}
|
421
|
+
}
|
422
|
+
|
423
|
+
return NGX_OK;
|
424
|
+
}
|
425
|
+
|
426
|
+
|
427
|
+
static ngx_int_t
|
428
|
+
ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
|
429
|
+
{
|
430
|
+
u_char *prev;
|
431
|
+
size_t bsize;
|
432
|
+
ngx_int_t rc;
|
433
|
+
ngx_uint_t flush, flushed, prev_last_shadow;
|
434
|
+
ngx_chain_t *out, **ll, *cl, file;
|
435
|
+
ngx_connection_t *downstream;
|
436
|
+
|
437
|
+
downstream = p->downstream;
|
438
|
+
|
439
|
+
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
440
|
+
"pipe write downstream: %d", downstream->write->ready);
|
441
|
+
|
442
|
+
flushed = 0;
|
443
|
+
|
444
|
+
for ( ;; ) {
|
445
|
+
if (p->downstream_error) {
|
446
|
+
return ngx_event_pipe_drain_chains(p);
|
447
|
+
}
|
448
|
+
|
449
|
+
if (p->upstream_eof || p->upstream_error || p->upstream_done) {
|
450
|
+
|
451
|
+
/* pass the p->out and p->in chains to the output filter */
|
452
|
+
|
453
|
+
for (cl = p->busy; cl; cl = cl->next) {
|
454
|
+
cl->buf->recycled = 0;
|
455
|
+
}
|
456
|
+
|
457
|
+
if (p->out) {
|
458
|
+
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
459
|
+
"pipe write downstream flush out");
|
460
|
+
|
461
|
+
for (cl = p->out; cl; cl = cl->next) {
|
462
|
+
cl->buf->recycled = 0;
|
463
|
+
}
|
464
|
+
|
465
|
+
rc = p->output_filter(p->output_ctx, p->out);
|
466
|
+
|
467
|
+
if (rc == NGX_ERROR) {
|
468
|
+
p->downstream_error = 1;
|
469
|
+
return ngx_event_pipe_drain_chains(p);
|
470
|
+
}
|
471
|
+
|
472
|
+
p->out = NULL;
|
473
|
+
}
|
474
|
+
|
475
|
+
if (p->in) {
|
476
|
+
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
477
|
+
"pipe write downstream flush in");
|
478
|
+
|
479
|
+
for (cl = p->in; cl; cl = cl->next) {
|
480
|
+
cl->buf->recycled = 0;
|
481
|
+
}
|
482
|
+
|
483
|
+
rc = p->output_filter(p->output_ctx, p->in);
|
484
|
+
|
485
|
+
if (rc == NGX_ERROR) {
|
486
|
+
p->downstream_error = 1;
|
487
|
+
return ngx_event_pipe_drain_chains(p);
|
488
|
+
}
|
489
|
+
|
490
|
+
p->in = NULL;
|
491
|
+
}
|
492
|
+
|
493
|
+
if (p->cacheable && p->buf_to_file) {
|
494
|
+
|
495
|
+
file.buf = p->buf_to_file;
|
496
|
+
file.next = NULL;
|
497
|
+
|
498
|
+
if (ngx_write_chain_to_temp_file(p->temp_file, &file)
|
499
|
+
== NGX_ERROR)
|
500
|
+
{
|
501
|
+
return NGX_ABORT;
|
502
|
+
}
|
503
|
+
}
|
504
|
+
|
505
|
+
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
506
|
+
"pipe write downstream done");
|
507
|
+
|
508
|
+
/* TODO: free unused bufs */
|
509
|
+
|
510
|
+
p->downstream_done = 1;
|
511
|
+
break;
|
512
|
+
}
|
513
|
+
|
514
|
+
if (downstream->data != p->output_ctx
|
515
|
+
|| !downstream->write->ready
|
516
|
+
|| downstream->write->delayed)
|
517
|
+
{
|
518
|
+
break;
|
519
|
+
}
|
520
|
+
|
521
|
+
/* bsize is the size of the busy recycled bufs */
|
522
|
+
|
523
|
+
prev = NULL;
|
524
|
+
bsize = 0;
|
525
|
+
|
526
|
+
for (cl = p->busy; cl; cl = cl->next) {
|
527
|
+
|
528
|
+
if (cl->buf->recycled) {
|
529
|
+
if (prev == cl->buf->start) {
|
530
|
+
continue;
|
531
|
+
}
|
532
|
+
|
533
|
+
bsize += cl->buf->end - cl->buf->start;
|
534
|
+
prev = cl->buf->start;
|
535
|
+
}
|
536
|
+
}
|
537
|
+
|
538
|
+
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
539
|
+
"pipe write busy: %uz", bsize);
|
540
|
+
|
541
|
+
out = NULL;
|
542
|
+
|
543
|
+
if (bsize >= (size_t) p->busy_size) {
|
544
|
+
flush = 1;
|
545
|
+
goto flush;
|
546
|
+
}
|
547
|
+
|
548
|
+
flush = 0;
|
549
|
+
ll = NULL;
|
550
|
+
prev_last_shadow = 1;
|
551
|
+
|
552
|
+
for ( ;; ) {
|
553
|
+
if (p->out) {
|
554
|
+
cl = p->out;
|
555
|
+
|
556
|
+
if (cl->buf->recycled
|
557
|
+
&& bsize + cl->buf->last - cl->buf->pos > p->busy_size)
|
558
|
+
{
|
559
|
+
flush = 1;
|
560
|
+
break;
|
561
|
+
}
|
562
|
+
|
563
|
+
p->out = p->out->next;
|
564
|
+
|
565
|
+
ngx_event_pipe_free_shadow_raw_buf(&p->free_raw_bufs, cl->buf);
|
566
|
+
|
567
|
+
} else if (!p->cacheable && p->in) {
|
568
|
+
cl = p->in;
|
569
|
+
|
570
|
+
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
571
|
+
"pipe write buf ls:%d %p %z",
|
572
|
+
cl->buf->last_shadow,
|
573
|
+
cl->buf->pos,
|
574
|
+
cl->buf->last - cl->buf->pos);
|
575
|
+
|
576
|
+
if (cl->buf->recycled
|
577
|
+
&& cl->buf->last_shadow
|
578
|
+
&& bsize + cl->buf->last - cl->buf->pos > p->busy_size)
|
579
|
+
{
|
580
|
+
if (!prev_last_shadow) {
|
581
|
+
p->in = p->in->next;
|
582
|
+
|
583
|
+
cl->next = NULL;
|
584
|
+
|
585
|
+
if (out) {
|
586
|
+
*ll = cl;
|
587
|
+
} else {
|
588
|
+
out = cl;
|
589
|
+
}
|
590
|
+
}
|
591
|
+
|
592
|
+
flush = 1;
|
593
|
+
break;
|
594
|
+
}
|
595
|
+
|
596
|
+
prev_last_shadow = cl->buf->last_shadow;
|
597
|
+
|
598
|
+
p->in = p->in->next;
|
599
|
+
|
600
|
+
} else {
|
601
|
+
break;
|
602
|
+
}
|
603
|
+
|
604
|
+
if (cl->buf->recycled) {
|
605
|
+
bsize += cl->buf->last - cl->buf->pos;
|
606
|
+
}
|
607
|
+
|
608
|
+
cl->next = NULL;
|
609
|
+
|
610
|
+
if (out) {
|
611
|
+
*ll = cl;
|
612
|
+
} else {
|
613
|
+
out = cl;
|
614
|
+
}
|
615
|
+
ll = &cl->next;
|
616
|
+
}
|
617
|
+
|
618
|
+
flush:
|
619
|
+
|
620
|
+
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
621
|
+
"pipe write: out:%p, f:%d", out, flush);
|
622
|
+
|
623
|
+
if (out == NULL) {
|
624
|
+
|
625
|
+
if (!flush) {
|
626
|
+
break;
|
627
|
+
}
|
628
|
+
|
629
|
+
/* a workaround for AIO */
|
630
|
+
if (flushed++ > 10) {
|
631
|
+
return NGX_BUSY;
|
632
|
+
}
|
633
|
+
}
|
634
|
+
|
635
|
+
rc = p->output_filter(p->output_ctx, out);
|
636
|
+
|
637
|
+
ngx_chain_update_chains(&p->free, &p->busy, &out, p->tag);
|
638
|
+
|
639
|
+
if (rc == NGX_ERROR) {
|
640
|
+
p->downstream_error = 1;
|
641
|
+
return ngx_event_pipe_drain_chains(p);
|
642
|
+
}
|
643
|
+
|
644
|
+
for (cl = p->free; cl; cl = cl->next) {
|
645
|
+
|
646
|
+
if (cl->buf->temp_file) {
|
647
|
+
if (p->cacheable || !p->cyclic_temp_file) {
|
648
|
+
continue;
|
649
|
+
}
|
650
|
+
|
651
|
+
/* reset p->temp_offset if all bufs had been sent */
|
652
|
+
|
653
|
+
if (cl->buf->file_last == p->temp_file->offset) {
|
654
|
+
p->temp_file->offset = 0;
|
655
|
+
}
|
656
|
+
}
|
657
|
+
|
658
|
+
/* TODO: free buf if p->free_bufs && upstream done */
|
659
|
+
|
660
|
+
/* add the free shadow raw buf to p->free_raw_bufs */
|
661
|
+
|
662
|
+
if (cl->buf->last_shadow) {
|
663
|
+
if (ngx_event_pipe_add_free_buf(p, cl->buf->shadow) != NGX_OK) {
|
664
|
+
return NGX_ABORT;
|
665
|
+
}
|
666
|
+
|
667
|
+
cl->buf->last_shadow = 0;
|
668
|
+
}
|
669
|
+
|
670
|
+
cl->buf->shadow = NULL;
|
671
|
+
}
|
672
|
+
}
|
673
|
+
|
674
|
+
return NGX_OK;
|
675
|
+
}
|
676
|
+
|
677
|
+
|
678
|
+
static ngx_int_t
|
679
|
+
ngx_event_pipe_write_chain_to_temp_file(ngx_event_pipe_t *p)
|
680
|
+
{
|
681
|
+
ssize_t size, bsize;
|
682
|
+
ngx_buf_t *b;
|
683
|
+
ngx_chain_t *cl, *tl, *next, *out, **ll, **last_free, fl;
|
684
|
+
|
685
|
+
if (p->buf_to_file) {
|
686
|
+
fl.buf = p->buf_to_file;
|
687
|
+
fl.next = p->in;
|
688
|
+
out = &fl;
|
689
|
+
|
690
|
+
} else {
|
691
|
+
out = p->in;
|
692
|
+
}
|
693
|
+
|
694
|
+
if (!p->cacheable) {
|
695
|
+
|
696
|
+
size = 0;
|
697
|
+
cl = out;
|
698
|
+
ll = NULL;
|
699
|
+
|
700
|
+
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
701
|
+
"pipe offset: %O", p->temp_file->offset);
|
702
|
+
|
703
|
+
do {
|
704
|
+
bsize = cl->buf->last - cl->buf->pos;
|
705
|
+
|
706
|
+
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, p->log, 0,
|
707
|
+
"pipe buf %p, pos %p, size: %z",
|
708
|
+
cl->buf->start, cl->buf->pos, bsize);
|
709
|
+
|
710
|
+
if ((size + bsize > p->temp_file_write_size)
|
711
|
+
|| (p->temp_file->offset + size + bsize > p->max_temp_file_size))
|
712
|
+
{
|
713
|
+
break;
|
714
|
+
}
|
715
|
+
|
716
|
+
size += bsize;
|
717
|
+
ll = &cl->next;
|
718
|
+
cl = cl->next;
|
719
|
+
|
720
|
+
} while (cl);
|
721
|
+
|
722
|
+
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "size: %z", size);
|
723
|
+
|
724
|
+
if (ll == NULL) {
|
725
|
+
return NGX_BUSY;
|
726
|
+
}
|
727
|
+
|
728
|
+
if (cl) {
|
729
|
+
p->in = cl;
|
730
|
+
*ll = NULL;
|
731
|
+
|
732
|
+
} else {
|
733
|
+
p->in = NULL;
|
734
|
+
p->last_in = &p->in;
|
735
|
+
}
|
736
|
+
|
737
|
+
} else {
|
738
|
+
p->in = NULL;
|
739
|
+
p->last_in = &p->in;
|
740
|
+
}
|
741
|
+
|
742
|
+
if (ngx_write_chain_to_temp_file(p->temp_file, out) == NGX_ERROR) {
|
743
|
+
return NGX_ABORT;
|
744
|
+
}
|
745
|
+
|
746
|
+
for (last_free = &p->free_raw_bufs;
|
747
|
+
*last_free != NULL;
|
748
|
+
last_free = &(*last_free)->next)
|
749
|
+
{
|
750
|
+
/* void */
|
751
|
+
}
|
752
|
+
|
753
|
+
if (p->buf_to_file) {
|
754
|
+
p->temp_file->offset = p->buf_to_file->last - p->buf_to_file->pos;
|
755
|
+
p->buf_to_file = NULL;
|
756
|
+
out = out->next;
|
757
|
+
}
|
758
|
+
|
759
|
+
for (cl = out; cl; cl = next) {
|
760
|
+
next = cl->next;
|
761
|
+
cl->next = NULL;
|
762
|
+
|
763
|
+
b = cl->buf;
|
764
|
+
b->file = &p->temp_file->file;
|
765
|
+
b->file_pos = p->temp_file->offset;
|
766
|
+
p->temp_file->offset += b->last - b->pos;
|
767
|
+
b->file_last = p->temp_file->offset;
|
768
|
+
|
769
|
+
b->in_file = 1;
|
770
|
+
b->temp_file = 1;
|
771
|
+
|
772
|
+
if (p->out) {
|
773
|
+
*p->last_out = cl;
|
774
|
+
} else {
|
775
|
+
p->out = cl;
|
776
|
+
}
|
777
|
+
p->last_out = &cl->next;
|
778
|
+
|
779
|
+
if (b->last_shadow) {
|
780
|
+
|
781
|
+
tl = ngx_alloc_chain_link(p->pool);
|
782
|
+
if (tl == NULL) {
|
783
|
+
return NGX_ABORT;
|
784
|
+
}
|
785
|
+
|
786
|
+
tl->buf = b->shadow;
|
787
|
+
tl->next = NULL;
|
788
|
+
|
789
|
+
*last_free = tl;
|
790
|
+
last_free = &tl->next;
|
791
|
+
|
792
|
+
b->shadow->pos = b->shadow->start;
|
793
|
+
b->shadow->last = b->shadow->start;
|
794
|
+
|
795
|
+
ngx_event_pipe_remove_shadow_links(b->shadow);
|
796
|
+
}
|
797
|
+
}
|
798
|
+
|
799
|
+
return NGX_OK;
|
800
|
+
}
|
801
|
+
|
802
|
+
|
803
|
+
/* the copy input filter */
|
804
|
+
|
805
|
+
ngx_int_t
|
806
|
+
ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf)
|
807
|
+
{
|
808
|
+
ngx_buf_t *b;
|
809
|
+
ngx_chain_t *cl;
|
810
|
+
|
811
|
+
if (buf->pos == buf->last) {
|
812
|
+
return NGX_OK;
|
813
|
+
}
|
814
|
+
|
815
|
+
if (p->free) {
|
816
|
+
cl = p->free;
|
817
|
+
b = cl->buf;
|
818
|
+
p->free = cl->next;
|
819
|
+
ngx_free_chain(p->pool, cl);
|
820
|
+
|
821
|
+
} else {
|
822
|
+
b = ngx_alloc_buf(p->pool);
|
823
|
+
if (b == NULL) {
|
824
|
+
return NGX_ERROR;
|
825
|
+
}
|
826
|
+
}
|
827
|
+
|
828
|
+
ngx_memcpy(b, buf, sizeof(ngx_buf_t));
|
829
|
+
b->shadow = buf;
|
830
|
+
b->tag = p->tag;
|
831
|
+
b->last_shadow = 1;
|
832
|
+
b->recycled = 1;
|
833
|
+
buf->shadow = b;
|
834
|
+
|
835
|
+
cl = ngx_alloc_chain_link(p->pool);
|
836
|
+
if (cl == NULL) {
|
837
|
+
return NGX_ERROR;
|
838
|
+
}
|
839
|
+
|
840
|
+
cl->buf = b;
|
841
|
+
cl->next = NULL;
|
842
|
+
|
843
|
+
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num);
|
844
|
+
|
845
|
+
if (p->in) {
|
846
|
+
*p->last_in = cl;
|
847
|
+
} else {
|
848
|
+
p->in = cl;
|
849
|
+
}
|
850
|
+
p->last_in = &cl->next;
|
851
|
+
|
852
|
+
return NGX_OK;
|
853
|
+
}
|
854
|
+
|
855
|
+
|
856
|
+
static ngx_inline void
|
857
|
+
ngx_event_pipe_remove_shadow_links(ngx_buf_t *buf)
|
858
|
+
{
|
859
|
+
ngx_buf_t *b, *next;
|
860
|
+
|
861
|
+
b = buf->shadow;
|
862
|
+
|
863
|
+
if (b == NULL) {
|
864
|
+
return;
|
865
|
+
}
|
866
|
+
|
867
|
+
while (!b->last_shadow) {
|
868
|
+
next = b->shadow;
|
869
|
+
|
870
|
+
b->temporary = 0;
|
871
|
+
b->recycled = 0;
|
872
|
+
|
873
|
+
b->shadow = NULL;
|
874
|
+
b = next;
|
875
|
+
}
|
876
|
+
|
877
|
+
b->temporary = 0;
|
878
|
+
b->recycled = 0;
|
879
|
+
b->last_shadow = 0;
|
880
|
+
|
881
|
+
b->shadow = NULL;
|
882
|
+
|
883
|
+
buf->shadow = NULL;
|
884
|
+
}
|
885
|
+
|
886
|
+
|
887
|
+
static ngx_inline void
|
888
|
+
ngx_event_pipe_free_shadow_raw_buf(ngx_chain_t **free, ngx_buf_t *buf)
|
889
|
+
{
|
890
|
+
ngx_buf_t *s;
|
891
|
+
ngx_chain_t *cl, **ll;
|
892
|
+
|
893
|
+
if (buf->shadow == NULL) {
|
894
|
+
return;
|
895
|
+
}
|
896
|
+
|
897
|
+
for (s = buf->shadow; !s->last_shadow; s = s->shadow) { /* void */ }
|
898
|
+
|
899
|
+
ll = free;
|
900
|
+
|
901
|
+
for (cl = *free; cl; cl = cl->next) {
|
902
|
+
if (cl->buf == s) {
|
903
|
+
*ll = cl->next;
|
904
|
+
break;
|
905
|
+
}
|
906
|
+
|
907
|
+
if (cl->buf->shadow) {
|
908
|
+
break;
|
909
|
+
}
|
910
|
+
|
911
|
+
ll = &cl->next;
|
912
|
+
}
|
913
|
+
}
|
914
|
+
|
915
|
+
|
916
|
+
ngx_int_t
|
917
|
+
ngx_event_pipe_add_free_buf(ngx_event_pipe_t *p, ngx_buf_t *b)
|
918
|
+
{
|
919
|
+
ngx_chain_t *cl;
|
920
|
+
|
921
|
+
cl = ngx_alloc_chain_link(p->pool);
|
922
|
+
if (cl == NULL) {
|
923
|
+
return NGX_ERROR;
|
924
|
+
}
|
925
|
+
|
926
|
+
b->pos = b->start;
|
927
|
+
b->last = b->start;
|
928
|
+
b->shadow = NULL;
|
929
|
+
|
930
|
+
cl->buf = b;
|
931
|
+
|
932
|
+
if (p->free_raw_bufs == NULL) {
|
933
|
+
p->free_raw_bufs = cl;
|
934
|
+
cl->next = NULL;
|
935
|
+
|
936
|
+
return NGX_OK;
|
937
|
+
}
|
938
|
+
|
939
|
+
if (p->free_raw_bufs->buf->pos == p->free_raw_bufs->buf->last) {
|
940
|
+
|
941
|
+
/* add the free buf to the list start */
|
942
|
+
|
943
|
+
cl->next = p->free_raw_bufs;
|
944
|
+
p->free_raw_bufs = cl;
|
945
|
+
|
946
|
+
return NGX_OK;
|
947
|
+
}
|
948
|
+
|
949
|
+
/* the first free buf is partially filled, thus add the free buf after it */
|
950
|
+
|
951
|
+
cl->next = p->free_raw_bufs->next;
|
952
|
+
p->free_raw_bufs->next = cl;
|
953
|
+
|
954
|
+
return NGX_OK;
|
955
|
+
}
|
956
|
+
|
957
|
+
|
958
|
+
static ngx_int_t
|
959
|
+
ngx_event_pipe_drain_chains(ngx_event_pipe_t *p)
|
960
|
+
{
|
961
|
+
ngx_chain_t *cl, *tl;
|
962
|
+
|
963
|
+
for ( ;; ) {
|
964
|
+
if (p->busy) {
|
965
|
+
cl = p->busy;
|
966
|
+
p->busy = NULL;
|
967
|
+
|
968
|
+
} else if (p->out) {
|
969
|
+
cl = p->out;
|
970
|
+
p->out = NULL;
|
971
|
+
|
972
|
+
} else if (p->in) {
|
973
|
+
cl = p->in;
|
974
|
+
p->in = NULL;
|
975
|
+
|
976
|
+
} else {
|
977
|
+
return NGX_OK;
|
978
|
+
}
|
979
|
+
|
980
|
+
while (cl) {
|
981
|
+
if (cl->buf->last_shadow) {
|
982
|
+
if (ngx_event_pipe_add_free_buf(p, cl->buf->shadow) != NGX_OK) {
|
983
|
+
return NGX_ABORT;
|
984
|
+
}
|
985
|
+
|
986
|
+
cl->buf->last_shadow = 0;
|
987
|
+
}
|
988
|
+
|
989
|
+
cl->buf->shadow = NULL;
|
990
|
+
tl = cl->next;
|
991
|
+
cl->next = p->free;
|
992
|
+
p->free = cl;
|
993
|
+
cl = tl;
|
994
|
+
}
|
995
|
+
}
|
996
|
+
}
|