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,1357 @@
|
|
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_http.h>
|
11
|
+
|
12
|
+
|
13
|
+
typedef struct ngx_http_log_op_s ngx_http_log_op_t;
|
14
|
+
|
15
|
+
typedef u_char *(*ngx_http_log_op_run_pt) (ngx_http_request_t *r, u_char *buf,
|
16
|
+
ngx_http_log_op_t *op);
|
17
|
+
|
18
|
+
typedef size_t (*ngx_http_log_op_getlen_pt) (ngx_http_request_t *r,
|
19
|
+
uintptr_t data);
|
20
|
+
|
21
|
+
|
22
|
+
struct ngx_http_log_op_s {
|
23
|
+
size_t len;
|
24
|
+
ngx_http_log_op_getlen_pt getlen;
|
25
|
+
ngx_http_log_op_run_pt run;
|
26
|
+
uintptr_t data;
|
27
|
+
};
|
28
|
+
|
29
|
+
|
30
|
+
typedef struct {
|
31
|
+
ngx_str_t name;
|
32
|
+
ngx_array_t *flushes;
|
33
|
+
ngx_array_t *ops; /* array of ngx_http_log_op_t */
|
34
|
+
} ngx_http_log_fmt_t;
|
35
|
+
|
36
|
+
|
37
|
+
typedef struct {
|
38
|
+
ngx_array_t formats; /* array of ngx_http_log_fmt_t */
|
39
|
+
ngx_uint_t combined_used; /* unsigned combined_used:1 */
|
40
|
+
} ngx_http_log_main_conf_t;
|
41
|
+
|
42
|
+
|
43
|
+
typedef struct {
|
44
|
+
ngx_array_t *lengths;
|
45
|
+
ngx_array_t *values;
|
46
|
+
} ngx_http_log_script_t;
|
47
|
+
|
48
|
+
|
49
|
+
typedef struct {
|
50
|
+
ngx_open_file_t *file;
|
51
|
+
ngx_http_log_script_t *script;
|
52
|
+
time_t disk_full_time;
|
53
|
+
time_t error_log_time;
|
54
|
+
ngx_http_log_fmt_t *format;
|
55
|
+
} ngx_http_log_t;
|
56
|
+
|
57
|
+
|
58
|
+
typedef struct {
|
59
|
+
ngx_array_t *logs; /* array of ngx_http_log_t */
|
60
|
+
|
61
|
+
ngx_open_file_cache_t *open_file_cache;
|
62
|
+
time_t open_file_cache_valid;
|
63
|
+
ngx_uint_t open_file_cache_min_uses;
|
64
|
+
|
65
|
+
ngx_uint_t off; /* unsigned off:1 */
|
66
|
+
} ngx_http_log_loc_conf_t;
|
67
|
+
|
68
|
+
|
69
|
+
typedef struct {
|
70
|
+
ngx_str_t name;
|
71
|
+
size_t len;
|
72
|
+
ngx_http_log_op_run_pt run;
|
73
|
+
} ngx_http_log_var_t;
|
74
|
+
|
75
|
+
|
76
|
+
static void ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log,
|
77
|
+
u_char *buf, size_t len);
|
78
|
+
static ssize_t ngx_http_log_script_write(ngx_http_request_t *r,
|
79
|
+
ngx_http_log_script_t *script, u_char **name, u_char *buf, size_t len);
|
80
|
+
|
81
|
+
static u_char *ngx_http_log_connection(ngx_http_request_t *r, u_char *buf,
|
82
|
+
ngx_http_log_op_t *op);
|
83
|
+
static u_char *ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf,
|
84
|
+
ngx_http_log_op_t *op);
|
85
|
+
static u_char *ngx_http_log_time(ngx_http_request_t *r, u_char *buf,
|
86
|
+
ngx_http_log_op_t *op);
|
87
|
+
static u_char *ngx_http_log_iso8601(ngx_http_request_t *r, u_char *buf,
|
88
|
+
ngx_http_log_op_t *op);
|
89
|
+
static u_char *ngx_http_log_msec(ngx_http_request_t *r, u_char *buf,
|
90
|
+
ngx_http_log_op_t *op);
|
91
|
+
static u_char *ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf,
|
92
|
+
ngx_http_log_op_t *op);
|
93
|
+
static u_char *ngx_http_log_status(ngx_http_request_t *r, u_char *buf,
|
94
|
+
ngx_http_log_op_t *op);
|
95
|
+
static u_char *ngx_http_log_bytes_sent(ngx_http_request_t *r, u_char *buf,
|
96
|
+
ngx_http_log_op_t *op);
|
97
|
+
static u_char *ngx_http_log_body_bytes_sent(ngx_http_request_t *r,
|
98
|
+
u_char *buf, ngx_http_log_op_t *op);
|
99
|
+
static u_char *ngx_http_log_request_length(ngx_http_request_t *r, u_char *buf,
|
100
|
+
ngx_http_log_op_t *op);
|
101
|
+
|
102
|
+
static ngx_int_t ngx_http_log_variable_compile(ngx_conf_t *cf,
|
103
|
+
ngx_http_log_op_t *op, ngx_str_t *value);
|
104
|
+
static size_t ngx_http_log_variable_getlen(ngx_http_request_t *r,
|
105
|
+
uintptr_t data);
|
106
|
+
static u_char *ngx_http_log_variable(ngx_http_request_t *r, u_char *buf,
|
107
|
+
ngx_http_log_op_t *op);
|
108
|
+
static uintptr_t ngx_http_log_escape(u_char *dst, u_char *src, size_t size);
|
109
|
+
|
110
|
+
|
111
|
+
static void *ngx_http_log_create_main_conf(ngx_conf_t *cf);
|
112
|
+
static void *ngx_http_log_create_loc_conf(ngx_conf_t *cf);
|
113
|
+
static char *ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent,
|
114
|
+
void *child);
|
115
|
+
static char *ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd,
|
116
|
+
void *conf);
|
117
|
+
static char *ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd,
|
118
|
+
void *conf);
|
119
|
+
static char *ngx_http_log_compile_format(ngx_conf_t *cf,
|
120
|
+
ngx_array_t *flushes, ngx_array_t *ops, ngx_array_t *args, ngx_uint_t s);
|
121
|
+
static char *ngx_http_log_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd,
|
122
|
+
void *conf);
|
123
|
+
static ngx_int_t ngx_http_log_init(ngx_conf_t *cf);
|
124
|
+
|
125
|
+
|
126
|
+
static ngx_command_t ngx_http_log_commands[] = {
|
127
|
+
|
128
|
+
{ ngx_string("log_format"),
|
129
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_2MORE,
|
130
|
+
ngx_http_log_set_format,
|
131
|
+
NGX_HTTP_MAIN_CONF_OFFSET,
|
132
|
+
0,
|
133
|
+
NULL },
|
134
|
+
|
135
|
+
{ ngx_string("access_log"),
|
136
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
137
|
+
|NGX_HTTP_LMT_CONF|NGX_CONF_TAKE123,
|
138
|
+
ngx_http_log_set_log,
|
139
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
140
|
+
0,
|
141
|
+
NULL },
|
142
|
+
|
143
|
+
{ ngx_string("open_log_file_cache"),
|
144
|
+
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234,
|
145
|
+
ngx_http_log_open_file_cache,
|
146
|
+
NGX_HTTP_LOC_CONF_OFFSET,
|
147
|
+
0,
|
148
|
+
NULL },
|
149
|
+
|
150
|
+
ngx_null_command
|
151
|
+
};
|
152
|
+
|
153
|
+
|
154
|
+
static ngx_http_module_t ngx_http_log_module_ctx = {
|
155
|
+
NULL, /* preconfiguration */
|
156
|
+
ngx_http_log_init, /* postconfiguration */
|
157
|
+
|
158
|
+
ngx_http_log_create_main_conf, /* create main configuration */
|
159
|
+
NULL, /* init main configuration */
|
160
|
+
|
161
|
+
NULL, /* create server configuration */
|
162
|
+
NULL, /* merge server configuration */
|
163
|
+
|
164
|
+
ngx_http_log_create_loc_conf, /* create location configuration */
|
165
|
+
ngx_http_log_merge_loc_conf /* merge location configuration */
|
166
|
+
};
|
167
|
+
|
168
|
+
|
169
|
+
ngx_module_t ngx_http_log_module = {
|
170
|
+
NGX_MODULE_V1,
|
171
|
+
&ngx_http_log_module_ctx, /* module context */
|
172
|
+
ngx_http_log_commands, /* module directives */
|
173
|
+
NGX_HTTP_MODULE, /* module type */
|
174
|
+
NULL, /* init master */
|
175
|
+
NULL, /* init module */
|
176
|
+
NULL, /* init process */
|
177
|
+
NULL, /* init thread */
|
178
|
+
NULL, /* exit thread */
|
179
|
+
NULL, /* exit process */
|
180
|
+
NULL, /* exit master */
|
181
|
+
NGX_MODULE_V1_PADDING
|
182
|
+
};
|
183
|
+
|
184
|
+
|
185
|
+
static ngx_str_t ngx_http_access_log = ngx_string(NGX_HTTP_LOG_PATH);
|
186
|
+
|
187
|
+
|
188
|
+
static ngx_str_t ngx_http_combined_fmt =
|
189
|
+
ngx_string("$remote_addr - $remote_user [$time_local] "
|
190
|
+
"\"$request\" $status $body_bytes_sent "
|
191
|
+
"\"$http_referer\" \"$http_user_agent\"");
|
192
|
+
|
193
|
+
|
194
|
+
static ngx_http_log_var_t ngx_http_log_vars[] = {
|
195
|
+
{ ngx_string("connection"), NGX_ATOMIC_T_LEN, ngx_http_log_connection },
|
196
|
+
{ ngx_string("pipe"), 1, ngx_http_log_pipe },
|
197
|
+
{ ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1,
|
198
|
+
ngx_http_log_time },
|
199
|
+
{ ngx_string("time_iso8601"), sizeof("1970-09-28T12:00:00+06:00") - 1,
|
200
|
+
ngx_http_log_iso8601 },
|
201
|
+
{ ngx_string("msec"), NGX_TIME_T_LEN + 4, ngx_http_log_msec },
|
202
|
+
{ ngx_string("request_time"), NGX_TIME_T_LEN + 4,
|
203
|
+
ngx_http_log_request_time },
|
204
|
+
{ ngx_string("status"), 3, ngx_http_log_status },
|
205
|
+
{ ngx_string("bytes_sent"), NGX_OFF_T_LEN, ngx_http_log_bytes_sent },
|
206
|
+
{ ngx_string("body_bytes_sent"), NGX_OFF_T_LEN,
|
207
|
+
ngx_http_log_body_bytes_sent },
|
208
|
+
{ ngx_string("apache_bytes_sent"), NGX_OFF_T_LEN,
|
209
|
+
ngx_http_log_body_bytes_sent },
|
210
|
+
{ ngx_string("request_length"), NGX_SIZE_T_LEN,
|
211
|
+
ngx_http_log_request_length },
|
212
|
+
|
213
|
+
{ ngx_null_string, 0, NULL }
|
214
|
+
};
|
215
|
+
|
216
|
+
|
217
|
+
ngx_int_t
|
218
|
+
ngx_http_log_handler(ngx_http_request_t *r)
|
219
|
+
{
|
220
|
+
u_char *line, *p;
|
221
|
+
size_t len;
|
222
|
+
ngx_uint_t i, l;
|
223
|
+
ngx_http_log_t *log;
|
224
|
+
ngx_open_file_t *file;
|
225
|
+
ngx_http_log_op_t *op;
|
226
|
+
ngx_http_log_loc_conf_t *lcf;
|
227
|
+
|
228
|
+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
229
|
+
"http log handler");
|
230
|
+
|
231
|
+
lcf = ngx_http_get_module_loc_conf(r, ngx_http_log_module);
|
232
|
+
|
233
|
+
if (lcf->off) {
|
234
|
+
return NGX_OK;
|
235
|
+
}
|
236
|
+
|
237
|
+
log = lcf->logs->elts;
|
238
|
+
for (l = 0; l < lcf->logs->nelts; l++) {
|
239
|
+
|
240
|
+
if (ngx_time() == log[l].disk_full_time) {
|
241
|
+
|
242
|
+
/*
|
243
|
+
* on FreeBSD writing to a full filesystem with enabled softupdates
|
244
|
+
* may block process for much longer time than writing to non-full
|
245
|
+
* filesystem, so we skip writing to a log for one second
|
246
|
+
*/
|
247
|
+
|
248
|
+
continue;
|
249
|
+
}
|
250
|
+
|
251
|
+
ngx_http_script_flush_no_cacheable_variables(r, log[l].format->flushes);
|
252
|
+
|
253
|
+
len = 0;
|
254
|
+
op = log[l].format->ops->elts;
|
255
|
+
for (i = 0; i < log[l].format->ops->nelts; i++) {
|
256
|
+
if (op[i].len == 0) {
|
257
|
+
len += op[i].getlen(r, op[i].data);
|
258
|
+
|
259
|
+
} else {
|
260
|
+
len += op[i].len;
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
len += NGX_LINEFEED_SIZE;
|
265
|
+
|
266
|
+
file = log[l].file;
|
267
|
+
|
268
|
+
if (file && file->buffer) {
|
269
|
+
|
270
|
+
if (len > (size_t) (file->last - file->pos)) {
|
271
|
+
|
272
|
+
ngx_http_log_write(r, &log[l], file->buffer,
|
273
|
+
file->pos - file->buffer);
|
274
|
+
|
275
|
+
file->pos = file->buffer;
|
276
|
+
}
|
277
|
+
|
278
|
+
if (len <= (size_t) (file->last - file->pos)) {
|
279
|
+
|
280
|
+
p = file->pos;
|
281
|
+
|
282
|
+
for (i = 0; i < log[l].format->ops->nelts; i++) {
|
283
|
+
p = op[i].run(r, p, &op[i]);
|
284
|
+
}
|
285
|
+
|
286
|
+
ngx_linefeed(p);
|
287
|
+
|
288
|
+
file->pos = p;
|
289
|
+
|
290
|
+
continue;
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
line = ngx_pnalloc(r->pool, len);
|
295
|
+
if (line == NULL) {
|
296
|
+
return NGX_ERROR;
|
297
|
+
}
|
298
|
+
|
299
|
+
p = line;
|
300
|
+
|
301
|
+
for (i = 0; i < log[l].format->ops->nelts; i++) {
|
302
|
+
p = op[i].run(r, p, &op[i]);
|
303
|
+
}
|
304
|
+
|
305
|
+
ngx_linefeed(p);
|
306
|
+
|
307
|
+
ngx_http_log_write(r, &log[l], line, p - line);
|
308
|
+
}
|
309
|
+
|
310
|
+
return NGX_OK;
|
311
|
+
}
|
312
|
+
|
313
|
+
|
314
|
+
static void
|
315
|
+
ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, u_char *buf,
|
316
|
+
size_t len)
|
317
|
+
{
|
318
|
+
u_char *name;
|
319
|
+
time_t now;
|
320
|
+
ssize_t n;
|
321
|
+
ngx_err_t err;
|
322
|
+
|
323
|
+
if (log->script == NULL) {
|
324
|
+
name = log->file->name.data;
|
325
|
+
n = ngx_write_fd(log->file->fd, buf, len);
|
326
|
+
|
327
|
+
} else {
|
328
|
+
name = NULL;
|
329
|
+
n = ngx_http_log_script_write(r, log->script, &name, buf, len);
|
330
|
+
}
|
331
|
+
|
332
|
+
if (n == (ssize_t) len) {
|
333
|
+
return;
|
334
|
+
}
|
335
|
+
|
336
|
+
now = ngx_time();
|
337
|
+
|
338
|
+
if (n == -1) {
|
339
|
+
err = ngx_errno;
|
340
|
+
|
341
|
+
if (err == NGX_ENOSPC) {
|
342
|
+
log->disk_full_time = now;
|
343
|
+
}
|
344
|
+
|
345
|
+
if (now - log->error_log_time > 59) {
|
346
|
+
ngx_log_error(NGX_LOG_ALERT, r->connection->log, err,
|
347
|
+
ngx_write_fd_n " to \"%s\" failed", name);
|
348
|
+
|
349
|
+
log->error_log_time = now;
|
350
|
+
}
|
351
|
+
|
352
|
+
return;
|
353
|
+
}
|
354
|
+
|
355
|
+
if (now - log->error_log_time > 59) {
|
356
|
+
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
|
357
|
+
ngx_write_fd_n " to \"%s\" was incomplete: %z of %uz",
|
358
|
+
name, n, len);
|
359
|
+
|
360
|
+
log->error_log_time = now;
|
361
|
+
}
|
362
|
+
}
|
363
|
+
|
364
|
+
|
365
|
+
static ssize_t
|
366
|
+
ngx_http_log_script_write(ngx_http_request_t *r, ngx_http_log_script_t *script,
|
367
|
+
u_char **name, u_char *buf, size_t len)
|
368
|
+
{
|
369
|
+
size_t root;
|
370
|
+
ssize_t n;
|
371
|
+
ngx_str_t log, path;
|
372
|
+
ngx_open_file_info_t of;
|
373
|
+
ngx_http_log_loc_conf_t *llcf;
|
374
|
+
ngx_http_core_loc_conf_t *clcf;
|
375
|
+
|
376
|
+
if (!r->root_tested) {
|
377
|
+
|
378
|
+
/* test root directory existence */
|
379
|
+
|
380
|
+
if (ngx_http_map_uri_to_path(r, &path, &root, 0) == NULL) {
|
381
|
+
/* simulate successful logging */
|
382
|
+
return len;
|
383
|
+
}
|
384
|
+
|
385
|
+
path.data[root] = '\0';
|
386
|
+
|
387
|
+
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
388
|
+
|
389
|
+
ngx_memzero(&of, sizeof(ngx_open_file_info_t));
|
390
|
+
|
391
|
+
of.valid = clcf->open_file_cache_valid;
|
392
|
+
of.min_uses = clcf->open_file_cache_min_uses;
|
393
|
+
of.test_dir = 1;
|
394
|
+
of.test_only = 1;
|
395
|
+
of.errors = clcf->open_file_cache_errors;
|
396
|
+
of.events = clcf->open_file_cache_events;
|
397
|
+
|
398
|
+
if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
|
399
|
+
!= NGX_OK)
|
400
|
+
{
|
401
|
+
if (of.err == 0) {
|
402
|
+
/* simulate successful logging */
|
403
|
+
return len;
|
404
|
+
}
|
405
|
+
|
406
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, of.err,
|
407
|
+
"testing \"%s\" existence failed", path.data);
|
408
|
+
|
409
|
+
/* simulate successful logging */
|
410
|
+
return len;
|
411
|
+
}
|
412
|
+
|
413
|
+
if (!of.is_dir) {
|
414
|
+
ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_ENOTDIR,
|
415
|
+
"testing \"%s\" existence failed", path.data);
|
416
|
+
|
417
|
+
/* simulate successful logging */
|
418
|
+
return len;
|
419
|
+
}
|
420
|
+
}
|
421
|
+
|
422
|
+
if (ngx_http_script_run(r, &log, script->lengths->elts, 1,
|
423
|
+
script->values->elts)
|
424
|
+
== NULL)
|
425
|
+
{
|
426
|
+
/* simulate successful logging */
|
427
|
+
return len;
|
428
|
+
}
|
429
|
+
|
430
|
+
log.data[log.len - 1] = '\0';
|
431
|
+
*name = log.data;
|
432
|
+
|
433
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
434
|
+
"http log \"%s\"", log.data);
|
435
|
+
|
436
|
+
llcf = ngx_http_get_module_loc_conf(r, ngx_http_log_module);
|
437
|
+
|
438
|
+
ngx_memzero(&of, sizeof(ngx_open_file_info_t));
|
439
|
+
|
440
|
+
of.log = 1;
|
441
|
+
of.valid = llcf->open_file_cache_valid;
|
442
|
+
of.min_uses = llcf->open_file_cache_min_uses;
|
443
|
+
of.directio = NGX_OPEN_FILE_DIRECTIO_OFF;
|
444
|
+
|
445
|
+
if (ngx_open_cached_file(llcf->open_file_cache, &log, &of, r->pool)
|
446
|
+
!= NGX_OK)
|
447
|
+
{
|
448
|
+
ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
|
449
|
+
"%s \"%s\" failed", of.failed, log.data);
|
450
|
+
/* simulate successful logging */
|
451
|
+
return len;
|
452
|
+
}
|
453
|
+
|
454
|
+
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
455
|
+
"http log #%d", of.fd);
|
456
|
+
|
457
|
+
n = ngx_write_fd(of.fd, buf, len);
|
458
|
+
|
459
|
+
return n;
|
460
|
+
}
|
461
|
+
|
462
|
+
|
463
|
+
static u_char *
|
464
|
+
ngx_http_log_copy_short(ngx_http_request_t *r, u_char *buf,
|
465
|
+
ngx_http_log_op_t *op)
|
466
|
+
{
|
467
|
+
size_t len;
|
468
|
+
uintptr_t data;
|
469
|
+
|
470
|
+
len = op->len;
|
471
|
+
data = op->data;
|
472
|
+
|
473
|
+
while (len--) {
|
474
|
+
*buf++ = (u_char) (data & 0xff);
|
475
|
+
data >>= 8;
|
476
|
+
}
|
477
|
+
|
478
|
+
return buf;
|
479
|
+
}
|
480
|
+
|
481
|
+
|
482
|
+
static u_char *
|
483
|
+
ngx_http_log_copy_long(ngx_http_request_t *r, u_char *buf,
|
484
|
+
ngx_http_log_op_t *op)
|
485
|
+
{
|
486
|
+
return ngx_cpymem(buf, (u_char *) op->data, op->len);
|
487
|
+
}
|
488
|
+
|
489
|
+
|
490
|
+
static u_char *
|
491
|
+
ngx_http_log_connection(ngx_http_request_t *r, u_char *buf,
|
492
|
+
ngx_http_log_op_t *op)
|
493
|
+
{
|
494
|
+
return ngx_sprintf(buf, "%ui", r->connection->number);
|
495
|
+
}
|
496
|
+
|
497
|
+
|
498
|
+
static u_char *
|
499
|
+
ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
|
500
|
+
{
|
501
|
+
if (r->pipeline) {
|
502
|
+
*buf = 'p';
|
503
|
+
} else {
|
504
|
+
*buf = '.';
|
505
|
+
}
|
506
|
+
|
507
|
+
return buf + 1;
|
508
|
+
}
|
509
|
+
|
510
|
+
|
511
|
+
static u_char *
|
512
|
+
ngx_http_log_time(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
|
513
|
+
{
|
514
|
+
return ngx_cpymem(buf, ngx_cached_http_log_time.data,
|
515
|
+
ngx_cached_http_log_time.len);
|
516
|
+
}
|
517
|
+
|
518
|
+
static u_char *
|
519
|
+
ngx_http_log_iso8601(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
|
520
|
+
{
|
521
|
+
return ngx_cpymem(buf, ngx_cached_http_log_iso8601.data,
|
522
|
+
ngx_cached_http_log_iso8601.len);
|
523
|
+
}
|
524
|
+
|
525
|
+
static u_char *
|
526
|
+
ngx_http_log_msec(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
|
527
|
+
{
|
528
|
+
ngx_time_t *tp;
|
529
|
+
|
530
|
+
tp = ngx_timeofday();
|
531
|
+
|
532
|
+
return ngx_sprintf(buf, "%T.%03M", tp->sec, tp->msec);
|
533
|
+
}
|
534
|
+
|
535
|
+
|
536
|
+
static u_char *
|
537
|
+
ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf,
|
538
|
+
ngx_http_log_op_t *op)
|
539
|
+
{
|
540
|
+
ngx_time_t *tp;
|
541
|
+
ngx_msec_int_t ms;
|
542
|
+
|
543
|
+
tp = ngx_timeofday();
|
544
|
+
|
545
|
+
ms = (ngx_msec_int_t)
|
546
|
+
((tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec));
|
547
|
+
ms = ngx_max(ms, 0);
|
548
|
+
|
549
|
+
return ngx_sprintf(buf, "%T.%03M", ms / 1000, ms % 1000);
|
550
|
+
}
|
551
|
+
|
552
|
+
|
553
|
+
static u_char *
|
554
|
+
ngx_http_log_status(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
|
555
|
+
{
|
556
|
+
ngx_uint_t status;
|
557
|
+
|
558
|
+
if (r->err_status) {
|
559
|
+
status = r->err_status;
|
560
|
+
|
561
|
+
} else if (r->headers_out.status) {
|
562
|
+
status = r->headers_out.status;
|
563
|
+
|
564
|
+
} else if (r->http_version == NGX_HTTP_VERSION_9) {
|
565
|
+
*buf++ = '0';
|
566
|
+
*buf++ = '0';
|
567
|
+
*buf++ = '9';
|
568
|
+
return buf;
|
569
|
+
|
570
|
+
} else {
|
571
|
+
status = 0;
|
572
|
+
}
|
573
|
+
|
574
|
+
return ngx_sprintf(buf, "%ui", status);
|
575
|
+
}
|
576
|
+
|
577
|
+
|
578
|
+
static u_char *
|
579
|
+
ngx_http_log_bytes_sent(ngx_http_request_t *r, u_char *buf,
|
580
|
+
ngx_http_log_op_t *op)
|
581
|
+
{
|
582
|
+
return ngx_sprintf(buf, "%O", r->connection->sent);
|
583
|
+
}
|
584
|
+
|
585
|
+
|
586
|
+
/*
|
587
|
+
* although there is a real $body_bytes_sent variable,
|
588
|
+
* this log operation code function is more optimized for logging
|
589
|
+
*/
|
590
|
+
|
591
|
+
static u_char *
|
592
|
+
ngx_http_log_body_bytes_sent(ngx_http_request_t *r, u_char *buf,
|
593
|
+
ngx_http_log_op_t *op)
|
594
|
+
{
|
595
|
+
off_t length;
|
596
|
+
|
597
|
+
length = r->connection->sent - r->header_size;
|
598
|
+
|
599
|
+
if (length > 0) {
|
600
|
+
return ngx_sprintf(buf, "%O", length);
|
601
|
+
}
|
602
|
+
|
603
|
+
*buf = '0';
|
604
|
+
|
605
|
+
return buf + 1;
|
606
|
+
}
|
607
|
+
|
608
|
+
|
609
|
+
static u_char *
|
610
|
+
ngx_http_log_request_length(ngx_http_request_t *r, u_char *buf,
|
611
|
+
ngx_http_log_op_t *op)
|
612
|
+
{
|
613
|
+
return ngx_sprintf(buf, "%O", r->request_length);
|
614
|
+
}
|
615
|
+
|
616
|
+
|
617
|
+
static ngx_int_t
|
618
|
+
ngx_http_log_variable_compile(ngx_conf_t *cf, ngx_http_log_op_t *op,
|
619
|
+
ngx_str_t *value)
|
620
|
+
{
|
621
|
+
ngx_int_t index;
|
622
|
+
|
623
|
+
index = ngx_http_get_variable_index(cf, value);
|
624
|
+
if (index == NGX_ERROR) {
|
625
|
+
return NGX_ERROR;
|
626
|
+
}
|
627
|
+
|
628
|
+
op->len = 0;
|
629
|
+
op->getlen = ngx_http_log_variable_getlen;
|
630
|
+
op->run = ngx_http_log_variable;
|
631
|
+
op->data = index;
|
632
|
+
|
633
|
+
return NGX_OK;
|
634
|
+
}
|
635
|
+
|
636
|
+
|
637
|
+
static size_t
|
638
|
+
ngx_http_log_variable_getlen(ngx_http_request_t *r, uintptr_t data)
|
639
|
+
{
|
640
|
+
uintptr_t len;
|
641
|
+
ngx_http_variable_value_t *value;
|
642
|
+
|
643
|
+
value = ngx_http_get_indexed_variable(r, data);
|
644
|
+
|
645
|
+
if (value == NULL || value->not_found) {
|
646
|
+
return 1;
|
647
|
+
}
|
648
|
+
|
649
|
+
len = ngx_http_log_escape(NULL, value->data, value->len);
|
650
|
+
|
651
|
+
value->escape = len ? 1 : 0;
|
652
|
+
|
653
|
+
return value->len + len * 3;
|
654
|
+
}
|
655
|
+
|
656
|
+
|
657
|
+
static u_char *
|
658
|
+
ngx_http_log_variable(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
|
659
|
+
{
|
660
|
+
ngx_http_variable_value_t *value;
|
661
|
+
|
662
|
+
value = ngx_http_get_indexed_variable(r, op->data);
|
663
|
+
|
664
|
+
if (value == NULL || value->not_found) {
|
665
|
+
*buf = '-';
|
666
|
+
return buf + 1;
|
667
|
+
}
|
668
|
+
|
669
|
+
if (value->escape == 0) {
|
670
|
+
return ngx_cpymem(buf, value->data, value->len);
|
671
|
+
|
672
|
+
} else {
|
673
|
+
return (u_char *) ngx_http_log_escape(buf, value->data, value->len);
|
674
|
+
}
|
675
|
+
}
|
676
|
+
|
677
|
+
|
678
|
+
static uintptr_t
|
679
|
+
ngx_http_log_escape(u_char *dst, u_char *src, size_t size)
|
680
|
+
{
|
681
|
+
ngx_uint_t n;
|
682
|
+
static u_char hex[] = "0123456789ABCDEF";
|
683
|
+
|
684
|
+
static uint32_t escape[] = {
|
685
|
+
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
686
|
+
|
687
|
+
/* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
|
688
|
+
0x00000004, /* 0000 0000 0000 0000 0000 0000 0000 0100 */
|
689
|
+
|
690
|
+
/* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */
|
691
|
+
0x10000000, /* 0001 0000 0000 0000 0000 0000 0000 0000 */
|
692
|
+
|
693
|
+
/* ~}| {zyx wvut srqp onml kjih gfed cba` */
|
694
|
+
0x80000000, /* 1000 0000 0000 0000 0000 0000 0000 0000 */
|
695
|
+
|
696
|
+
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
697
|
+
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
698
|
+
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
699
|
+
0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
|
700
|
+
};
|
701
|
+
|
702
|
+
|
703
|
+
if (dst == NULL) {
|
704
|
+
|
705
|
+
/* find the number of the characters to be escaped */
|
706
|
+
|
707
|
+
n = 0;
|
708
|
+
|
709
|
+
while (size) {
|
710
|
+
if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
|
711
|
+
n++;
|
712
|
+
}
|
713
|
+
src++;
|
714
|
+
size--;
|
715
|
+
}
|
716
|
+
|
717
|
+
return (uintptr_t) n;
|
718
|
+
}
|
719
|
+
|
720
|
+
while (size) {
|
721
|
+
if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
|
722
|
+
*dst++ = '\\';
|
723
|
+
*dst++ = 'x';
|
724
|
+
*dst++ = hex[*src >> 4];
|
725
|
+
*dst++ = hex[*src & 0xf];
|
726
|
+
src++;
|
727
|
+
|
728
|
+
} else {
|
729
|
+
*dst++ = *src++;
|
730
|
+
}
|
731
|
+
size--;
|
732
|
+
}
|
733
|
+
|
734
|
+
return (uintptr_t) dst;
|
735
|
+
}
|
736
|
+
|
737
|
+
|
738
|
+
static void *
|
739
|
+
ngx_http_log_create_main_conf(ngx_conf_t *cf)
|
740
|
+
{
|
741
|
+
ngx_http_log_main_conf_t *conf;
|
742
|
+
|
743
|
+
ngx_http_log_fmt_t *fmt;
|
744
|
+
|
745
|
+
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_main_conf_t));
|
746
|
+
if (conf == NULL) {
|
747
|
+
return NULL;
|
748
|
+
}
|
749
|
+
|
750
|
+
if (ngx_array_init(&conf->formats, cf->pool, 4, sizeof(ngx_http_log_fmt_t))
|
751
|
+
!= NGX_OK)
|
752
|
+
{
|
753
|
+
return NULL;
|
754
|
+
}
|
755
|
+
|
756
|
+
fmt = ngx_array_push(&conf->formats);
|
757
|
+
if (fmt == NULL) {
|
758
|
+
return NULL;
|
759
|
+
}
|
760
|
+
|
761
|
+
ngx_str_set(&fmt->name, "combined");
|
762
|
+
|
763
|
+
fmt->flushes = NULL;
|
764
|
+
|
765
|
+
fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_http_log_op_t));
|
766
|
+
if (fmt->ops == NULL) {
|
767
|
+
return NULL;
|
768
|
+
}
|
769
|
+
|
770
|
+
return conf;
|
771
|
+
}
|
772
|
+
|
773
|
+
|
774
|
+
static void *
|
775
|
+
ngx_http_log_create_loc_conf(ngx_conf_t *cf)
|
776
|
+
{
|
777
|
+
ngx_http_log_loc_conf_t *conf;
|
778
|
+
|
779
|
+
conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_loc_conf_t));
|
780
|
+
if (conf == NULL) {
|
781
|
+
return NULL;
|
782
|
+
}
|
783
|
+
|
784
|
+
conf->open_file_cache = NGX_CONF_UNSET_PTR;
|
785
|
+
|
786
|
+
return conf;
|
787
|
+
}
|
788
|
+
|
789
|
+
|
790
|
+
static char *
|
791
|
+
ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
792
|
+
{
|
793
|
+
ngx_http_log_loc_conf_t *prev = parent;
|
794
|
+
ngx_http_log_loc_conf_t *conf = child;
|
795
|
+
|
796
|
+
ngx_http_log_t *log;
|
797
|
+
ngx_http_log_fmt_t *fmt;
|
798
|
+
ngx_http_log_main_conf_t *lmcf;
|
799
|
+
|
800
|
+
if (conf->open_file_cache == NGX_CONF_UNSET_PTR) {
|
801
|
+
|
802
|
+
conf->open_file_cache = prev->open_file_cache;
|
803
|
+
conf->open_file_cache_valid = prev->open_file_cache_valid;
|
804
|
+
conf->open_file_cache_min_uses = prev->open_file_cache_min_uses;
|
805
|
+
|
806
|
+
if (conf->open_file_cache == NGX_CONF_UNSET_PTR) {
|
807
|
+
conf->open_file_cache = NULL;
|
808
|
+
}
|
809
|
+
}
|
810
|
+
|
811
|
+
if (conf->logs || conf->off) {
|
812
|
+
return NGX_CONF_OK;
|
813
|
+
}
|
814
|
+
|
815
|
+
conf->logs = prev->logs;
|
816
|
+
conf->off = prev->off;
|
817
|
+
|
818
|
+
if (conf->logs || conf->off) {
|
819
|
+
return NGX_CONF_OK;
|
820
|
+
}
|
821
|
+
|
822
|
+
conf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t));
|
823
|
+
if (conf->logs == NULL) {
|
824
|
+
return NGX_CONF_ERROR;
|
825
|
+
}
|
826
|
+
|
827
|
+
log = ngx_array_push(conf->logs);
|
828
|
+
if (log == NULL) {
|
829
|
+
return NGX_CONF_ERROR;
|
830
|
+
}
|
831
|
+
|
832
|
+
log->file = ngx_conf_open_file(cf->cycle, &ngx_http_access_log);
|
833
|
+
if (log->file == NULL) {
|
834
|
+
return NGX_CONF_ERROR;
|
835
|
+
}
|
836
|
+
|
837
|
+
log->script = NULL;
|
838
|
+
log->disk_full_time = 0;
|
839
|
+
log->error_log_time = 0;
|
840
|
+
|
841
|
+
lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
|
842
|
+
fmt = lmcf->formats.elts;
|
843
|
+
|
844
|
+
/* the default "combined" format */
|
845
|
+
log->format = &fmt[0];
|
846
|
+
lmcf->combined_used = 1;
|
847
|
+
|
848
|
+
return NGX_CONF_OK;
|
849
|
+
}
|
850
|
+
|
851
|
+
|
852
|
+
static char *
|
853
|
+
ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
854
|
+
{
|
855
|
+
ngx_http_log_loc_conf_t *llcf = conf;
|
856
|
+
|
857
|
+
ssize_t buf;
|
858
|
+
ngx_uint_t i, n;
|
859
|
+
ngx_str_t *value, name;
|
860
|
+
ngx_http_log_t *log;
|
861
|
+
ngx_http_log_fmt_t *fmt;
|
862
|
+
ngx_http_log_main_conf_t *lmcf;
|
863
|
+
ngx_http_script_compile_t sc;
|
864
|
+
|
865
|
+
value = cf->args->elts;
|
866
|
+
|
867
|
+
if (ngx_strcmp(value[1].data, "off") == 0) {
|
868
|
+
llcf->off = 1;
|
869
|
+
if (cf->args->nelts == 2) {
|
870
|
+
return NGX_CONF_OK;
|
871
|
+
}
|
872
|
+
|
873
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
874
|
+
"invalid parameter \"%V\"", &value[2]);
|
875
|
+
return NGX_CONF_ERROR;
|
876
|
+
}
|
877
|
+
|
878
|
+
if (llcf->logs == NULL) {
|
879
|
+
llcf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t));
|
880
|
+
if (llcf->logs == NULL) {
|
881
|
+
return NGX_CONF_ERROR;
|
882
|
+
}
|
883
|
+
}
|
884
|
+
|
885
|
+
lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
|
886
|
+
|
887
|
+
log = ngx_array_push(llcf->logs);
|
888
|
+
if (log == NULL) {
|
889
|
+
return NGX_CONF_ERROR;
|
890
|
+
}
|
891
|
+
|
892
|
+
ngx_memzero(log, sizeof(ngx_http_log_t));
|
893
|
+
|
894
|
+
n = ngx_http_script_variables_count(&value[1]);
|
895
|
+
|
896
|
+
if (n == 0) {
|
897
|
+
log->file = ngx_conf_open_file(cf->cycle, &value[1]);
|
898
|
+
if (log->file == NULL) {
|
899
|
+
return NGX_CONF_ERROR;
|
900
|
+
}
|
901
|
+
|
902
|
+
} else {
|
903
|
+
if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {
|
904
|
+
return NGX_CONF_ERROR;
|
905
|
+
}
|
906
|
+
|
907
|
+
log->script = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_script_t));
|
908
|
+
if (log->script == NULL) {
|
909
|
+
return NGX_CONF_ERROR;
|
910
|
+
}
|
911
|
+
|
912
|
+
ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
|
913
|
+
|
914
|
+
sc.cf = cf;
|
915
|
+
sc.source = &value[1];
|
916
|
+
sc.lengths = &log->script->lengths;
|
917
|
+
sc.values = &log->script->values;
|
918
|
+
sc.variables = n;
|
919
|
+
sc.complete_lengths = 1;
|
920
|
+
sc.complete_values = 1;
|
921
|
+
|
922
|
+
if (ngx_http_script_compile(&sc) != NGX_OK) {
|
923
|
+
return NGX_CONF_ERROR;
|
924
|
+
}
|
925
|
+
}
|
926
|
+
|
927
|
+
if (cf->args->nelts >= 3) {
|
928
|
+
name = value[2];
|
929
|
+
|
930
|
+
if (ngx_strcmp(name.data, "combined") == 0) {
|
931
|
+
lmcf->combined_used = 1;
|
932
|
+
}
|
933
|
+
|
934
|
+
} else {
|
935
|
+
ngx_str_set(&name, "combined");
|
936
|
+
lmcf->combined_used = 1;
|
937
|
+
}
|
938
|
+
|
939
|
+
fmt = lmcf->formats.elts;
|
940
|
+
for (i = 0; i < lmcf->formats.nelts; i++) {
|
941
|
+
if (fmt[i].name.len == name.len
|
942
|
+
&& ngx_strcasecmp(fmt[i].name.data, name.data) == 0)
|
943
|
+
{
|
944
|
+
log->format = &fmt[i];
|
945
|
+
goto buffer;
|
946
|
+
}
|
947
|
+
}
|
948
|
+
|
949
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
950
|
+
"unknown log format \"%V\"", &name);
|
951
|
+
return NGX_CONF_ERROR;
|
952
|
+
|
953
|
+
buffer:
|
954
|
+
|
955
|
+
if (cf->args->nelts == 4) {
|
956
|
+
if (ngx_strncmp(value[3].data, "buffer=", 7) != 0) {
|
957
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
958
|
+
"invalid parameter \"%V\"", &value[3]);
|
959
|
+
return NGX_CONF_ERROR;
|
960
|
+
}
|
961
|
+
|
962
|
+
if (log->script) {
|
963
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
964
|
+
"buffered logs cannot have variables in name");
|
965
|
+
return NGX_CONF_ERROR;
|
966
|
+
}
|
967
|
+
|
968
|
+
name.len = value[3].len - 7;
|
969
|
+
name.data = value[3].data + 7;
|
970
|
+
|
971
|
+
buf = ngx_parse_size(&name);
|
972
|
+
|
973
|
+
if (buf == NGX_ERROR) {
|
974
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
975
|
+
"invalid parameter \"%V\"", &value[3]);
|
976
|
+
return NGX_CONF_ERROR;
|
977
|
+
}
|
978
|
+
|
979
|
+
if (log->file->buffer && log->file->last - log->file->pos != buf) {
|
980
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
981
|
+
"access_log \"%V\" already defined "
|
982
|
+
"with different buffer size", &value[1]);
|
983
|
+
return NGX_CONF_ERROR;
|
984
|
+
}
|
985
|
+
|
986
|
+
log->file->buffer = ngx_palloc(cf->pool, buf);
|
987
|
+
if (log->file->buffer == NULL) {
|
988
|
+
return NGX_CONF_ERROR;
|
989
|
+
}
|
990
|
+
|
991
|
+
log->file->pos = log->file->buffer;
|
992
|
+
log->file->last = log->file->buffer + buf;
|
993
|
+
}
|
994
|
+
|
995
|
+
return NGX_CONF_OK;
|
996
|
+
}
|
997
|
+
|
998
|
+
|
999
|
+
static char *
|
1000
|
+
ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
1001
|
+
{
|
1002
|
+
ngx_http_log_main_conf_t *lmcf = conf;
|
1003
|
+
|
1004
|
+
ngx_str_t *value;
|
1005
|
+
ngx_uint_t i;
|
1006
|
+
ngx_http_log_fmt_t *fmt;
|
1007
|
+
|
1008
|
+
value = cf->args->elts;
|
1009
|
+
|
1010
|
+
fmt = lmcf->formats.elts;
|
1011
|
+
for (i = 0; i < lmcf->formats.nelts; i++) {
|
1012
|
+
if (fmt[i].name.len == value[1].len
|
1013
|
+
&& ngx_strcmp(fmt[i].name.data, value[1].data) == 0)
|
1014
|
+
{
|
1015
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1016
|
+
"duplicate \"log_format\" name \"%V\"",
|
1017
|
+
&value[1]);
|
1018
|
+
return NGX_CONF_ERROR;
|
1019
|
+
}
|
1020
|
+
}
|
1021
|
+
|
1022
|
+
fmt = ngx_array_push(&lmcf->formats);
|
1023
|
+
if (fmt == NULL) {
|
1024
|
+
return NGX_CONF_ERROR;
|
1025
|
+
}
|
1026
|
+
|
1027
|
+
fmt->name = value[1];
|
1028
|
+
|
1029
|
+
fmt->flushes = ngx_array_create(cf->pool, 4, sizeof(ngx_int_t));
|
1030
|
+
if (fmt->flushes == NULL) {
|
1031
|
+
return NGX_CONF_ERROR;
|
1032
|
+
}
|
1033
|
+
|
1034
|
+
fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_http_log_op_t));
|
1035
|
+
if (fmt->ops == NULL) {
|
1036
|
+
return NGX_CONF_ERROR;
|
1037
|
+
}
|
1038
|
+
|
1039
|
+
return ngx_http_log_compile_format(cf, fmt->flushes, fmt->ops, cf->args, 2);
|
1040
|
+
}
|
1041
|
+
|
1042
|
+
|
1043
|
+
static char *
|
1044
|
+
ngx_http_log_compile_format(ngx_conf_t *cf, ngx_array_t *flushes,
|
1045
|
+
ngx_array_t *ops, ngx_array_t *args, ngx_uint_t s)
|
1046
|
+
{
|
1047
|
+
u_char *data, *p, ch;
|
1048
|
+
size_t i, len;
|
1049
|
+
ngx_str_t *value, var;
|
1050
|
+
ngx_int_t *flush;
|
1051
|
+
ngx_uint_t bracket;
|
1052
|
+
ngx_http_log_op_t *op;
|
1053
|
+
ngx_http_log_var_t *v;
|
1054
|
+
|
1055
|
+
value = args->elts;
|
1056
|
+
|
1057
|
+
for ( /* void */ ; s < args->nelts; s++) {
|
1058
|
+
|
1059
|
+
i = 0;
|
1060
|
+
|
1061
|
+
while (i < value[s].len) {
|
1062
|
+
|
1063
|
+
op = ngx_array_push(ops);
|
1064
|
+
if (op == NULL) {
|
1065
|
+
return NGX_CONF_ERROR;
|
1066
|
+
}
|
1067
|
+
|
1068
|
+
data = &value[s].data[i];
|
1069
|
+
|
1070
|
+
if (value[s].data[i] == '$') {
|
1071
|
+
|
1072
|
+
if (++i == value[s].len) {
|
1073
|
+
goto invalid;
|
1074
|
+
}
|
1075
|
+
|
1076
|
+
if (value[s].data[i] == '{') {
|
1077
|
+
bracket = 1;
|
1078
|
+
|
1079
|
+
if (++i == value[s].len) {
|
1080
|
+
goto invalid;
|
1081
|
+
}
|
1082
|
+
|
1083
|
+
var.data = &value[s].data[i];
|
1084
|
+
|
1085
|
+
} else {
|
1086
|
+
bracket = 0;
|
1087
|
+
var.data = &value[s].data[i];
|
1088
|
+
}
|
1089
|
+
|
1090
|
+
for (var.len = 0; i < value[s].len; i++, var.len++) {
|
1091
|
+
ch = value[s].data[i];
|
1092
|
+
|
1093
|
+
if (ch == '}' && bracket) {
|
1094
|
+
i++;
|
1095
|
+
bracket = 0;
|
1096
|
+
break;
|
1097
|
+
}
|
1098
|
+
|
1099
|
+
if ((ch >= 'A' && ch <= 'Z')
|
1100
|
+
|| (ch >= 'a' && ch <= 'z')
|
1101
|
+
|| (ch >= '0' && ch <= '9')
|
1102
|
+
|| ch == '_')
|
1103
|
+
{
|
1104
|
+
continue;
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
break;
|
1108
|
+
}
|
1109
|
+
|
1110
|
+
if (bracket) {
|
1111
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1112
|
+
"the closing bracket in \"%V\" "
|
1113
|
+
"variable is missing", &var);
|
1114
|
+
return NGX_CONF_ERROR;
|
1115
|
+
}
|
1116
|
+
|
1117
|
+
if (var.len == 0) {
|
1118
|
+
goto invalid;
|
1119
|
+
}
|
1120
|
+
|
1121
|
+
if (ngx_strncmp(var.data, "apache_bytes_sent", 17) == 0) {
|
1122
|
+
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
1123
|
+
"use \"$body_bytes_sent\" instead of "
|
1124
|
+
"\"$apache_bytes_sent\"");
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
for (v = ngx_http_log_vars; v->name.len; v++) {
|
1128
|
+
|
1129
|
+
if (v->name.len == var.len
|
1130
|
+
&& ngx_strncmp(v->name.data, var.data, var.len) == 0)
|
1131
|
+
{
|
1132
|
+
op->len = v->len;
|
1133
|
+
op->getlen = NULL;
|
1134
|
+
op->run = v->run;
|
1135
|
+
op->data = 0;
|
1136
|
+
|
1137
|
+
goto found;
|
1138
|
+
}
|
1139
|
+
}
|
1140
|
+
|
1141
|
+
if (ngx_http_log_variable_compile(cf, op, &var) != NGX_OK) {
|
1142
|
+
return NGX_CONF_ERROR;
|
1143
|
+
}
|
1144
|
+
|
1145
|
+
if (flushes) {
|
1146
|
+
|
1147
|
+
flush = ngx_array_push(flushes);
|
1148
|
+
if (flush == NULL) {
|
1149
|
+
return NGX_CONF_ERROR;
|
1150
|
+
}
|
1151
|
+
|
1152
|
+
*flush = op->data; /* variable index */
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
found:
|
1156
|
+
|
1157
|
+
continue;
|
1158
|
+
}
|
1159
|
+
|
1160
|
+
i++;
|
1161
|
+
|
1162
|
+
while (i < value[s].len && value[s].data[i] != '$') {
|
1163
|
+
i++;
|
1164
|
+
}
|
1165
|
+
|
1166
|
+
len = &value[s].data[i] - data;
|
1167
|
+
|
1168
|
+
if (len) {
|
1169
|
+
|
1170
|
+
op->len = len;
|
1171
|
+
op->getlen = NULL;
|
1172
|
+
|
1173
|
+
if (len <= sizeof(uintptr_t)) {
|
1174
|
+
op->run = ngx_http_log_copy_short;
|
1175
|
+
op->data = 0;
|
1176
|
+
|
1177
|
+
while (len--) {
|
1178
|
+
op->data <<= 8;
|
1179
|
+
op->data |= data[len];
|
1180
|
+
}
|
1181
|
+
|
1182
|
+
} else {
|
1183
|
+
op->run = ngx_http_log_copy_long;
|
1184
|
+
|
1185
|
+
p = ngx_pnalloc(cf->pool, len);
|
1186
|
+
if (p == NULL) {
|
1187
|
+
return NGX_CONF_ERROR;
|
1188
|
+
}
|
1189
|
+
|
1190
|
+
ngx_memcpy(p, data, len);
|
1191
|
+
op->data = (uintptr_t) p;
|
1192
|
+
}
|
1193
|
+
}
|
1194
|
+
}
|
1195
|
+
}
|
1196
|
+
|
1197
|
+
return NGX_CONF_OK;
|
1198
|
+
|
1199
|
+
invalid:
|
1200
|
+
|
1201
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%s\"", data);
|
1202
|
+
|
1203
|
+
return NGX_CONF_ERROR;
|
1204
|
+
}
|
1205
|
+
|
1206
|
+
|
1207
|
+
static char *
|
1208
|
+
ngx_http_log_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
1209
|
+
{
|
1210
|
+
ngx_http_log_loc_conf_t *llcf = conf;
|
1211
|
+
|
1212
|
+
time_t inactive, valid;
|
1213
|
+
ngx_str_t *value, s;
|
1214
|
+
ngx_int_t max, min_uses;
|
1215
|
+
ngx_uint_t i;
|
1216
|
+
|
1217
|
+
if (llcf->open_file_cache != NGX_CONF_UNSET_PTR) {
|
1218
|
+
return "is duplicate";
|
1219
|
+
}
|
1220
|
+
|
1221
|
+
value = cf->args->elts;
|
1222
|
+
|
1223
|
+
max = 0;
|
1224
|
+
inactive = 10;
|
1225
|
+
valid = 60;
|
1226
|
+
min_uses = 1;
|
1227
|
+
|
1228
|
+
for (i = 1; i < cf->args->nelts; i++) {
|
1229
|
+
|
1230
|
+
if (ngx_strncmp(value[i].data, "max=", 4) == 0) {
|
1231
|
+
|
1232
|
+
max = ngx_atoi(value[i].data + 4, value[i].len - 4);
|
1233
|
+
if (max == NGX_ERROR) {
|
1234
|
+
goto failed;
|
1235
|
+
}
|
1236
|
+
|
1237
|
+
continue;
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
if (ngx_strncmp(value[i].data, "inactive=", 9) == 0) {
|
1241
|
+
|
1242
|
+
s.len = value[i].len - 9;
|
1243
|
+
s.data = value[i].data + 9;
|
1244
|
+
|
1245
|
+
inactive = ngx_parse_time(&s, 1);
|
1246
|
+
if (inactive < 0) {
|
1247
|
+
goto failed;
|
1248
|
+
}
|
1249
|
+
|
1250
|
+
continue;
|
1251
|
+
}
|
1252
|
+
|
1253
|
+
if (ngx_strncmp(value[i].data, "min_uses=", 9) == 0) {
|
1254
|
+
|
1255
|
+
min_uses = ngx_atoi(value[i].data + 9, value[i].len - 9);
|
1256
|
+
if (min_uses == NGX_ERROR) {
|
1257
|
+
goto failed;
|
1258
|
+
}
|
1259
|
+
|
1260
|
+
continue;
|
1261
|
+
}
|
1262
|
+
|
1263
|
+
if (ngx_strncmp(value[i].data, "valid=", 6) == 0) {
|
1264
|
+
|
1265
|
+
s.len = value[i].len - 6;
|
1266
|
+
s.data = value[i].data + 6;
|
1267
|
+
|
1268
|
+
valid = ngx_parse_time(&s, 1);
|
1269
|
+
if (valid < 0) {
|
1270
|
+
goto failed;
|
1271
|
+
}
|
1272
|
+
|
1273
|
+
continue;
|
1274
|
+
}
|
1275
|
+
|
1276
|
+
if (ngx_strcmp(value[i].data, "off") == 0) {
|
1277
|
+
|
1278
|
+
llcf->open_file_cache = NULL;
|
1279
|
+
|
1280
|
+
continue;
|
1281
|
+
}
|
1282
|
+
|
1283
|
+
failed:
|
1284
|
+
|
1285
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1286
|
+
"invalid \"open_log_file_cache\" parameter \"%V\"",
|
1287
|
+
&value[i]);
|
1288
|
+
return NGX_CONF_ERROR;
|
1289
|
+
}
|
1290
|
+
|
1291
|
+
if (llcf->open_file_cache == NULL) {
|
1292
|
+
return NGX_CONF_OK;
|
1293
|
+
}
|
1294
|
+
|
1295
|
+
if (max == 0) {
|
1296
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
1297
|
+
"\"open_log_file_cache\" must have \"max\" parameter");
|
1298
|
+
return NGX_CONF_ERROR;
|
1299
|
+
}
|
1300
|
+
|
1301
|
+
llcf->open_file_cache = ngx_open_file_cache_init(cf->pool, max, inactive);
|
1302
|
+
|
1303
|
+
if (llcf->open_file_cache) {
|
1304
|
+
|
1305
|
+
llcf->open_file_cache_valid = valid;
|
1306
|
+
llcf->open_file_cache_min_uses = min_uses;
|
1307
|
+
|
1308
|
+
return NGX_CONF_OK;
|
1309
|
+
}
|
1310
|
+
|
1311
|
+
return NGX_CONF_ERROR;
|
1312
|
+
}
|
1313
|
+
|
1314
|
+
|
1315
|
+
static ngx_int_t
|
1316
|
+
ngx_http_log_init(ngx_conf_t *cf)
|
1317
|
+
{
|
1318
|
+
ngx_str_t *value;
|
1319
|
+
ngx_array_t a;
|
1320
|
+
ngx_http_handler_pt *h;
|
1321
|
+
ngx_http_log_fmt_t *fmt;
|
1322
|
+
ngx_http_log_main_conf_t *lmcf;
|
1323
|
+
ngx_http_core_main_conf_t *cmcf;
|
1324
|
+
|
1325
|
+
lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
|
1326
|
+
|
1327
|
+
if (lmcf->combined_used) {
|
1328
|
+
if (ngx_array_init(&a, cf->pool, 1, sizeof(ngx_str_t)) != NGX_OK) {
|
1329
|
+
return NGX_ERROR;
|
1330
|
+
}
|
1331
|
+
|
1332
|
+
value = ngx_array_push(&a);
|
1333
|
+
if (value == NULL) {
|
1334
|
+
return NGX_ERROR;
|
1335
|
+
}
|
1336
|
+
|
1337
|
+
*value = ngx_http_combined_fmt;
|
1338
|
+
fmt = lmcf->formats.elts;
|
1339
|
+
|
1340
|
+
if (ngx_http_log_compile_format(cf, NULL, fmt->ops, &a, 0)
|
1341
|
+
!= NGX_CONF_OK)
|
1342
|
+
{
|
1343
|
+
return NGX_ERROR;
|
1344
|
+
}
|
1345
|
+
}
|
1346
|
+
|
1347
|
+
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
1348
|
+
|
1349
|
+
h = ngx_array_push(&cmcf->phases[NGX_HTTP_LOG_PHASE].handlers);
|
1350
|
+
if (h == NULL) {
|
1351
|
+
return NGX_ERROR;
|
1352
|
+
}
|
1353
|
+
|
1354
|
+
*h = ngx_http_log_handler;
|
1355
|
+
|
1356
|
+
return NGX_OK;
|
1357
|
+
}
|