├── .gitattributes ├── LICENSE ├── Makefile ├── README ├── README.bak ├── auto ├── cc │ ├── acc │ ├── bcc │ ├── ccc │ ├── clang │ ├── conf │ ├── gcc │ ├── icc │ ├── msvc │ ├── name │ ├── owc │ └── sunc ├── configure ├── define ├── endianness ├── feature ├── have ├── have_headers ├── headers ├── include ├── init ├── install ├── lib │ ├── conf │ ├── geoip │ │ └── conf │ ├── google-perftools │ │ └── conf │ ├── libatomic │ │ ├── conf │ │ └── make │ ├── libgd │ │ └── conf │ ├── libxslt │ │ └── conf │ ├── make │ ├── md5 │ │ ├── conf │ │ ├── make │ │ ├── makefile.bcc │ │ ├── makefile.msvc │ │ └── makefile.owc │ ├── openssl │ │ ├── conf │ │ ├── make │ │ ├── makefile.bcc │ │ └── makefile.msvc │ ├── pcre │ │ ├── conf │ │ ├── make │ │ ├── makefile.bcc │ │ ├── makefile.msvc │ │ └── makefile.owc │ ├── perl │ │ ├── conf │ │ └── make │ ├── sha1 │ │ ├── conf │ │ ├── make │ │ ├── makefile.bcc │ │ ├── makefile.msvc │ │ └── makefile.owc │ ├── test │ └── zlib │ │ ├── conf │ │ ├── make │ │ ├── makefile.bcc │ │ ├── makefile.msvc │ │ ├── makefile.owc │ │ └── patch.zlib.h ├── make ├── modules ├── nohave ├── options ├── os │ ├── conf │ ├── darwin │ ├── freebsd │ ├── linux │ ├── solaris │ └── win32 ├── sources ├── stubs ├── summary ├── types │ ├── sizeof │ ├── typedef │ ├── uintptr_t │ └── value └── unix ├── conf ├── fastcgi.conf ├── fastcgi_params ├── koi-utf ├── koi-win ├── mime.types ├── nginx.conf ├── scgi_params ├── uwsgi_params └── win-utf ├── configure ├── docs ├── GNUmakefile ├── dtd │ ├── change_log_conf.dtd │ └── changes.dtd ├── html │ ├── 50x.html │ └── index.html ├── man │ └── nginx.8 ├── text │ ├── LICENSE │ └── README ├── xml │ ├── change_log_conf.xml │ └── nginx │ │ └── changes.xml ├── xsls │ └── changes.xsls └── xslt │ └── changes.xslt ├── html ├── 50x.html └── index.html ├── man └── nginx.8 ├── misc ├── GNUmakefile └── README ├── nginx.sln ├── objs ├── Makefile ├── autoconf.err ├── ngx_auto_config.h ├── ngx_auto_headers.h ├── ngx_modules.c └── ngx_pch.c ├── src ├── core │ ├── nginx.c │ ├── nginx.h │ ├── ngx_array.c │ ├── ngx_array.h │ ├── ngx_buf.c │ ├── ngx_buf.h │ ├── ngx_conf_file.c │ ├── ngx_conf_file.h │ ├── ngx_config.h │ ├── ngx_connection.c │ ├── ngx_connection.h │ ├── ngx_core.h │ ├── ngx_cpuinfo.c │ ├── ngx_crc.h │ ├── ngx_crc32.c │ ├── ngx_crc32.h │ ├── ngx_crypt.c │ ├── ngx_crypt.h │ ├── ngx_cycle.c │ ├── ngx_cycle.h │ ├── ngx_file.c │ ├── ngx_file.h │ ├── ngx_hash.c │ ├── ngx_hash.h │ ├── ngx_inet.c │ ├── ngx_inet.h │ ├── ngx_list.c │ ├── ngx_list.h │ ├── ngx_log.c │ ├── ngx_log.h │ ├── ngx_md5.c │ ├── ngx_md5.h │ ├── ngx_murmurhash.c │ ├── ngx_murmurhash.h │ ├── ngx_open_file_cache.c │ ├── ngx_open_file_cache.h │ ├── ngx_output_chain.c │ ├── ngx_palloc.c │ ├── ngx_palloc.h │ ├── ngx_parse.c │ ├── ngx_parse.h │ ├── ngx_proxy_protocol.c │ ├── ngx_proxy_protocol.h │ ├── ngx_queue.c │ ├── ngx_queue.h │ ├── ngx_radix_tree.c │ ├── ngx_radix_tree.h │ ├── ngx_rbtree.c │ ├── ngx_rbtree.h │ ├── ngx_regex.c │ ├── ngx_regex.h │ ├── ngx_resolver.c │ ├── ngx_resolver.h │ ├── ngx_sha1.h │ ├── ngx_shmtx.c │ ├── ngx_shmtx.h │ ├── ngx_slab.c │ ├── ngx_slab.h │ ├── ngx_spinlock.c │ ├── ngx_string.c │ ├── ngx_string.h │ ├── ngx_times.c │ └── ngx_times.h ├── event │ ├── modules │ │ ├── ngx_aio_module.c │ │ ├── ngx_devpoll_module.c │ │ ├── ngx_epoll_module.c │ │ ├── ngx_eventport_module.c │ │ ├── ngx_iocp_module.c │ │ ├── ngx_iocp_module.h │ │ ├── ngx_kqueue_module.c │ │ ├── ngx_poll_module.c │ │ ├── ngx_rtsig_module.c │ │ ├── ngx_select_module.c │ │ └── ngx_win32_select_module.c │ ├── ngx_event.c │ ├── ngx_event.h │ ├── ngx_event_accept.c │ ├── ngx_event_acceptex.c │ ├── ngx_event_busy_lock.c │ ├── ngx_event_busy_lock.h │ ├── ngx_event_connect.c │ ├── ngx_event_connect.h │ ├── ngx_event_connectex.c │ ├── ngx_event_mutex.c │ ├── ngx_event_openssl.c │ ├── ngx_event_openssl.h │ ├── ngx_event_openssl_stapling.c │ ├── ngx_event_pipe.c │ ├── ngx_event_pipe.h │ ├── ngx_event_posted.c │ ├── ngx_event_posted.h │ ├── ngx_event_timer.c │ └── ngx_event_timer.h ├── http │ ├── modules │ │ ├── ngx_http_access_module.c │ │ ├── ngx_http_addition_filter_module.c │ │ ├── ngx_http_auth_basic_module.c │ │ ├── ngx_http_auth_request_module.c │ │ ├── ngx_http_autoindex_module.c │ │ ├── ngx_http_browser_module.c │ │ ├── ngx_http_charset_filter_module.c │ │ ├── ngx_http_chunked_filter_module.c │ │ ├── ngx_http_dav_module.c │ │ ├── ngx_http_degradation_module.c │ │ ├── ngx_http_empty_gif_module.c │ │ ├── ngx_http_fastcgi_module.c │ │ ├── ngx_http_flv_module.c │ │ ├── ngx_http_geo_module.c │ │ ├── ngx_http_geoip_module.c │ │ ├── ngx_http_gunzip_filter_module.c │ │ ├── ngx_http_gzip_filter_module.c │ │ ├── ngx_http_gzip_static_module.c │ │ ├── ngx_http_headers_filter_module.c │ │ ├── ngx_http_image_filter_module.c │ │ ├── ngx_http_index_module.c │ │ ├── ngx_http_limit_conn_module.c │ │ ├── ngx_http_limit_req_module.c │ │ ├── ngx_http_log_module.c │ │ ├── ngx_http_map_module.c │ │ ├── ngx_http_memcached_module.c │ │ ├── ngx_http_mp4_module.c │ │ ├── ngx_http_not_modified_filter_module.c │ │ ├── ngx_http_proxy_module.c │ │ ├── ngx_http_random_index_module.c │ │ ├── ngx_http_range_filter_module.c │ │ ├── ngx_http_realip_module.c │ │ ├── ngx_http_referer_module.c │ │ ├── ngx_http_rewrite_module.c │ │ ├── ngx_http_scgi_module.c │ │ ├── ngx_http_secure_link_module.c │ │ ├── ngx_http_split_clients_module.c │ │ ├── ngx_http_ssi_filter_module.c │ │ ├── ngx_http_ssi_filter_module.h │ │ ├── ngx_http_ssl_module.c │ │ ├── ngx_http_ssl_module.h │ │ ├── ngx_http_static_module.c │ │ ├── ngx_http_stub_status_module.c │ │ ├── ngx_http_sub_filter_module.c │ │ ├── ngx_http_upstream_ip_hash_module.c │ │ ├── ngx_http_upstream_keepalive_module.c │ │ ├── ngx_http_upstream_least_conn_module.c │ │ ├── ngx_http_userid_filter_module.c │ │ ├── ngx_http_uwsgi_module.c │ │ ├── ngx_http_xslt_filter_module.c │ │ └── perl │ │ │ ├── Makefile.PL │ │ │ ├── nginx.pm │ │ │ ├── nginx.xs │ │ │ ├── ngx_http_perl_module.c │ │ │ ├── ngx_http_perl_module.h │ │ │ └── typemap │ ├── ngx_http.c │ ├── ngx_http.h │ ├── ngx_http_busy_lock.c │ ├── ngx_http_busy_lock.h │ ├── ngx_http_cache.h │ ├── ngx_http_config.h │ ├── ngx_http_copy_filter_module.c │ ├── ngx_http_core_module.c │ ├── ngx_http_core_module.h │ ├── ngx_http_file_cache.c │ ├── ngx_http_header_filter_module.c │ ├── ngx_http_parse.c │ ├── ngx_http_parse_time.c │ ├── ngx_http_postpone_filter_module.c │ ├── ngx_http_request.c │ ├── ngx_http_request.h │ ├── ngx_http_request_body.c │ ├── ngx_http_script.c │ ├── ngx_http_script.h │ ├── ngx_http_spdy.c │ ├── ngx_http_spdy.h │ ├── ngx_http_spdy_filter_module.c │ ├── ngx_http_spdy_module.c │ ├── ngx_http_spdy_module.h │ ├── ngx_http_special_response.c │ ├── ngx_http_upstream.c │ ├── ngx_http_upstream.h │ ├── ngx_http_upstream_round_robin.c │ ├── ngx_http_upstream_round_robin.h │ ├── ngx_http_variables.c │ ├── ngx_http_variables.h │ └── ngx_http_write_filter_module.c ├── mail │ ├── ngx_mail.c │ ├── ngx_mail.h │ ├── ngx_mail_auth_http_module.c │ ├── ngx_mail_core_module.c │ ├── ngx_mail_handler.c │ ├── ngx_mail_imap_handler.c │ ├── ngx_mail_imap_module.c │ ├── ngx_mail_imap_module.h │ ├── ngx_mail_parse.c │ ├── ngx_mail_pop3_handler.c │ ├── ngx_mail_pop3_module.c │ ├── ngx_mail_pop3_module.h │ ├── ngx_mail_proxy_module.c │ ├── ngx_mail_smtp_handler.c │ ├── ngx_mail_smtp_module.c │ ├── ngx_mail_smtp_module.h │ ├── ngx_mail_ssl_module.c │ └── ngx_mail_ssl_module.h ├── misc │ ├── ngx_cpp_test_module.cpp │ └── ngx_google_perftools_module.c ├── mysql │ ├── config │ ├── ngx_http_mysql_test.c │ ├── ngx_mysql.c │ └── ngx_mysql.h └── os │ ├── unix │ ├── ngx_aio_read.c │ ├── ngx_aio_read_chain.c │ ├── ngx_aio_write.c │ ├── ngx_aio_write_chain.c │ ├── ngx_alloc.c │ ├── ngx_alloc.h │ ├── ngx_atomic.h │ ├── ngx_channel.c │ ├── ngx_channel.h │ ├── ngx_daemon.c │ ├── ngx_darwin.h │ ├── ngx_darwin_config.h │ ├── ngx_darwin_init.c │ ├── ngx_darwin_sendfile_chain.c │ ├── ngx_errno.c │ ├── ngx_errno.h │ ├── ngx_file_aio_read.c │ ├── ngx_files.c │ ├── ngx_files.h │ ├── ngx_freebsd.h │ ├── ngx_freebsd_config.h │ ├── ngx_freebsd_init.c │ ├── ngx_freebsd_rfork_thread.c │ ├── ngx_freebsd_rfork_thread.h │ ├── ngx_freebsd_sendfile_chain.c │ ├── ngx_gcc_atomic_amd64.h │ ├── ngx_gcc_atomic_ppc.h │ ├── ngx_gcc_atomic_sparc64.h │ ├── ngx_gcc_atomic_x86.h │ ├── ngx_linux.h │ ├── ngx_linux_aio_read.c │ ├── ngx_linux_config.h │ ├── ngx_linux_init.c │ ├── ngx_linux_sendfile_chain.c │ ├── ngx_os.h │ ├── ngx_posix_config.h │ ├── ngx_posix_init.c │ ├── ngx_process.c │ ├── ngx_process.h │ ├── ngx_process_cycle.c │ ├── ngx_process_cycle.h │ ├── ngx_pthread_thread.c │ ├── ngx_readv_chain.c │ ├── ngx_recv.c │ ├── ngx_send.c │ ├── ngx_setaffinity.c │ ├── ngx_setaffinity.h │ ├── ngx_setproctitle.c │ ├── ngx_setproctitle.h │ ├── ngx_shmem.c │ ├── ngx_shmem.h │ ├── ngx_socket.c │ ├── ngx_socket.h │ ├── ngx_solaris.h │ ├── ngx_solaris_config.h │ ├── ngx_solaris_init.c │ ├── ngx_solaris_sendfilev_chain.c │ ├── ngx_sunpro_amd64.il │ ├── ngx_sunpro_atomic_sparc64.h │ ├── ngx_sunpro_sparc64.il │ ├── ngx_sunpro_x86.il │ ├── ngx_thread.h │ ├── ngx_time.c │ ├── ngx_time.h │ ├── ngx_udp_recv.c │ ├── ngx_user.c │ ├── ngx_user.h │ ├── ngx_writev_chain.c │ └── rfork_thread.S │ └── win32 │ ├── nginx.ico │ ├── nginx.rc │ ├── nginx_icon16.xpm │ ├── nginx_icon32.xpm │ ├── nginx_icon48.xpm │ ├── ngx_alloc.c │ ├── ngx_alloc.h │ ├── ngx_atomic.h │ ├── ngx_errno.c │ ├── ngx_errno.h │ ├── ngx_event_log.c │ ├── ngx_files.c │ ├── ngx_files.h │ ├── ngx_os.h │ ├── ngx_process.c │ ├── ngx_process.h │ ├── ngx_process_cycle.c │ ├── ngx_process_cycle.h │ ├── ngx_service.c │ ├── ngx_shmem.c │ ├── ngx_shmem.h │ ├── ngx_socket.c │ ├── ngx_socket.h │ ├── ngx_stat.c │ ├── ngx_thread.c │ ├── ngx_thread.h │ ├── ngx_time.c │ ├── ngx_time.h │ ├── ngx_udp_wsarecv.c │ ├── ngx_user.c │ ├── ngx_user.h │ ├── ngx_win32_config.h │ ├── ngx_win32_init.c │ ├── ngx_wsarecv.c │ ├── ngx_wsarecv_chain.c │ ├── ngx_wsasend.c │ └── ngx_wsasend_chain.c └── win ├── conf ├── fastcgi.conf ├── fastcgi_params ├── koi-utf ├── koi-win ├── mime.types ├── nginx.conf ├── scgi_params ├── uwsgi_params └── win-utf ├── generate ├── ngx_auto_config.h ├── ngx_auto_headers.h ├── ngx_modules.c └── ngx_pch.c ├── html ├── 50x.html └── index.html ├── logs ├── access.log ├── error.log └── nginx.pid ├── nginx-1.9.9.sdf ├── nginx-1.9.9.vcxproj └── nginx-1.9.9.vcxproj.filters /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2014 Igor Sysoev 3 | * Copyright (C) 2011-2014 Nginx, Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | default: build 3 | 4 | clean: 5 | rm -rf Makefile objs 6 | 7 | build: 8 | $(MAKE) -f objs/Makefile 9 | $(MAKE) -f objs/Makefile manpage 10 | 11 | install: 12 | $(MAKE) -f objs/Makefile install 13 | 14 | upgrade: 15 | /cygdrive/c/nginx/sbin/nginx -t 16 | 17 | kill -USR2 `cat /cygdrive/c/nginx/logs/nginx.pid` 18 | sleep 1 19 | test -f /cygdrive/c/nginx/logs/nginx.pid.oldbin 20 | 21 | kill -QUIT `cat /cygdrive/c/nginx/logs/nginx.pid.oldbin` 22 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Nginx 1.9.9 build on win32 platform by VS2015 2 | 3 | Documentation is available at http://nginx.org 4 | 5 | -------------------------------------------------------------------------------- /README.bak: -------------------------------------------------------------------------------- 1 | USE VS2015 Build Nginx 1.9.9 2 | 3 | Documentation is available at http://nginx.org 4 | 5 | -------------------------------------------------------------------------------- /auto/cc/acc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | # aCC: HP ANSI C++ B3910B A.03.55.02 7 | 8 | # C89 mode 9 | 10 | CFLAGS="$CFLAGS -Ae" 11 | CC_TEST_FLAGS="-Ae" 12 | 13 | PCRE_OPT="$PCRE_OPT -Ae" 14 | ZLIB_OPT="$ZLIB_OPT -Ae" 15 | MD5_OPT="$MD5_OPT -Ae" 16 | -------------------------------------------------------------------------------- /auto/cc/bcc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | # Borland C++ 5.5 7 | 8 | # optimizations 9 | 10 | # maximize speed 11 | CFLAGS="$CFLAGS -O2" 12 | 13 | case $CPU in 14 | pentium) 15 | # optimize for Pentium and Athlon 16 | CPU_OPT="-5" 17 | ;; 18 | 19 | pentiumpro) 20 | # optimize for Pentium Pro, Pentium II and Pentium III 21 | CPU_OPT="-6" 22 | ;; 23 | esac 24 | 25 | # __stdcall 26 | #CPU_OPT="$CPU_OPT -ps" 27 | # __fastcall 28 | #CPU_OPT="$CPU_OPT -pr" 29 | 30 | CFLAGS="$CFLAGS $CPU_OPT" 31 | 32 | # multithreaded 33 | CFLAGS="$CFLAGS -tWM" 34 | 35 | # stop on warning 36 | CFLAGS="$CFLAGS -w!" 37 | 38 | # disable logo 39 | CFLAGS="$CFLAGS -q" 40 | 41 | 42 | # precompiled headers 43 | CORE_DEPS="$CORE_DEPS $NGX_OBJS/ngx_config.csm" 44 | NGX_PCH="$NGX_OBJS/ngx_config.csm" 45 | NGX_BUILD_PCH="-H=$NGX_OBJS/ngx_config.csm" 46 | NGX_USE_PCH="-Hu -H=$NGX_OBJS/ngx_config.csm" 47 | 48 | 49 | # Win32 GUI mode application 50 | #LINK="\$(CC) -laa" 51 | 52 | 53 | # the resource file 54 | NGX_RES="$NGX_OBJS/nginx.res" 55 | NGX_RCC="brcc32 -fo$NGX_OBJS/nginx.res \$(CORE_INCS) $NGX_WIN32_RC" 56 | # the pragma allows to link the resource file using bcc32 and 57 | # to avoid the direct ilink32 calling and the c0w32.obj's WinMain/main problem 58 | NGX_PRAGMA="#pragma resource \"$NGX_OBJS/nginx.res\"" 59 | 60 | 61 | ngx_include_opt="-I" 62 | ngx_objout="-o" 63 | ngx_binout="-e" 64 | ngx_objext="obj" 65 | ngx_binext=".exe" 66 | 67 | ngx_long_start='@&&| 68 | ' 69 | ngx_long_end='|' 70 | 71 | ngx_regex_dirsep='\\' 72 | ngx_dirsep="\\" 73 | -------------------------------------------------------------------------------- /auto/cc/ccc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | # Compaq C V6.5-207 7 | 8 | ngx_include_opt="-I" 9 | 10 | # warnings 11 | 12 | CFLAGS="$CFLAGS -msg_enable level6 -msg_fatal level6" 13 | 14 | CFLAGS="$CFLAGS -msg_disable unknownmacro" 15 | CFLAGS="$CFLAGS -msg_disable unusedincl" 16 | CFLAGS="$CFLAGS -msg_disable unnecincl" 17 | CFLAGS="$CFLAGS -msg_disable nestincl" 18 | CFLAGS="$CFLAGS -msg_disable strctpadding" 19 | CFLAGS="$CFLAGS -msg_disable ansialiascast" 20 | CFLAGS="$CFLAGS -msg_disable inlinestoclsmod" 21 | CFLAGS="$CFLAGS -msg_disable cxxkeyword" 22 | CFLAGS="$CFLAGS -msg_disable longlongsufx" 23 | CFLAGS="$CFLAGS -msg_disable valuepres" 24 | 25 | # STUB 26 | CFLAGS="$CFLAGS -msg_disable truncintcast" 27 | CFLAGS="$CFLAGS -msg_disable trunclongcast" 28 | 29 | CFLAGS="$CFLAGS -msg_disable truncintasn" 30 | CFLAGS="$CFLAGS -msg_disable trunclongint" 31 | CFLAGS="$CFLAGS -msg_disable intconcastsgn" 32 | CFLAGS="$CFLAGS -msg_disable intconstsign" 33 | CFLAGS="$CFLAGS -msg_disable switchlong" 34 | CFLAGS="$CFLAGS -msg_disable subscrbounds2" 35 | 36 | CFLAGS="$CFLAGS -msg_disable hexoctunsign" 37 | 38 | CFLAGS="$CFLAGS -msg_disable ignorecallval" 39 | CFLAGS="$CFLAGS -msg_disable nonstandcast" 40 | CFLAGS="$CFLAGS -msg_disable embedcomment" 41 | CFLAGS="$CFLAGS -msg_disable unreachcode" 42 | CFLAGS="$CFLAGS -msg_disable questcompare2" 43 | CFLAGS="$CFLAGS -msg_disable unusedtop" 44 | CFLAGS="$CFLAGS -msg_disable unrefdecl" 45 | 46 | CFLAGS="$CFLAGS -msg_disable bitnotint" 47 | -------------------------------------------------------------------------------- /auto/cc/clang: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Nginx, Inc. 3 | 4 | 5 | # clang 6 | 7 | 8 | NGX_CLANG_VER=`$CC -v 2>&1 | grep '\(clang\|LLVM\) version' 2>&1 \ 9 | | sed -e 's/^.* version \(.*\)/\1/'` 10 | 11 | echo " + clang version: $NGX_CLANG_VER" 12 | 13 | have=NGX_COMPILER value="\"clang $NGX_CLANG_VER\"" . auto/define 14 | 15 | 16 | CC_TEST_FLAGS="-pipe" 17 | 18 | 19 | # optimizations 20 | 21 | #NGX_CLANG_OPT="-O2" 22 | #NGX_CLANG_OPT="-Oz" 23 | NGX_CLANG_OPT="-O" 24 | 25 | case $CPU in 26 | pentium) 27 | # optimize for Pentium 28 | CPU_OPT="-march=pentium" 29 | NGX_CPU_CACHE_LINE=32 30 | ;; 31 | 32 | pentiumpro | pentium3) 33 | # optimize for Pentium Pro, Pentium II and Pentium III 34 | CPU_OPT="-march=pentiumpro" 35 | NGX_CPU_CACHE_LINE=32 36 | ;; 37 | 38 | pentium4) 39 | # optimize for Pentium 4 40 | CPU_OPT="-march=pentium4" 41 | NGX_CPU_CACHE_LINE=128 42 | ;; 43 | 44 | athlon) 45 | # optimize for Athlon 46 | CPU_OPT="-march=athlon" 47 | NGX_CPU_CACHE_LINE=64 48 | ;; 49 | 50 | opteron) 51 | # optimize for Opteron 52 | CPU_OPT="-march=opteron" 53 | NGX_CPU_CACHE_LINE=64 54 | ;; 55 | 56 | esac 57 | 58 | CC_AUX_FLAGS="$CC_AUX_FLAGS $CPU_OPT" 59 | 60 | 61 | CFLAGS="$CFLAGS -pipe $CPU_OPT" 62 | 63 | if [ ".$PCRE_OPT" = "." ]; then 64 | PCRE_OPT="-O2 -pipe $CPU_OPT" 65 | else 66 | PCRE_OPT="$PCRE_OPT -pipe" 67 | fi 68 | 69 | if [ ".$MD5_OPT" = "." ]; then 70 | MD5_OPT="-O2 -pipe $CPU_OPT" 71 | else 72 | MD5_OPT="$MD5_OPT -pipe" 73 | fi 74 | 75 | if [ ".$ZLIB_OPT" = "." ]; then 76 | ZLIB_OPT="-O2 -pipe $CPU_OPT" 77 | else 78 | ZLIB_OPT="$ZLIB_OPT -pipe" 79 | fi 80 | 81 | 82 | # warnings 83 | 84 | CFLAGS="$CFLAGS $NGX_CLANG_OPT -Wall -Wextra -Wpointer-arith" 85 | CFLAGS="$CFLAGS -Wconditional-uninitialized" 86 | #CFLAGS="$CFLAGS -Wmissing-prototypes" 87 | 88 | # we have a lot of unused function arguments 89 | CFLAGS="$CFLAGS -Wno-unused-parameter" 90 | 91 | # stop on warning 92 | CFLAGS="$CFLAGS -Werror" 93 | 94 | # debug 95 | CFLAGS="$CFLAGS -g" 96 | 97 | if [ ".$CPP" = "." ]; then 98 | CPP="$CC -E" 99 | fi 100 | -------------------------------------------------------------------------------- /auto/cc/owc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | # Open Watcom C 1.0, 1.2, 1.3 7 | 8 | # optimizations 9 | 10 | # maximize speed 11 | CFLAGS="$CFLAGS -ot" 12 | # reorder instructions for best pipeline usage 13 | CFLAGS="$CFLAGS -op" 14 | # inline intrinsic functions 15 | CFLAGS="$CFLAGS -oi" 16 | # inline expansion 17 | CFLAGS="$CFLAGS -oe" 18 | # disable stack checking calls 19 | CFLAGS="$CFLAGS -s" 20 | 21 | case $CPU in 22 | pentium) 23 | # optimize for Pentium and Athlon 24 | # register-based arguments passing conventions 25 | CPU_OPT="-5r" 26 | # stack-based arguments passing conventions 27 | #CPU_OPT="-5s" 28 | ;; 29 | 30 | pentiumpro) 31 | # optimize for Pentium Pro, Pentium II and Pentium III 32 | # register-based arguments passing conventions 33 | CPU_OPT="-6r" 34 | # stack-based arguments passing conventions 35 | #CPU_OPT="-6s" 36 | ;; 37 | esac 38 | 39 | CFLAGS="$CFLAGS $CPU_OPT" 40 | 41 | 42 | # warnings 43 | 44 | # maximum level 45 | CFLAGS="$CFLAGS -wx" 46 | #CFLAGS="$CFLAGS -w3" 47 | 48 | # stop on warning 49 | CFLAGS="$CFLAGS -we" 50 | 51 | # built target is NT 52 | CFLAGS="$CFLAGS -bt=nt" 53 | 54 | # multithreaded 55 | CFLAGS="$CFLAGS -bm" 56 | 57 | # debug 58 | CFLAGS="$CFLAGS -d2" 59 | 60 | # quiet 61 | CFLAGS="$CFLAGS -zq" 62 | 63 | # Open Watcom C 1.2 64 | have=NGX_HAVE_C99_VARIADIC_MACROS . auto/have 65 | 66 | 67 | # the precompiled headers 68 | #CORE_DEPS="$CORE_DEPS $NGX_OBJS/ngx_config.pch" 69 | #NGX_PCH="$NGX_OBJS/ngx_config.pch" 70 | #NGX_BUILD_PCH="-fhq=$NGX_OBJS/ngx_config.pch" 71 | #NGX_USE_PCH="-fh=$NGX_OBJS/ngx_config.pch" 72 | 73 | 74 | # the link flags, built target is NT GUI mode application 75 | #CORE_LINK="$CORE_LINK -l=nt_win" 76 | 77 | 78 | # the resource file 79 | NGX_RCC="wrc \$(CORE_INCS) -fo=$NGX_OBJS/nginx.res " 80 | NGX_RCC="$NGX_RCC $NGX_WIN32_RC $NGX_OBJS/nginx.exe" 81 | 82 | 83 | ngx_include_opt="-i=" 84 | ngx_objout="-fo" 85 | ngx_binout="-fe=" 86 | ngx_objext="obj" 87 | ngx_binext=".exe" 88 | 89 | ngx_regex_dirsep='\\' 90 | ngx_dirsep="\\" 91 | 92 | ngx_long_start=' ' 93 | ngx_long_end=' ' 94 | ngx_long_regex_cont=' \&\ 95 | ' 96 | ngx_long_cont=' & 97 | ' 98 | 99 | ngx_regex_cont=' \&\ 100 | ' 101 | ngx_cont=' & 102 | ' 103 | ngx_tab=' & 104 | ' 105 | -------------------------------------------------------------------------------- /auto/define: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | cat << END >> $NGX_AUTO_CONFIG_H 7 | 8 | #ifndef $have 9 | #define $have $value 10 | #endif 11 | 12 | END 13 | -------------------------------------------------------------------------------- /auto/endianness: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | echo $ngx_n "checking for system byte ordering ...$ngx_c" 7 | echo >> $NGX_ERR 8 | echo "checking for system byte ordering" >> $NGX_ERR 9 | 10 | 11 | cat << END > $NGX_AUTOTEST.c 12 | 13 | int main() { 14 | int i = 0x11223344; 15 | char *p; 16 | 17 | p = (char *) &i; 18 | if (*p == 0x44) return 0; 19 | return 1; 20 | } 21 | 22 | END 23 | 24 | ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \ 25 | -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs" 26 | 27 | eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1" 28 | 29 | if [ -x $NGX_AUTOTEST ]; then 30 | if $NGX_AUTOTEST >/dev/null 2>&1; then 31 | echo " little endian" 32 | have=NGX_HAVE_LITTLE_ENDIAN . auto/have 33 | else 34 | echo " big endian" 35 | fi 36 | 37 | rm -rf $NGX_AUTOTEST* 38 | 39 | else 40 | rm -rf $NGX_AUTOTEST* 41 | 42 | echo 43 | echo "$0: error: cannot detect system byte ordering" 44 | exit 1 45 | fi 46 | -------------------------------------------------------------------------------- /auto/have: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | cat << END >> $NGX_AUTO_CONFIG_H 7 | 8 | #ifndef $have 9 | #define $have 1 10 | #endif 11 | 12 | END 13 | -------------------------------------------------------------------------------- /auto/have_headers: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | cat << END >> $NGX_AUTO_HEADERS_H 7 | 8 | #ifndef $have 9 | #define $have 1 10 | #endif 11 | 12 | END 13 | -------------------------------------------------------------------------------- /auto/headers: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | ngx_include="unistd.h"; . auto/include 7 | ngx_include="inttypes.h"; . auto/include 8 | ngx_include="limits.h"; . auto/include 9 | ngx_include="sys/filio.h"; . auto/include 10 | ngx_include="sys/param.h"; . auto/include 11 | ngx_include="sys/mount.h"; . auto/include 12 | ngx_include="sys/statvfs.h"; . auto/include 13 | ngx_include="crypt.h"; . auto/include 14 | -------------------------------------------------------------------------------- /auto/include: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | echo $ngx_n "checking for $ngx_include ...$ngx_c" 7 | 8 | cat << END >> $NGX_AUTOCONF_ERR 9 | 10 | ---------------------------------------- 11 | checking for $ngx_include 12 | 13 | END 14 | 15 | 16 | ngx_found=no 17 | 18 | cat << END > $NGX_AUTOTEST.c 19 | 20 | $NGX_INCLUDE_SYS_PARAM_H 21 | #include <$ngx_include> 22 | 23 | int main() { 24 | return 0; 25 | } 26 | 27 | END 28 | 29 | 30 | ngx_test="$CC -o $NGX_AUTOTEST $NGX_AUTOTEST.c" 31 | 32 | eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1" 33 | 34 | if [ -x $NGX_AUTOTEST ]; then 35 | 36 | ngx_found=yes 37 | 38 | echo " found" 39 | 40 | ngx_name=`echo $ngx_include \ 41 | | tr abcdefghijklmnopqrstuvwxyz/. ABCDEFGHIJKLMNOPQRSTUVWXYZ__` 42 | 43 | 44 | have=NGX_HAVE_$ngx_name . auto/have_headers 45 | 46 | eval "NGX_INCLUDE_$ngx_name='#include <$ngx_include>'" 47 | 48 | #STUB 49 | eval "NGX_$ngx_name='#include <$ngx_include>'" 50 | 51 | else 52 | echo " not found" 53 | 54 | echo "----------" >> $NGX_AUTOCONF_ERR 55 | cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR 56 | echo "----------" >> $NGX_AUTOCONF_ERR 57 | echo $ngx_test >> $NGX_AUTOCONF_ERR 58 | echo "----------" >> $NGX_AUTOCONF_ERR 59 | fi 60 | 61 | rm -rf $NGX_AUTOTEST* 62 | -------------------------------------------------------------------------------- /auto/init: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | NGX_MAKEFILE=$NGX_OBJS/Makefile 7 | NGX_MODULES_C=$NGX_OBJS/ngx_modules.c 8 | 9 | NGX_AUTO_HEADERS_H=$NGX_OBJS/ngx_auto_headers.h 10 | NGX_AUTO_CONFIG_H=$NGX_OBJS/ngx_auto_config.h 11 | 12 | NGX_AUTOTEST=$NGX_OBJS/autotest 13 | NGX_AUTOCONF_ERR=$NGX_OBJS/autoconf.err 14 | 15 | # STUBs 16 | NGX_ERR=$NGX_OBJS/autoconf.err 17 | MAKEFILE=$NGX_OBJS/Makefile 18 | 19 | 20 | NGX_PCH= 21 | NGX_USE_PCH= 22 | 23 | 24 | # check the echo's "-n" option and "\c" capability 25 | 26 | if echo "test\c" | grep c >/dev/null; then 27 | 28 | if echo -n test | grep n >/dev/null; then 29 | ngx_n= 30 | ngx_c= 31 | 32 | else 33 | ngx_n=-n 34 | ngx_c= 35 | fi 36 | 37 | else 38 | ngx_n= 39 | ngx_c='\c' 40 | fi 41 | 42 | 43 | # create Makefile 44 | 45 | cat << END > Makefile 46 | 47 | default: build 48 | 49 | clean: 50 | rm -rf Makefile $NGX_OBJS 51 | END 52 | -------------------------------------------------------------------------------- /auto/lib/conf: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | if [ $USE_PCRE = YES -o $PCRE != NONE ]; then 7 | . auto/lib/pcre/conf 8 | 9 | else 10 | if [ $USE_PCRE = DISABLED -a $HTTP_REWRITE = YES ]; then 11 | 12 | cat << END 13 | 14 | $0: error: the HTTP rewrite module requires the PCRE library. 15 | You can either disable the module by using --without-http_rewrite_module 16 | option or you have to enable the PCRE support. 17 | 18 | END 19 | exit 1 20 | fi 21 | fi 22 | 23 | 24 | if [ $USE_OPENSSL = YES ]; then 25 | . auto/lib/openssl/conf 26 | fi 27 | 28 | if [ $USE_MD5 = YES ]; then 29 | 30 | if [ $USE_OPENSSL = YES ]; then 31 | have=NGX_HAVE_OPENSSL_MD5_H . auto/have 32 | have=NGX_OPENSSL_MD5 . auto/have 33 | have=NGX_HAVE_MD5 . auto/have 34 | MD5=YES 35 | MD5_LIB=OpenSSL 36 | 37 | else 38 | . auto/lib/md5/conf 39 | fi 40 | 41 | fi 42 | 43 | if [ $USE_SHA1 = YES ]; then 44 | 45 | if [ $USE_OPENSSL = YES ]; then 46 | have=NGX_HAVE_OPENSSL_SHA1_H . auto/have 47 | have=NGX_HAVE_SHA1 . auto/have 48 | SHA1=YES 49 | SHA1_LIB=OpenSSL 50 | 51 | else 52 | . auto/lib/sha1/conf 53 | fi 54 | 55 | fi 56 | 57 | if [ $USE_ZLIB = YES ]; then 58 | . auto/lib/zlib/conf 59 | fi 60 | 61 | if [ $USE_LIBXSLT = YES ]; then 62 | . auto/lib/libxslt/conf 63 | fi 64 | 65 | if [ $USE_LIBGD = YES ]; then 66 | . auto/lib/libgd/conf 67 | fi 68 | 69 | if [ $USE_PERL = YES ]; then 70 | . auto/lib/perl/conf 71 | fi 72 | 73 | if [ $HTTP_GEOIP = YES ]; then 74 | . auto/lib/geoip/conf 75 | fi 76 | 77 | if [ $NGX_GOOGLE_PERFTOOLS = YES ]; then 78 | . auto/lib/google-perftools/conf 79 | fi 80 | 81 | if [ $NGX_LIBATOMIC != NO ]; then 82 | . auto/lib/libatomic/conf 83 | fi 84 | -------------------------------------------------------------------------------- /auto/lib/geoip/conf: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | ngx_feature="GeoIP library" 7 | ngx_feature_name= 8 | ngx_feature_run=no 9 | ngx_feature_incs="#include " 10 | ngx_feature_path= 11 | ngx_feature_libs="-lGeoIP" 12 | ngx_feature_test="GeoIP_open(NULL, 0)" 13 | . auto/feature 14 | 15 | 16 | if [ $ngx_found = no ]; then 17 | 18 | # FreeBSD port 19 | 20 | ngx_feature="GeoIP library in /usr/local/" 21 | ngx_feature_path="/usr/local/include" 22 | 23 | if [ $NGX_RPATH = YES ]; then 24 | ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lGeoIP" 25 | else 26 | ngx_feature_libs="-L/usr/local/lib -lGeoIP" 27 | fi 28 | 29 | . auto/feature 30 | fi 31 | 32 | 33 | if [ $ngx_found = no ]; then 34 | 35 | # NetBSD port 36 | 37 | ngx_feature="GeoIP library in /usr/pkg/" 38 | ngx_feature_path="/usr/pkg/include" 39 | 40 | if [ $NGX_RPATH = YES ]; then 41 | ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lGeoIP" 42 | else 43 | ngx_feature_libs="-L/usr/pkg/lib -lGeoIP" 44 | fi 45 | 46 | . auto/feature 47 | fi 48 | 49 | 50 | if [ $ngx_found = no ]; then 51 | 52 | # MacPorts 53 | 54 | ngx_feature="GeoIP library in /opt/local/" 55 | ngx_feature_path="/opt/local/include" 56 | 57 | if [ $NGX_RPATH = YES ]; then 58 | ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lGeoIP" 59 | else 60 | ngx_feature_libs="-L/opt/local/lib -lGeoIP" 61 | fi 62 | 63 | . auto/feature 64 | fi 65 | 66 | 67 | if [ $ngx_found = yes ]; then 68 | 69 | CORE_INCS="$CORE_INCS $ngx_feature_path" 70 | CORE_LIBS="$CORE_LIBS $ngx_feature_libs" 71 | 72 | if [ $NGX_IPV6 = YES ]; then 73 | ngx_feature="GeoIP IPv6 support" 74 | ngx_feature_name="NGX_HAVE_GEOIP_V6" 75 | ngx_feature_run=no 76 | ngx_feature_incs="#include 77 | #include " 78 | #ngx_feature_path= 79 | #ngx_feature_libs= 80 | ngx_feature_test="printf(\"%d\", GEOIP_CITY_EDITION_REV0_V6);" 81 | . auto/feature 82 | fi 83 | 84 | else 85 | 86 | cat << END 87 | 88 | $0: error: the GeoIP module requires the GeoIP library. 89 | You can either do not enable the module or install the library. 90 | 91 | END 92 | 93 | exit 1 94 | fi 95 | -------------------------------------------------------------------------------- /auto/lib/google-perftools/conf: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | ngx_feature="Google perftools" 7 | ngx_feature_name= 8 | ngx_feature_run=no 9 | ngx_feature_incs= 10 | ngx_feature_path= 11 | ngx_feature_libs="-lprofiler" 12 | ngx_feature_test="ProfilerStop()" 13 | . auto/feature 14 | 15 | 16 | if [ $ngx_found = no ]; then 17 | 18 | # FreeBSD port 19 | 20 | ngx_feature="Google perftools in /usr/local/" 21 | 22 | if [ $NGX_RPATH = YES ]; then 23 | ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lprofiler" 24 | else 25 | ngx_feature_libs="-L/usr/local/lib -lprofiler" 26 | fi 27 | 28 | . auto/feature 29 | fi 30 | 31 | 32 | if [ $ngx_found = no ]; then 33 | 34 | # MacPorts 35 | 36 | ngx_feature="Google perftools in /opt/local/" 37 | 38 | if [ $NGX_RPATH = YES ]; then 39 | ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lprofiler" 40 | else 41 | ngx_feature_libs="-L/opt/local/lib -lprofiler" 42 | fi 43 | 44 | . auto/feature 45 | fi 46 | 47 | 48 | if [ $ngx_found = yes ]; then 49 | CORE_LIBS="$CORE_LIBS $ngx_feature_libs" 50 | 51 | else 52 | 53 | cat << END 54 | 55 | $0: error: the Google perftool module requires the Google perftools 56 | library. You can either do not enable the module or install the library. 57 | 58 | END 59 | 60 | exit 1 61 | fi 62 | -------------------------------------------------------------------------------- /auto/lib/libatomic/conf: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | if [ $NGX_LIBATOMIC != YES ]; then 7 | 8 | have=NGX_HAVE_LIBATOMIC . auto/have 9 | CORE_INCS="$CORE_INCS $NGX_LIBATOMIC/src" 10 | LINK_DEPS="$LINK_DEPS $NGX_LIBATOMIC/src/libatomic_ops.a" 11 | CORE_LIBS="$CORE_LIBS $NGX_LIBATOMIC/src/libatomic_ops.a" 12 | 13 | else 14 | 15 | ngx_feature="atomic_ops library" 16 | ngx_feature_name=NGX_HAVE_LIBATOMIC 17 | ngx_feature_run=yes 18 | ngx_feature_incs="#define AO_REQUIRE_CAS 19 | #include " 20 | ngx_feature_path= 21 | ngx_feature_libs="-latomic_ops" 22 | ngx_feature_test="long n = 0; 23 | if (!AO_compare_and_swap(&n, 0, 1)) 24 | return 1; 25 | if (AO_fetch_and_add(&n, 1) != 1) 26 | return 1; 27 | if (n != 2) 28 | return 1; 29 | AO_nop();" 30 | . auto/feature 31 | 32 | if [ $ngx_found = yes ]; then 33 | CORE_LIBS="$CORE_LIBS $ngx_feature_libs" 34 | else 35 | 36 | cat << END 37 | 38 | $0: error: libatomic_ops library was not found. 39 | 40 | END 41 | exit 1 42 | fi 43 | fi 44 | -------------------------------------------------------------------------------- /auto/lib/libatomic/make: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | cat << END >> $NGX_MAKEFILE 7 | 8 | $NGX_LIBATOMIC/src/libatomic_ops.a: $NGX_LIBATOMIC/Makefile 9 | cd $NGX_LIBATOMIC && \$(MAKE) 10 | 11 | $NGX_LIBATOMIC/Makefile: $NGX_MAKEFILE 12 | cd $NGX_LIBATOMIC \\ 13 | && if [ -f Makefile ]; then \$(MAKE) distclean; fi \\ 14 | && ./configure 15 | 16 | END 17 | -------------------------------------------------------------------------------- /auto/lib/libgd/conf: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | ngx_feature="GD library" 7 | ngx_feature_name= 8 | ngx_feature_run=no 9 | ngx_feature_incs="#include " 10 | ngx_feature_path= 11 | ngx_feature_libs="-lgd" 12 | ngx_feature_test="gdImagePtr img = gdImageCreateFromGifPtr(1, NULL);" 13 | . auto/feature 14 | 15 | 16 | if [ $ngx_found = no ]; then 17 | 18 | # FreeBSD port 19 | 20 | ngx_feature="GD library in /usr/local/" 21 | ngx_feature_path="/usr/local/include" 22 | 23 | if [ $NGX_RPATH = YES ]; then 24 | ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lgd" 25 | else 26 | ngx_feature_libs="-L/usr/local/lib -lgd" 27 | fi 28 | 29 | . auto/feature 30 | fi 31 | 32 | 33 | if [ $ngx_found = no ]; then 34 | 35 | # NetBSD port 36 | 37 | ngx_feature="GD library in /usr/pkg/" 38 | ngx_feature_path="/usr/pkg/include" 39 | 40 | if [ $NGX_RPATH = YES ]; then 41 | ngx_feature_libs="-R/usr/pkg/lib -L/usr/pkg/lib -lgd" 42 | else 43 | ngx_feature_libs="-L/usr/pkg/lib -lgd" 44 | fi 45 | 46 | . auto/feature 47 | fi 48 | 49 | 50 | if [ $ngx_found = no ]; then 51 | 52 | # MacPorts 53 | 54 | ngx_feature="GD library in /opt/local/" 55 | ngx_feature_path="/opt/local/include" 56 | 57 | if [ $NGX_RPATH = YES ]; then 58 | ngx_feature_libs="-R/opt/local/lib -L/opt/local/lib -lgd" 59 | else 60 | ngx_feature_libs="-L/opt/local/lib -lgd" 61 | fi 62 | 63 | . auto/feature 64 | fi 65 | 66 | 67 | if [ $ngx_found = yes ]; then 68 | 69 | CORE_INCS="$CORE_INCS $ngx_feature_path" 70 | CORE_LIBS="$CORE_LIBS $ngx_feature_libs" 71 | 72 | else 73 | 74 | cat << END 75 | 76 | $0: error: the HTTP image filter module requires the GD library. 77 | You can either do not enable the module or install the libraries. 78 | 79 | END 80 | 81 | exit 1 82 | 83 | fi 84 | -------------------------------------------------------------------------------- /auto/lib/make: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | if [ $PCRE != NONE -a $PCRE != NO -a $PCRE != YES ]; then 7 | . auto/lib/pcre/make 8 | fi 9 | 10 | if [ $MD5 != NONE -a $MD5 != NO -a $MD5 != YES ]; then 11 | . auto/lib/md5/make 12 | fi 13 | 14 | if [ $SHA1 != NONE -a $SHA1 != NO -a $SHA1 != YES ]; then 15 | . auto/lib/sha1/make 16 | fi 17 | 18 | if [ $OPENSSL != NONE -a $OPENSSL != NO -a $OPENSSL != YES ]; then 19 | . auto/lib/openssl/make 20 | fi 21 | 22 | if [ $ZLIB != NONE -a $ZLIB != NO -a $ZLIB != YES ]; then 23 | . auto/lib/zlib/make 24 | fi 25 | 26 | if [ $NGX_LIBATOMIC != NO -a $NGX_LIBATOMIC != YES ]; then 27 | . auto/lib/libatomic/make 28 | fi 29 | 30 | if [ $USE_PERL = YES ]; then 31 | . auto/lib/perl/make 32 | fi 33 | -------------------------------------------------------------------------------- /auto/lib/md5/make: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | case "$NGX_CC_NAME" in 7 | 8 | msvc*) 9 | ngx_makefile=makefile.msvc 10 | ngx_opt="CPU_OPT=\"$CPU_OPT\" LIBC=$LIBC MD5_ASM=$MD5_ASM" 11 | ngx_md5="MD5=\"$MD5\"" 12 | ;; 13 | 14 | owc*) 15 | ngx_makefile=makefile.owc 16 | ngx_opt="CPU_OPT=\"$CPU_OPT\"" 17 | ngx_md5=`echo MD5=\"$MD5\" | sed -e "s/\//$ngx_regex_dirsep/g"` 18 | ;; 19 | 20 | bcc) 21 | ngx_makefile=makefile.bcc 22 | ngx_opt="-DCPU_OPT=\"$CPU_OPT\" -DMD5_ASM=$MD5_ASM" 23 | ngx_md5=`echo \-DMD5=\"$MD5\" | sed -e "s/\//$ngx_regex_dirsep/g"` 24 | ;; 25 | 26 | esac 27 | 28 | 29 | done=NO 30 | 31 | 32 | case "$NGX_PLATFORM" in 33 | 34 | win32) 35 | cat << END >> $NGX_MAKEFILE 36 | 37 | `echo "$MD5/md5.lib: $NGX_MAKEFILE" | sed -e "s/\//$ngx_regex_dirsep/g"` 38 | \$(MAKE) -f auto/lib/md5/$ngx_makefile $ngx_opt $ngx_md5 39 | 40 | END 41 | 42 | done=YES 43 | ;; 44 | 45 | SunOS:*:i86pc) 46 | if [ $MD5_ASM = YES ]; then 47 | 48 | cat << END >> $NGX_MAKEFILE 49 | 50 | $MD5/libmd5.a: $NGX_MAKEFILE 51 | cd $MD5 \\ 52 | && \$(MAKE) CFLAGS="$MD5_OPT -DSOL -DMD5_ASM -DL_ENDIAN" \\ 53 | CC="\$(CC)" CPP="\$(CPP)" \\ 54 | MD5_ASM_OBJ=asm/mx86-sol.o clean libmd5.a 55 | 56 | END 57 | 58 | done=YES 59 | fi 60 | ;; 61 | 62 | # FreeBSD: i386 63 | # Linux: i686 64 | 65 | *:i386 | *:i686) 66 | if [ $MD5_ASM = YES ]; then 67 | 68 | cat << END >> $NGX_MAKEFILE 69 | 70 | $MD5/libmd5.a: $NGX_MAKEFILE 71 | cd $MD5 \\ 72 | && \$(MAKE) CFLAGS="$MD5_OPT -DELF -DMD5_ASM -DL_ENDIAN" \\ 73 | CC="\$(CC)" CPP="\$(CPP)" \\ 74 | MD5_ASM_OBJ=asm/mx86-elf.o clean libmd5.a 75 | 76 | END 77 | 78 | done=YES 79 | fi 80 | ;; 81 | 82 | esac 83 | 84 | 85 | if [ $done = NO ]; then 86 | 87 | cat << END >> $NGX_MAKEFILE 88 | 89 | $MD5/libmd5.a: $NGX_MAKEFILE 90 | cd $MD5 \\ 91 | && \$(MAKE) CFLAGS="$MD5_OPT" \\ 92 | CC="\$(CC)" MD5_ASM_OBJ= clean libmd5.a 93 | 94 | END 95 | 96 | fi 97 | -------------------------------------------------------------------------------- /auto/lib/md5/makefile.bcc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | CFLAGS = -q -O2 -tWM $(CPU_OPT) -DL_ENDIAN 7 | 8 | !if "$(MD5_ASM)" == "YES" 9 | 10 | md5.lib: 11 | cd $(MD5) 12 | bcc32 -c $(CFLAGS) -DMD5_ASM md5_dgst.c 13 | tlib md5.lib +md5_dgst.obj +"asm\m-win32.obj" 14 | 15 | !else 16 | 17 | md5.lib: 18 | cd $(MD5) 19 | bcc32 -c $(CFLAGS) md5_dgst.c 20 | tlib md5.lib +md5_dgst.obj 21 | 22 | !endif 23 | -------------------------------------------------------------------------------- /auto/lib/md5/makefile.msvc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | CFLAGS = -nologo -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT) -D L_ENDIAN 7 | 8 | !IF "$(MD5_ASM)" == "YES" 9 | 10 | md5.lib: 11 | cd $(MD5) 12 | cl -c $(CFLAGS) -D MD5_ASM md5_dgst.c 13 | link -lib -out:md5.lib md5_dgst.obj asm/m-win32.obj 14 | 15 | !ELSE 16 | 17 | md5.lib: 18 | cd $(MD5) 19 | cl -c $(CFLAGS) md5_dgst.c 20 | link -lib -out:md5.lib md5_dgst.obj 21 | 22 | !ENDIF 23 | -------------------------------------------------------------------------------- /auto/lib/md5/makefile.owc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | CFLAGS = -zq -bt=nt -bm -ot -op -oi -oe -s $(CPU_OPT) 7 | 8 | md5.lib: 9 | cd $(MD5) 10 | wcl386 -c $(CFLAGS) -dL_ENDIAN md5_dgst.c 11 | wlib -n md5.lib md5_dgst.obj 12 | -------------------------------------------------------------------------------- /auto/lib/openssl/conf: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | if [ $OPENSSL != NONE ]; then 7 | 8 | case "$CC" in 9 | 10 | cl | bcc32) 11 | have=NGX_OPENSSL . auto/have 12 | have=NGX_SSL . auto/have 13 | 14 | CFLAGS="$CFLAGS -DNO_SYS_TYPES_H" 15 | 16 | CORE_INCS="$CORE_INCS $OPENSSL/openssl/include" 17 | CORE_DEPS="$CORE_DEPS $OPENSSL/openssl/include/openssl/ssl.h" 18 | CORE_LIBS="$CORE_LIBS $OPENSSL/openssl/lib/ssleay32.lib" 19 | CORE_LIBS="$CORE_LIBS $OPENSSL/openssl/lib/libeay32.lib" 20 | 21 | # libeay32.lib requires gdi32.lib 22 | CORE_LIBS="$CORE_LIBS gdi32.lib" 23 | # OpenSSL 1.0.0 requires crypt32.lib 24 | CORE_LIBS="$CORE_LIBS crypt32.lib" 25 | ;; 26 | 27 | *) 28 | have=NGX_OPENSSL . auto/have 29 | have=NGX_SSL . auto/have 30 | 31 | CORE_INCS="$CORE_INCS $OPENSSL/.openssl/include" 32 | CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h" 33 | CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a" 34 | CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a" 35 | CORE_LIBS="$CORE_LIBS $NGX_LIBDL" 36 | 37 | if [ "$NGX_PLATFORM" = win32 ]; then 38 | CORE_LIBS="$CORE_LIBS -lgdi32 -lcrypt32 -lws2_32" 39 | fi 40 | ;; 41 | esac 42 | 43 | else 44 | 45 | if [ "$NGX_PLATFORM" != win32 ]; then 46 | 47 | OPENSSL=NO 48 | 49 | ngx_feature="OpenSSL library" 50 | ngx_feature_name="NGX_OPENSSL" 51 | ngx_feature_run=no 52 | ngx_feature_incs="#include " 53 | ngx_feature_path= 54 | ngx_feature_libs="-lssl -lcrypto" 55 | ngx_feature_test="SSL_library_init()" 56 | . auto/feature 57 | 58 | if [ $ngx_found = yes ]; then 59 | have=NGX_SSL . auto/have 60 | CORE_LIBS="$CORE_LIBS $ngx_feature_libs $NGX_LIBDL" 61 | OPENSSL=YES 62 | fi 63 | fi 64 | 65 | if [ $OPENSSL != YES ]; then 66 | 67 | cat << END 68 | 69 | $0: error: SSL modules require the OpenSSL library. 70 | You can either do not enable the modules, or install the OpenSSL library 71 | into the system, or build the OpenSSL library statically from the source 72 | with nginx by using --with-openssl= option. 73 | 74 | END 75 | exit 1 76 | fi 77 | 78 | fi 79 | -------------------------------------------------------------------------------- /auto/lib/openssl/make: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | case "$CC" in 7 | 8 | cl) 9 | 10 | cat << END >> $NGX_MAKEFILE 11 | 12 | $OPENSSL/openssl/include/openssl/ssl.h: $NGX_MAKEFILE 13 | \$(MAKE) -f auto/lib/openssl/makefile.msvc \ 14 | OPENSSL="$OPENSSL" OPENSSL_OPT="$OPENSSL_OPT" 15 | 16 | END 17 | 18 | ;; 19 | 20 | bcc32) 21 | 22 | ngx_opt=`echo "-DOPENSSL=\"$OPENSSL\" -DOPENSSL_OPT=\"$OPENSSL_OPT\"" \ 23 | | sed -e "s/\//$ngx_regex_dirsep/g"` 24 | 25 | cat << END >> $NGX_MAKEFILE 26 | 27 | `echo "$OPENSSL\\openssl\\lib\\libeay32.lib: \ 28 | $OPENSSL\\openssl\\include\\openssl\\ssl.h" \ 29 | | sed -e "s/\//$ngx_regex_dirsep/g"` 30 | 31 | `echo "$OPENSSL\\openssl\\lib\\ssleay32.lib: \ 32 | $OPENSSL\\openssl\\include\\openssl\\ssl.h" \ 33 | | sed -e "s/\//$ngx_regex_dirsep/g"` 34 | 35 | `echo "$OPENSSL\\openssl\\include\\openssl\\ssl.h: $NGX_MAKEFILE" \ 36 | | sed -e "s/\//$ngx_regex_dirsep/g"` 37 | \$(MAKE) -f auto/lib/openssl/makefile.bcc $ngx_opt 38 | 39 | END 40 | 41 | ;; 42 | 43 | *) 44 | case $USE_THREADS in 45 | NO) OPENSSL_OPT="$OPENSSL_OPT no-threads" ;; 46 | *) OPENSSL_OPT="$OPENSSL_OPT threads" ;; 47 | esac 48 | 49 | case $OPENSSL in 50 | /*) ngx_prefix="$OPENSSL/.openssl" ;; 51 | *) ngx_prefix="$PWD/$OPENSSL/.openssl" ;; 52 | esac 53 | 54 | cat << END >> $NGX_MAKEFILE 55 | 56 | $OPENSSL/.openssl/include/openssl/ssl.h: $NGX_MAKEFILE 57 | cd $OPENSSL \\ 58 | && if [ -f Makefile ]; then \$(MAKE) clean; fi \\ 59 | && ./config --prefix=$ngx_prefix no-shared $OPENSSL_OPT \\ 60 | && \$(MAKE) \\ 61 | && \$(MAKE) install LIBDIR=lib 62 | 63 | END 64 | 65 | ;; 66 | 67 | esac 68 | -------------------------------------------------------------------------------- /auto/lib/openssl/makefile.bcc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | all: 7 | cd $(OPENSSL) 8 | 9 | perl Configure BC-32 no-shared --prefix=openssl $(OPENSSL_OPT) 10 | 11 | ms\do_nasm 12 | 13 | $(MAKE) -f ms\bcb.mak 14 | $(MAKE) -f ms\bcb.mak install 15 | 16 | # Borland's make does not expand "[ch]" in 17 | # copy "inc32\openssl\*.[ch]" "openssl\include\openssl" 18 | copy inc32\openssl\*.h openssl\include\openssl 19 | -------------------------------------------------------------------------------- /auto/lib/openssl/makefile.msvc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | all: 7 | cd $(OPENSSL) 8 | 9 | perl Configure VC-WIN32 no-shared --prefix=openssl $(OPENSSL_OPT) 10 | 11 | ms\do_ms 12 | 13 | $(MAKE) -f ms\nt.mak 14 | $(MAKE) -f ms\nt.mak install 15 | -------------------------------------------------------------------------------- /auto/lib/pcre/make: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | case "$NGX_CC_NAME" in 7 | 8 | msvc*) 9 | ngx_makefile=makefile.msvc 10 | ngx_opt="CPU_OPT=\"$CPU_OPT\" LIBC=$LIBC" 11 | ngx_pcre="PCRE=\"$PCRE\"" 12 | ;; 13 | 14 | owc*) 15 | ngx_makefile=makefile.owc 16 | ngx_opt="CPU_OPT=\"$CPU_OPT\"" 17 | ngx_pcre=`echo PCRE=\"$PCRE\" | sed -e "s/\//$ngx_regex_dirsep/g"` 18 | ;; 19 | 20 | bcc) 21 | ngx_makefile=makefile.bcc 22 | ngx_opt="-DCPU_OPT=\"$CPU_OPT\"" 23 | ngx_pcre=`echo \-DPCRE=\"$PCRE\" | sed -e "s/\//$ngx_regex_dirsep/g"` 24 | ;; 25 | 26 | *) 27 | ngx_makefile= 28 | ;; 29 | 30 | esac 31 | 32 | 33 | if [ -n "$ngx_makefile" ]; then 34 | 35 | cat << END >> $NGX_MAKEFILE 36 | 37 | `echo "$PCRE/pcre.lib: $PCRE/pcre.h $NGX_MAKEFILE" \ 38 | | sed -e "s/\//$ngx_regex_dirsep/g"` 39 | \$(MAKE) -f auto/lib/pcre/$ngx_makefile $ngx_pcre $ngx_opt 40 | 41 | `echo "$PCRE/pcre.h:" | sed -e "s/\//$ngx_regex_dirsep/g"` 42 | \$(MAKE) -f auto/lib/pcre/$ngx_makefile $ngx_pcre pcre.h 43 | 44 | END 45 | 46 | else 47 | 48 | cat << END >> $NGX_MAKEFILE 49 | 50 | $PCRE/pcre.h: $PCRE/Makefile 51 | 52 | $PCRE/Makefile: $NGX_MAKEFILE 53 | cd $PCRE \\ 54 | && if [ -f Makefile ]; then \$(MAKE) distclean; fi \\ 55 | && CC="\$(CC)" CFLAGS="$PCRE_OPT" \\ 56 | ./configure --disable-shared $PCRE_CONF_OPT 57 | 58 | $PCRE/.libs/libpcre.a: $PCRE/Makefile 59 | cd $PCRE \\ 60 | && \$(MAKE) libpcre.la 61 | 62 | END 63 | 64 | fi 65 | -------------------------------------------------------------------------------- /auto/lib/pcre/makefile.bcc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | CFLAGS = -q -O2 -tWM -w-8004 $(CPU_OPT) 7 | PCREFLAGS = -DHAVE_CONFIG_H -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10 \ 8 | -DSUPPORT_PCRE8 -DHAVE_MEMMOVE 9 | 10 | 11 | pcre.lib: 12 | cd $(PCRE) 13 | 14 | bcc32 -c $(CFLAGS) -I. $(PCREFLAGS) pcre_*.c 15 | 16 | copy /y nul pcre.lst 17 | for %n in (*.obj) do @echo +%n ^^& >> pcre.lst 18 | echo + >> pcre.lst 19 | 20 | tlib pcre.lib @pcre.lst 21 | 22 | pcre.h: 23 | cd $(PCRE) 24 | 25 | copy /y pcre.h.generic pcre.h 26 | copy /y config.h.generic config.h 27 | copy /y pcre_chartables.c.dist pcre_chartables.c 28 | -------------------------------------------------------------------------------- /auto/lib/pcre/makefile.msvc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | CFLAGS = -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT) 7 | PCREFLAGS = -DHAVE_CONFIG_H -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10 \ 8 | -DSUPPORT_PCRE8 -DHAVE_MEMMOVE 9 | 10 | 11 | pcre.lib: 12 | cd $(PCRE) 13 | 14 | cl -nologo -c $(CFLAGS) -I . $(PCREFLAGS) pcre_*.c 15 | 16 | link -lib -out:pcre.lib -verbose:lib pcre_*.obj 17 | 18 | pcre.h: 19 | cd $(PCRE) 20 | 21 | copy /y pcre.h.generic pcre.h 22 | copy /y config.h.generic config.h 23 | copy /y pcre_chartables.c.dist pcre_chartables.c 24 | -------------------------------------------------------------------------------- /auto/lib/pcre/makefile.owc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | CFLAGS = -c -zq -bt=nt -ot -op -oi -oe -s -bm $(CPU_OPT) 7 | PCREFLAGS = -DHAVE_CONFIG_H -DPCRE_STATIC -DPOSIX_MALLOC_THRESHOLD=10 & 8 | -DSUPPORT_PCRE8 -DHAVE_MEMMOVE 9 | 10 | 11 | pcre.lib: 12 | cd $(PCRE) 13 | 14 | wcl386 $(CFLAGS) -i=. $(PCREFLAGS) pcre_*.c 15 | 16 | dir /b *.obj > pcre.lst 17 | 18 | wlib -n pcre.lib @pcre.lst 19 | 20 | pcre.h: 21 | cd $(PCRE) 22 | 23 | copy /y pcre.h.generic pcre.h 24 | copy /y config.h.generic config.h 25 | copy /y pcre_chartables.c.dist pcre_chartables.c 26 | -------------------------------------------------------------------------------- /auto/lib/perl/conf: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | echo "checking for perl" 7 | 8 | 9 | NGX_PERL_VER=`$NGX_PERL -v 2>&1 | grep '^This is perl' 2>&1 \ 10 | | sed -e 's/^This is perl, \(.*\)/\1/'` 11 | 12 | if test -n "$NGX_PERL_VER"; then 13 | echo " + perl version: $NGX_PERL_VER" 14 | 15 | if [ "`$NGX_PERL -e 'use 5.006001; print "OK"'`" != "OK" ]; then 16 | echo 17 | echo "$0: error: perl 5.6.1 or higher is required" 18 | echo 19 | 20 | exit 1; 21 | fi 22 | 23 | if [ "`$NGX_PERL -MExtUtils::Embed -e 'print "OK"'`" != "OK" ]; then 24 | echo 25 | echo "$0: error: perl module ExtUtils::Embed is required" 26 | echo 27 | 28 | exit 1; 29 | fi 30 | 31 | NGX_PERL_CFLAGS="$CFLAGS `$NGX_PERL -MExtUtils::Embed -e ccopts`" 32 | NGX_PM_CFLAGS=`$NGX_PERL -MExtUtils::Embed -e ccopts` 33 | 34 | # gcc 4.1/4.2 warn about unused values in pTHX_ 35 | NGX_PERL_CFLAGS=`echo $NGX_PERL_CFLAGS \ 36 | | sed -e 's/-Wunused-value/-Wno-unused-value/'` 37 | # icc8 warns 'declaration hides parameter "my_perl"' in ENTER and LEAVE 38 | NGX_PERL_CFLAGS=`echo $NGX_PERL_CFLAGS \ 39 | | sed -e 's/-wd171/-wd171 -wd1599/'` 40 | 41 | ngx_perl_ldopts=`$NGX_PERL -MExtUtils::Embed -e ldopts` 42 | 43 | ngx_perl_dlext=`$NGX_PERL -MConfig -e 'print $Config{dlext}'` 44 | 45 | if $NGX_PERL -V:usemultiplicity | grep define > /dev/null; then 46 | have=NGX_HAVE_PERL_MULTIPLICITY . auto/have 47 | echo " + perl interpreter multiplicity found" 48 | fi 49 | 50 | if $NGX_PERL -V:useithreads | grep undef > /dev/null; then 51 | # FreeBSD port wants to link with -pthread non-threaded perl 52 | ngx_perl_ldopts=`echo $ngx_perl_ldopts | sed 's/ -pthread//'` 53 | fi 54 | 55 | CORE_LINK="$CORE_LINK $ngx_perl_ldopts" 56 | LINK_DEPS="$LINK_DEPS $NGX_OBJS/src/http/modules/perl/blib/arch/auto/nginx/nginx.$ngx_perl_dlext" 57 | 58 | if test -n "$NGX_PERL_MODULES"; then 59 | have=NGX_PERL_MODULES value="(u_char *) \"$NGX_PERL_MODULES\"" 60 | . auto/define 61 | NGX_PERL_MODULES_MAN=$NGX_PERL_MODULES/man3 62 | fi 63 | 64 | else 65 | echo 66 | echo "$0: error: perl 5.6.1 or higher is required" 67 | echo 68 | 69 | exit 1; 70 | fi 71 | -------------------------------------------------------------------------------- /auto/lib/perl/make: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | v=`grep 'define NGINX_VERSION' src/core/nginx.h | sed -e 's/^.*"\(.*\)".*/\1/'` 7 | 8 | 9 | cat << END >> $NGX_MAKEFILE 10 | 11 | $NGX_OBJS/src/http/modules/perl/blib/arch/auto/nginx/nginx.$ngx_perl_dlext: \\ 12 | \$(CORE_DEPS) \$(HTTP_DEPS) \\ 13 | src/http/modules/perl/ngx_http_perl_module.h \\ 14 | $NGX_OBJS/src/http/modules/perl/Makefile 15 | cd $NGX_OBJS/src/http/modules/perl && \$(MAKE) 16 | 17 | rm -rf $NGX_OBJS/install_perl 18 | 19 | 20 | $NGX_OBJS/src/http/modules/perl/Makefile: \\ 21 | $NGX_AUTO_CONFIG_H \\ 22 | src/core/nginx.h \\ 23 | src/http/modules/perl/Makefile.PL \\ 24 | src/http/modules/perl/nginx.pm \\ 25 | src/http/modules/perl/nginx.xs \\ 26 | src/http/modules/perl/typemap 27 | sed "s/%%VERSION%%/$v/" src/http/modules/perl/nginx.pm > \\ 28 | $NGX_OBJS/src/http/modules/perl/nginx.pm 29 | cp -p src/http/modules/perl/nginx.xs $NGX_OBJS/src/http/modules/perl/ 30 | cp -p src/http/modules/perl/typemap $NGX_OBJS/src/http/modules/perl/ 31 | cp -p src/http/modules/perl/Makefile.PL $NGX_OBJS/src/http/modules/perl/ 32 | 33 | cd $NGX_OBJS/src/http/modules/perl \\ 34 | && NGX_PM_CFLAGS="\$(NGX_PM_CFLAGS) -g $NGX_CC_OPT" \\ 35 | NGX_INCS="$CORE_INCS $NGX_OBJS $HTTP_INCS" \\ 36 | NGX_DEPS="\$(CORE_DEPS) \$(HTTP_DEPS)" \\ 37 | $NGX_PERL Makefile.PL \\ 38 | LIB=$NGX_PERL_MODULES \\ 39 | INSTALLSITEMAN3DIR=$NGX_PERL_MODULES_MAN 40 | 41 | END 42 | -------------------------------------------------------------------------------- /auto/lib/sha1/conf: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | if [ $SHA1 != NONE ]; then 7 | 8 | have=NGX_HAVE_SHA1 . auto/have 9 | CORE_INCS="$CORE_INCS $SHA1" 10 | 11 | case "$NGX_CC_NAME" in 12 | 13 | msvc* | owc* | bcc) 14 | LINK_DEPS="$LINK_DEPS $SHA1/sha1.lib" 15 | CORE_LIBS="$CORE_LIBS $SHA1/sha1.lib" 16 | ;; 17 | 18 | icc*) 19 | LINK_DEPS="$LINK_DEPS $SHA1/libsha.a" 20 | 21 | # to allow -ipo optimization we link with the *.o but not library 22 | CORE_LIBS="$CORE_LIBS $SHA1/sha1_dgst.o" 23 | 24 | if [ $SHA1_ASM = YES ]; then 25 | CORE_LIBS="$CORE_LIBS $SHA1/asm/sx86-elf.o" 26 | fi 27 | ;; 28 | 29 | *) 30 | LINK_DEPS="$LINK_DEPS $SHA1/libsha.a" 31 | CORE_LIBS="$CORE_LIBS $SHA1/libsha.a" 32 | #CORE_LIBS="$CORE_LIBS -L $SHA1 -lsha" 33 | ;; 34 | 35 | esac 36 | 37 | else 38 | 39 | if [ "$NGX_PLATFORM" != win32 ]; then 40 | 41 | SHA1=NO 42 | 43 | # FreeBSD 44 | 45 | ngx_feature="sha1 in system md library" 46 | ngx_feature_name=NGX_HAVE_SHA1 47 | ngx_feature_run=no 48 | ngx_feature_incs="#include " 49 | ngx_feature_path= 50 | ngx_feature_libs="-lmd" 51 | ngx_feature_test="SHA_CTX sha1; SHA1_Init(&sha1)" 52 | . auto/feature 53 | 54 | ngx_sha1_lib="system md" 55 | 56 | if [ $ngx_found = no ]; then 57 | 58 | # OpenSSL crypto library 59 | 60 | ngx_feature="sha1 in system OpenSSL crypto library" 61 | ngx_feature_incs="#include " 62 | ngx_feature_libs="-lcrypto" 63 | . auto/feature 64 | 65 | ngx_sha1_lib="system crypto" 66 | 67 | if [ $ngx_found = yes ]; then 68 | have=NGX_HAVE_OPENSSL_SHA1_H . auto/have 69 | fi 70 | fi 71 | 72 | if [ $ngx_found = yes ]; then 73 | CORE_LIBS="$CORE_LIBS $ngx_feature_libs" 74 | SHA1=YES 75 | SHA1_LIB=$ngx_sha1_lib 76 | fi 77 | fi 78 | 79 | fi 80 | -------------------------------------------------------------------------------- /auto/lib/sha1/make: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | case "$NGX_CC_NAME" in 7 | 8 | msvc*) 9 | ngx_makefile=makefile.msvc 10 | ngx_opt="CPU_OPT=\"$CPU_OPT\" LIBC=$LIBC SHA1_ASM=$SHA1_ASM" 11 | ngx_sha1="SHA1=\"$SHA1\"" 12 | ;; 13 | 14 | owc*) 15 | ngx_makefile=makefile.owc 16 | ngx_opt="CPU_OPT=\"$CPU_OPT\"" 17 | ngx_sha1=`echo SHA1=\"$SHA1\" | sed -e "s/\//$ngx_regex_dirsep/g"` 18 | ;; 19 | 20 | bcc) 21 | ngx_makefile=makefile.bcc 22 | ngx_opt="-DCPU_OPT=\"$CPU_OPT\" -DSHA1_ASM=$SHA1_ASM" 23 | ngx_sha1=`echo \-DSHA1=\"$SHA1\" | sed -e "s/\//$ngx_regex_dirsep/g"` 24 | ;; 25 | 26 | esac 27 | 28 | 29 | done=NO 30 | 31 | 32 | case "$NGX_PLATFORM" in 33 | 34 | win32) 35 | cat << END >> $NGX_MAKEFILE 36 | 37 | `echo "$SHA1/sha1.lib: $NGX_MAKEFILE" | sed -e "s/\//$ngx_regex_dirsep/g"` 38 | \$(MAKE) -f auto/lib/sha1/$ngx_makefile $ngx_opt $ngx_sha1 39 | 40 | END 41 | 42 | done=YES 43 | ;; 44 | 45 | SunOS:*:i86pc) 46 | if [ $SHA1_ASM = YES ]; then 47 | 48 | cat << END >> $NGX_MAKEFILE 49 | 50 | $SHA1/libsha.a: $NGX_MAKEFILE 51 | cd $SHA1 \\ 52 | && \$(MAKE) CFLAGS="$SHA1_OPT -DSOL -DSHA1_ASM -DL_ENDIAN" \\ 53 | CC="\$(CC)" CPP="\$(CPP)" \\ 54 | SHA_ASM_OBJ=asm/sx86-sol.o clean libsha.a 55 | 56 | END 57 | 58 | done=YES 59 | fi 60 | ;; 61 | 62 | # FreeBSD: i386 63 | # Linux: i686 64 | 65 | *:i386 | *:i686) 66 | if [ $SHA1_ASM = YES ]; then 67 | 68 | cat << END >> $NGX_MAKEFILE 69 | 70 | $SHA1/libsha.a: $NGX_MAKEFILE 71 | cd $SHA1 \\ 72 | && \$(MAKE) CFLAGS="$SHA1_OPT -DELF -DSHA1_ASM -DL_ENDIAN" \\ 73 | CC="\$(CC)" CPP="\$(CPP)" \\ 74 | SHA_ASM_OBJ=asm/sx86-elf.o clean libsha.a 75 | 76 | END 77 | 78 | done=YES 79 | fi 80 | ;; 81 | 82 | esac 83 | 84 | 85 | if [ $done = NO ]; then 86 | 87 | cat << END >> $NGX_MAKEFILE 88 | 89 | $SHA1/libsha.a: $NGX_MAKEFILE 90 | cd $SHA1 \\ 91 | && \$(MAKE) CFLAGS="$SHA1_OPT" \\ 92 | CC="\$(CC)" SHA_ASM_OBJ= clean libsha.a 93 | 94 | END 95 | 96 | fi 97 | -------------------------------------------------------------------------------- /auto/lib/sha1/makefile.bcc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | CFLAGS = -q -O2 -tWM $(CPU_OPT) -DL_ENDIAN 7 | 8 | !if "$(SHA1_ASM)" == "YES" 9 | 10 | sha1.lib: 11 | cd $(SHA1) 12 | bcc32 -c $(CFLAGS) -DSHA1_ASM sha1dgst.c 13 | tlib sha1.lib +sha1dgst.obj +"asm\s-win32.obj" 14 | 15 | !else 16 | 17 | sha1.lib: 18 | cd $(SHA1) 19 | bcc32 -c $(CFLAGS) sha1dgst.c 20 | tlib sha1.lib +sha1dgst.obj 21 | 22 | !endif 23 | -------------------------------------------------------------------------------- /auto/lib/sha1/makefile.msvc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | CFLAGS = -nologo -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT) -D L_ENDIAN 7 | 8 | !IF "$(SHA1_ASM)" == "YES" 9 | 10 | sha1.lib: 11 | cd $(SHA1) 12 | cl -c $(CFLAGS) -D SHA1_ASM sha1dgst.c 13 | link -lib -out:sha1.lib sha1dgst.obj asm/s-win32.obj 14 | 15 | !ELSE 16 | 17 | sha1.lib: 18 | cd $(SHA1) 19 | cl -c $(CFLAGS) sha1dgst.c 20 | link -lib -out:sha1.lib sha1dgst.obj 21 | 22 | !ENDIF 23 | -------------------------------------------------------------------------------- /auto/lib/sha1/makefile.owc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | CFLAGS = -zq -bt=nt -bm -ot -op -oi -oe -s $(CPU_OPT) 7 | 8 | sha1.lib: 9 | cd $(SHA1) 10 | wcl386 -c $(CFLAGS) -dL_ENDIAN sha1dgst.c 11 | wlib -n sha1.lib sha1dgst.obj 12 | -------------------------------------------------------------------------------- /auto/lib/test: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | echo $ngx_n "checking for $ngx_lib ...$ngx_c" 7 | 8 | cat << END >> $NGX_AUTOCONF_ERR 9 | 10 | ---------------------------------------- 11 | checking for $ngx_lib 12 | 13 | END 14 | 15 | ngx_found=no 16 | 17 | cat << END > $NGX_AUTOTEST.c 18 | 19 | $ngx_lib_incs 20 | 21 | int main() { 22 | $ngx_lib_test; 23 | return 0; 24 | } 25 | 26 | 27 | eval "$CC $cc_test_flags $ngx_lib_cflags \ 28 | -o $NGX_AUTOTEST $NGX_AUTOTEST.c $ngx_libs \ 29 | >> $NGX_ERR 2>&1" 30 | 31 | if [ -x $NGX_AUTOTEST ]; then 32 | echo " found" 33 | 34 | ngx_found=yes 35 | 36 | else 37 | echo " not found" 38 | fi 39 | 40 | rm -rf $NGX_AUTOTEST* 41 | -------------------------------------------------------------------------------- /auto/lib/zlib/conf: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | if [ $ZLIB != NONE ]; then 7 | CORE_INCS="$CORE_INCS $ZLIB" 8 | 9 | case "$NGX_CC_NAME" in 10 | 11 | msvc* | owc* | bcc) 12 | have=NGX_ZLIB . auto/have 13 | LINK_DEPS="$LINK_DEPS $ZLIB/zlib.lib" 14 | CORE_LIBS="$CORE_LIBS $ZLIB/zlib.lib" 15 | ;; 16 | 17 | icc*) 18 | have=NGX_ZLIB . auto/have 19 | LINK_DEPS="$LINK_DEPS $ZLIB/libz.a" 20 | 21 | # to allow -ipo optimization we link with the *.o but not library 22 | CORE_LIBS="$CORE_LIBS $ZLIB/adler32.o" 23 | CORE_LIBS="$CORE_LIBS $ZLIB/crc32.o" 24 | CORE_LIBS="$CORE_LIBS $ZLIB/deflate.o" 25 | CORE_LIBS="$CORE_LIBS $ZLIB/trees.o" 26 | CORE_LIBS="$CORE_LIBS $ZLIB/zutil.o" 27 | CORE_LIBS="$CORE_LIBS $ZLIB/compress.o" 28 | 29 | if [ $ZLIB_ASM != NO ]; then 30 | CORE_LIBS="$CORE_LIBS $ZLIB/match.o" 31 | fi 32 | ;; 33 | 34 | *) 35 | have=NGX_ZLIB . auto/have 36 | LINK_DEPS="$LINK_DEPS $ZLIB/libz.a" 37 | CORE_LIBS="$CORE_LIBS $ZLIB/libz.a" 38 | #CORE_LIBS="$CORE_LIBS -L $ZLIB -lz" 39 | ;; 40 | 41 | esac 42 | 43 | else 44 | 45 | if [ "$NGX_PLATFORM" != win32 ]; then 46 | ZLIB=NO 47 | 48 | # FreeBSD, Solaris, Linux 49 | 50 | ngx_feature="zlib library" 51 | ngx_feature_name="NGX_ZLIB" 52 | ngx_feature_run=no 53 | ngx_feature_incs="#include " 54 | ngx_feature_path= 55 | ngx_feature_libs="-lz" 56 | ngx_feature_test="z_stream z; deflate(&z, Z_NO_FLUSH)" 57 | . auto/feature 58 | 59 | 60 | if [ $ngx_found = yes ]; then 61 | CORE_LIBS="$CORE_LIBS $ngx_feature_libs" 62 | ZLIB=YES 63 | ngx_found=no 64 | fi 65 | fi 66 | 67 | if [ $ZLIB != YES ]; then 68 | cat << END 69 | 70 | $0: error: the HTTP gzip module requires the zlib library. 71 | You can either disable the module by using --without-http_gzip_module 72 | option, or install the zlib library into the system, or build the zlib library 73 | statically from the source with nginx by using --with-zlib= option. 74 | 75 | END 76 | exit 1 77 | fi 78 | 79 | fi 80 | -------------------------------------------------------------------------------- /auto/lib/zlib/makefile.bcc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | CFLAGS = -q -O2 -tWM -w-8004 -w-8012 $(CPU_OPT) 7 | 8 | zlib.lib: 9 | cd $(ZLIB) 10 | 11 | bcc32 -c $(CFLAGS) adler32.c crc32.c deflate.c \ 12 | trees.c zutil.c compress.c \ 13 | inflate.c inffast.c inftrees.c 14 | 15 | tlib zlib.lib +adler32.obj +crc32.obj +deflate.obj \ 16 | +trees.obj +zutil.obj +compress.obj \ 17 | +inflate.obj +inffast.obj +inftrees.obj 18 | -------------------------------------------------------------------------------- /auto/lib/zlib/makefile.msvc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | CFLAGS = -nologo -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT) 7 | 8 | zlib.lib: 9 | cd $(ZLIB) 10 | 11 | cl -c $(CFLAGS) adler32.c crc32.c deflate.c \ 12 | trees.c zutil.c compress.c \ 13 | inflate.c inffast.c inftrees.c 14 | 15 | link -lib -out:zlib.lib adler32.obj crc32.obj deflate.obj \ 16 | trees.obj zutil.obj compress.obj \ 17 | inflate.obj inffast.obj inftrees.obj 18 | -------------------------------------------------------------------------------- /auto/lib/zlib/makefile.owc: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | CFLAGS = -zq -bt=nt -ot -op -oi -oe -s -bm $(CPU_OPT) 7 | 8 | zlib.lib: 9 | cd $(ZLIB) 10 | 11 | wcl386 -c $(CFLAGS) adler32.c crc32.c deflate.c trees.c zutil.c & 12 | compress.c inflate.c inffast.c inftrees.c 13 | wlib -n zlib.lib adler32.obj crc32.obj deflate.obj trees.obj & 14 | zutil.obj compress.obj inflate.obj inffast.obj inftrees.obj 15 | -------------------------------------------------------------------------------- /auto/lib/zlib/patch.zlib.h: -------------------------------------------------------------------------------- 1 | --- zlib.h Thu Jul 9 20:06:56 1998 2 | +++ zlib-1.1.3/zlib.h Tue Mar 22 13:41:04 2005 3 | @@ -709,7 +709,6 @@ 4 | (0 in case of error). 5 | */ 6 | 7 | -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); 8 | /* 9 | Converts, formats, and writes the args to the compressed file under 10 | control of the format string, as in fprintf. gzprintf returns the number of 11 | -------------------------------------------------------------------------------- /auto/nohave: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | cat << END >> $NGX_AUTO_CONFIG_H 7 | 8 | #ifndef $have 9 | #define $have 0 10 | #endif 11 | 12 | END 13 | -------------------------------------------------------------------------------- /auto/os/solaris: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | have=NGX_SOLARIS . auto/have_headers 7 | 8 | CORE_INCS="$UNIX_INCS" 9 | CORE_DEPS="$UNIX_DEPS $SOLARIS_DEPS" 10 | CORE_SRCS="$UNIX_SRCS $SOLARIS_SRCS " 11 | CORE_LIBS="$CORE_LIBS -lsocket -lnsl" 12 | 13 | NGX_RPATH=YES 14 | 15 | # Solaris's make does not support a blank line between target and rules 16 | ngx_spacer= 17 | 18 | CC_AUX_FLAGS="$CC_AUX_FLAGS -D_FILE_OFFSET_BITS=64 -lsocket -lnsl" 19 | 20 | 21 | if [ $ZLIB_ASM != NO ]; then 22 | echo "$0: error: the --with-zlib-asm=CPU option is not supported" 23 | echo "on that platform" 24 | echo 25 | 26 | exit 1 27 | fi 28 | 29 | 30 | ngx_feature="sendfilev()" 31 | ngx_feature_name="NGX_HAVE_SENDFILE" 32 | ngx_feature_run=no 33 | ngx_feature_incs="#include " 34 | ngx_feature_path= 35 | ngx_feature_libs="-lsendfile" 36 | ngx_feature_test="int fd = 1; sendfilevec_t vec[1]; 37 | size_t sent; ssize_t n; 38 | n = sendfilev(fd, vec, 1, &sent); 39 | if (n == -1) return 1" 40 | . auto/feature 41 | 42 | 43 | if [ $ngx_found = yes ]; then 44 | CORE_SRCS="$CORE_SRCS $SOLARIS_SENDFILEV_SRCS" 45 | CORE_LIBS="$CORE_LIBS -lsendfile" 46 | fi 47 | 48 | 49 | ngx_feature="event ports" 50 | ngx_feature_name="NGX_HAVE_EVENTPORT" 51 | ngx_feature_run=no 52 | ngx_feature_incs="#include " 53 | ngx_feature_path= 54 | ngx_feature_libs= 55 | ngx_feature_test="int n = port_create()" 56 | . auto/feature 57 | 58 | if [ $ngx_found = yes ]; then 59 | CORE_SRCS="$CORE_SRCS $EVENTPORT_SRCS" 60 | EVENT_MODULES="$EVENT_MODULES $EVENTPORT_MODULE" 61 | fi 62 | -------------------------------------------------------------------------------- /auto/os/win32: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | have=NGX_WIN32 . auto/have_headers 7 | 8 | CORE_INCS="$WIN32_INCS" 9 | CORE_DEPS="$WIN32_DEPS" 10 | CORE_SRCS="$WIN32_SRCS $IOCP_SRCS" 11 | OS_CONFIG="$WIN32_CONFIG" 12 | NGX_ICONS="$NGX_WIN32_ICONS" 13 | SELECT_SRCS=$WIN32_SELECT_SRCS 14 | 15 | case "$NGX_CC_NAME" in 16 | 17 | gcc) 18 | CORE_LIBS="$CORE_LIBS -ladvapi32 -lws2_32" 19 | ;; 20 | 21 | *) 22 | CORE_LIBS="$CORE_LIBS advapi32.lib ws2_32.lib" 23 | ;; 24 | 25 | esac 26 | 27 | EVENT_MODULES="$EVENT_MODULES $IOCP_MODULE" 28 | EVENT_FOUND=YES 29 | 30 | if [ $EVENT_SELECT = NO ]; then 31 | CORE_SRCS="$CORE_SRCS $SELECT_SRCS" 32 | EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE" 33 | fi 34 | 35 | if [ $NGX_IPV6 = YES ]; then 36 | have=NGX_HAVE_INET6 . auto/have 37 | fi 38 | 39 | have=NGX_HAVE_AIO . auto/have 40 | have=NGX_HAVE_IOCP . auto/have 41 | -------------------------------------------------------------------------------- /auto/stubs: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | have=NGX_SUPPRESS_WARN . auto/have 7 | 8 | have=NGX_SMP . auto/have 9 | -------------------------------------------------------------------------------- /auto/types/sizeof: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | echo $ngx_n "checking for $ngx_type size ...$ngx_c" 7 | 8 | cat << END >> $NGX_AUTOCONF_ERR 9 | 10 | ---------------------------------------- 11 | checking for $ngx_type size 12 | 13 | END 14 | 15 | ngx_size= 16 | 17 | cat << END > $NGX_AUTOTEST.c 18 | 19 | #include 20 | #include 21 | $NGX_INCLUDE_UNISTD_H 22 | #include 23 | #include 24 | #include 25 | $NGX_INCLUDE_INTTYPES_H 26 | $NGX_INCLUDE_AUTO_CONFIG_H 27 | 28 | int main() { 29 | printf("%d", (int) sizeof($ngx_type)); 30 | return 0; 31 | } 32 | 33 | END 34 | 35 | 36 | ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \ 37 | -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs" 38 | 39 | eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1" 40 | 41 | 42 | if [ -x $NGX_AUTOTEST ]; then 43 | ngx_size=`$NGX_AUTOTEST` 44 | echo " $ngx_size bytes" 45 | fi 46 | 47 | 48 | rm -rf $NGX_AUTOTEST* 49 | 50 | 51 | case $ngx_size in 52 | 4) 53 | if [ "$ngx_type"="long" ]; then 54 | ngx_max_value=2147483647L 55 | else 56 | ngx_max_value=2147483647 57 | fi 58 | 59 | ngx_max_len='(sizeof("-2147483648") - 1)' 60 | ;; 61 | 62 | 8) 63 | if [ "$ngx_type"="long long" ]; then 64 | ngx_max_value=9223372036854775807LL 65 | else 66 | ngx_max_value=9223372036854775807L 67 | fi 68 | 69 | ngx_max_len='(sizeof("-9223372036854775808") - 1)' 70 | ;; 71 | 72 | *) 73 | echo 74 | echo "$0: error: can not detect $ngx_type size" 75 | 76 | echo "----------" >> $NGX_AUTOCONF_ERR 77 | cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR 78 | echo "----------" >> $NGX_AUTOCONF_ERR 79 | echo $ngx_test >> $NGX_AUTOCONF_ERR 80 | echo "----------" >> $NGX_AUTOCONF_ERR 81 | 82 | exit 1 83 | esac 84 | 85 | -------------------------------------------------------------------------------- /auto/types/typedef: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | echo $ngx_n "checking for $ngx_type ...$ngx_c" 7 | 8 | cat << END >> $NGX_AUTOCONF_ERR 9 | 10 | ---------------------------------------- 11 | checking for $ngx_type 12 | 13 | END 14 | 15 | ngx_found=no 16 | 17 | for ngx_try in $ngx_type $ngx_types 18 | do 19 | 20 | cat << END > $NGX_AUTOTEST.c 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | $NGX_INCLUDE_INTTYPES_H 29 | 30 | int main() { 31 | $ngx_try i = 0; 32 | return (int) i; 33 | } 34 | 35 | END 36 | 37 | ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \ 38 | -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs" 39 | 40 | eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1" 41 | 42 | if [ -x $NGX_AUTOTEST ]; then 43 | if [ $ngx_try = $ngx_type ]; then 44 | echo " found" 45 | ngx_found=yes 46 | else 47 | echo ", $ngx_try used" 48 | ngx_found=$ngx_try 49 | fi 50 | fi 51 | 52 | rm -rf $NGX_AUTOTEST* 53 | 54 | if [ $ngx_found = no ]; then 55 | echo $ngx_n " $ngx_try not found$ngx_c" 56 | 57 | echo "----------" >> $NGX_AUTOCONF_ERR 58 | cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR 59 | echo "----------" >> $NGX_AUTOCONF_ERR 60 | echo $ngx_test >> $NGX_AUTOCONF_ERR 61 | echo "----------" >> $NGX_AUTOCONF_ERR 62 | 63 | else 64 | break 65 | fi 66 | done 67 | 68 | if [ $ngx_found = no ]; then 69 | echo 70 | echo "$0: error: can not define $ngx_type" 71 | 72 | exit 1 73 | fi 74 | 75 | if [ $ngx_found != yes ]; then 76 | echo "typedef $ngx_found $ngx_type;" >> $NGX_AUTO_CONFIG_H 77 | fi 78 | -------------------------------------------------------------------------------- /auto/types/uintptr_t: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | echo $ngx_n "checking for uintptr_t ...$ngx_c" 7 | echo >> $NGX_AUTOCONF_ERR 8 | echo "checking for uintptr_t" >> $NGX_AUTOCONF_ERR 9 | 10 | found=no 11 | 12 | cat << END > $NGX_AUTOTEST.c 13 | 14 | #include 15 | $NGX_INTTYPES_H 16 | 17 | int main() { 18 | uintptr_t i = 0; 19 | return (int) i; 20 | } 21 | 22 | END 23 | 24 | ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \ 25 | -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT" 26 | 27 | eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1" 28 | 29 | if [ -x $NGX_AUTOTEST ]; then 30 | echo " uintptr_t found" 31 | found=yes 32 | else 33 | echo $ngx_n " uintptr_t not found" $ngx_c 34 | fi 35 | 36 | rm -rf $NGX_AUTOTEST* 37 | 38 | 39 | if [ $found = no ]; then 40 | found="uint`expr 8 \* $ngx_ptr_size`_t" 41 | echo ", $found used" 42 | 43 | echo "typedef $found uintptr_t;" >> $NGX_AUTO_CONFIG_H 44 | echo "typedef $found intptr_t;" | sed -e 's/u//g' >> $NGX_AUTO_CONFIG_H 45 | fi 46 | -------------------------------------------------------------------------------- /auto/types/value: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | 6 | cat << END >> $NGX_AUTO_CONFIG_H 7 | 8 | #ifndef $ngx_param 9 | #define $ngx_param $ngx_value 10 | #endif 11 | 12 | END 13 | -------------------------------------------------------------------------------- /conf/fastcgi.conf: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 3 | fastcgi_param QUERY_STRING $query_string; 4 | fastcgi_param REQUEST_METHOD $request_method; 5 | fastcgi_param CONTENT_TYPE $content_type; 6 | fastcgi_param CONTENT_LENGTH $content_length; 7 | 8 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 9 | fastcgi_param REQUEST_URI $request_uri; 10 | fastcgi_param DOCUMENT_URI $document_uri; 11 | fastcgi_param DOCUMENT_ROOT $document_root; 12 | fastcgi_param SERVER_PROTOCOL $server_protocol; 13 | fastcgi_param HTTPS $https if_not_empty; 14 | 15 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 16 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 17 | 18 | fastcgi_param REMOTE_ADDR $remote_addr; 19 | fastcgi_param REMOTE_PORT $remote_port; 20 | fastcgi_param SERVER_ADDR $server_addr; 21 | fastcgi_param SERVER_PORT $server_port; 22 | fastcgi_param SERVER_NAME $server_name; 23 | 24 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 25 | fastcgi_param REDIRECT_STATUS 200; 26 | -------------------------------------------------------------------------------- /conf/fastcgi_params: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param QUERY_STRING $query_string; 3 | fastcgi_param REQUEST_METHOD $request_method; 4 | fastcgi_param CONTENT_TYPE $content_type; 5 | fastcgi_param CONTENT_LENGTH $content_length; 6 | 7 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 8 | fastcgi_param REQUEST_URI $request_uri; 9 | fastcgi_param DOCUMENT_URI $document_uri; 10 | fastcgi_param DOCUMENT_ROOT $document_root; 11 | fastcgi_param SERVER_PROTOCOL $server_protocol; 12 | fastcgi_param HTTPS $https if_not_empty; 13 | 14 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 15 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 16 | 17 | fastcgi_param REMOTE_ADDR $remote_addr; 18 | fastcgi_param REMOTE_PORT $remote_port; 19 | fastcgi_param SERVER_ADDR $server_addr; 20 | fastcgi_param SERVER_PORT $server_port; 21 | fastcgi_param SERVER_NAME $server_name; 22 | 23 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 24 | fastcgi_param REDIRECT_STATUS 200; 25 | -------------------------------------------------------------------------------- /conf/scgi_params: -------------------------------------------------------------------------------- 1 | 2 | scgi_param REQUEST_METHOD $request_method; 3 | scgi_param REQUEST_URI $request_uri; 4 | scgi_param QUERY_STRING $query_string; 5 | scgi_param CONTENT_TYPE $content_type; 6 | 7 | scgi_param DOCUMENT_URI $document_uri; 8 | scgi_param DOCUMENT_ROOT $document_root; 9 | scgi_param SCGI 1; 10 | scgi_param SERVER_PROTOCOL $server_protocol; 11 | scgi_param HTTPS $https if_not_empty; 12 | 13 | scgi_param REMOTE_ADDR $remote_addr; 14 | scgi_param REMOTE_PORT $remote_port; 15 | scgi_param SERVER_PORT $server_port; 16 | scgi_param SERVER_NAME $server_name; 17 | -------------------------------------------------------------------------------- /conf/uwsgi_params: -------------------------------------------------------------------------------- 1 | 2 | uwsgi_param QUERY_STRING $query_string; 3 | uwsgi_param REQUEST_METHOD $request_method; 4 | uwsgi_param CONTENT_TYPE $content_type; 5 | uwsgi_param CONTENT_LENGTH $content_length; 6 | 7 | uwsgi_param REQUEST_URI $request_uri; 8 | uwsgi_param PATH_INFO $document_uri; 9 | uwsgi_param DOCUMENT_ROOT $document_root; 10 | uwsgi_param SERVER_PROTOCOL $server_protocol; 11 | uwsgi_param HTTPS $https if_not_empty; 12 | 13 | uwsgi_param REMOTE_ADDR $remote_addr; 14 | uwsgi_param REMOTE_PORT $remote_port; 15 | uwsgi_param SERVER_PORT $server_port; 16 | uwsgi_param SERVER_NAME $server_name; 17 | -------------------------------------------------------------------------------- /docs/GNUmakefile: -------------------------------------------------------------------------------- 1 | 2 | VER= $(shell grep 'define NGINX_VERSION' src/core/nginx.h \ 3 | | sed -e 's/^.*"\(.*\)".*/\1/') 4 | NGINX= nginx-$(VER) 5 | TEMP= tmp 6 | XSLS?= xslscript.pl 7 | 8 | 9 | all: changes 10 | 11 | changes: $(TEMP)/$(NGINX)/CHANGES.ru \ 12 | $(TEMP)/$(NGINX)/CHANGES 13 | 14 | 15 | $(TEMP)/$(NGINX)/CHANGES.ru: docs/dtd/changes.dtd \ 16 | docs/xml/nginx/changes.xml \ 17 | docs/xml/change_log_conf.xml \ 18 | docs/xslt/changes.xslt 19 | 20 | mkdir -p $(TEMP)/$(NGINX) 21 | 22 | xmllint --noout --valid docs/xml/nginx/changes.xml 23 | xsltproc --stringparam lang ru \ 24 | -o $@ docs/xslt/changes.xslt docs/xml/nginx/changes.xml 25 | 26 | 27 | $(TEMP)/$(NGINX)/CHANGES: docs/dtd/changes.dtd \ 28 | docs/xml/nginx/changes.xml \ 29 | docs/xml/change_log_conf.xml \ 30 | docs/xslt/changes.xslt 31 | 32 | mkdir -p $(TEMP)/$(NGINX) 33 | 34 | xmllint --noout --valid docs/xml/nginx/changes.xml 35 | xsltproc --stringparam lang en \ 36 | -o $@ docs/xslt/changes.xslt docs/xml/nginx/changes.xml 37 | 38 | 39 | docs/xslt/changes.xslt: docs/xsls/changes.xsls 40 | 41 | $(XSLS) -o $@ $< 42 | -------------------------------------------------------------------------------- /docs/dtd/change_log_conf.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/dtd/changes.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/html/50x.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Error 5 | 12 | 13 | 14 |

An error occurred.

15 |

Sorry, the page you are looking for is currently unavailable.
16 | Please try again later.

17 |

If you are the system administrator of this resource then you should check 18 | the error log for details.

19 |

Faithfully yours, nginx.

20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Welcome to nginx! 5 | 12 | 13 | 14 |

Welcome to nginx!

15 |

If you see this page, the nginx web server is successfully installed and 16 | working. Further configuration is required.

17 | 18 |

For online documentation and support please refer to 19 | nginx.org.
20 | Commercial support is available at 21 | nginx.com.

22 | 23 |

Thank you for using nginx.

24 | 25 | 26 | -------------------------------------------------------------------------------- /docs/text/LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2014 Igor Sysoev 3 | * Copyright (C) 2011-2014 Nginx, Inc. 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 | * SUCH DAMAGE. 26 | */ 27 | -------------------------------------------------------------------------------- /docs/text/README: -------------------------------------------------------------------------------- 1 | 2 | Documentation is available at http://nginx.org 3 | 4 | -------------------------------------------------------------------------------- /docs/xml/change_log_conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 76 7 | 8 | *) 9 | 10 | 11 | 12 | Изменения в 13 | 66 14 | 15 | Исправление 16 | Добавление 17 | Изменение 18 | Безопасность 19 | Изменение 20 | 21 | 22 | 23 | Changes with 24 | 65 25 | 26 | Bugfix 27 | Feature 28 | Change 29 | Security 30 | Workaround 31 | 32 | Jan 33 | Feb 34 | Mar 35 | Apr 36 | May 37 | Jun 38 | Jul 39 | Aug 40 | Sep 41 | Oct 42 | Nov 43 | Dec 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /html/50x.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Error 5 | 12 | 13 | 14 |

An error occurred.

15 |

Sorry, the page you are looking for is currently unavailable.
16 | Please try again later.

17 |

If you are the system administrator of this resource then you should check 18 | the error log for details.

19 |

Faithfully yours, nginx.

20 | 21 | 22 | -------------------------------------------------------------------------------- /html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Welcome to nginx! 5 | 12 | 13 | 14 |

Welcome to nginx!

15 |

If you see this page, the nginx web server is successfully installed and 16 | working. Further configuration is required.

17 | 18 |

For online documentation and support please refer to 19 | nginx.org.
20 | Commercial support is available at 21 | nginx.com.

22 | 23 |

Thank you for using nginx.

24 | 25 | 26 | -------------------------------------------------------------------------------- /misc/README: -------------------------------------------------------------------------------- 1 | 2 | make -f misc/GNUmakefile release 3 | 4 | the required tools: 5 | *) xsltproc to build CHANGES, 6 | *) java and XSLScript ( http://pault.com/pault/XSLScript/ ) to build XSLTs 7 | from XSLScript sources. 8 | 9 | 10 | make -f misc/GNUmakefile icons 11 | 12 | the required tool: 13 | *) netpbm to create Win32 icons from xpm sources. 14 | -------------------------------------------------------------------------------- /nginx.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nginx-1.9.9", "win\nginx-1.9.9.vcxproj", "{DF33B527-DE8B-401A-8EE4-0C9C12D4F9A0}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {DF33B527-DE8B-401A-8EE4-0C9C12D4F9A0}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {DF33B527-DE8B-401A-8EE4-0C9C12D4F9A0}.Debug|Win32.Build.0 = Debug|Win32 14 | {DF33B527-DE8B-401A-8EE4-0C9C12D4F9A0}.Release|Win32.ActiveCfg = Release|Win32 15 | {DF33B527-DE8B-401A-8EE4-0C9C12D4F9A0}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /objs/autoconf.err: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /objs/ngx_auto_headers.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef NGX_WIN32 4 | #define NGX_WIN32 1 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /objs/ngx_pch.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /src/core/nginx.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGINX_H_INCLUDED_ 9 | #define _NGINX_H_INCLUDED_ 10 | 11 | 12 | #define nginx_version 1006000 13 | #define NGINX_VERSION "1.6.0" 14 | #define NGINX_VER "nginx/" NGINX_VERSION 15 | 16 | #define NGINX_VAR "NGINX" 17 | #define NGX_OLDPID_EXT ".oldbin" 18 | 19 | 20 | #endif /* _NGINX_H_INCLUDED_ */ 21 | -------------------------------------------------------------------------------- /src/core/ngx_array.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_ARRAY_H_INCLUDED_ 9 | #define _NGX_ARRAY_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | typedef struct { 17 | void *elts; 18 | ngx_uint_t nelts; 19 | size_t size; 20 | ngx_uint_t nalloc; 21 | ngx_pool_t *pool; 22 | } ngx_array_t; 23 | 24 | 25 | ngx_array_t *ngx_array_create(ngx_pool_t *p, ngx_uint_t n, size_t size); 26 | void ngx_array_destroy(ngx_array_t *a); 27 | void *ngx_array_push(ngx_array_t *a); 28 | void *ngx_array_push_n(ngx_array_t *a, ngx_uint_t n); 29 | 30 | 31 | static ngx_inline ngx_int_t 32 | ngx_array_init(ngx_array_t *array, ngx_pool_t *pool, ngx_uint_t n, size_t size) 33 | { 34 | /* 35 | * set "array->nelts" before "array->elts", otherwise MSVC thinks 36 | * that "array->nelts" may be used without having been initialized 37 | */ 38 | 39 | array->nelts = 0; 40 | array->size = size; 41 | array->nalloc = n; 42 | array->pool = pool; 43 | 44 | array->elts = ngx_palloc(pool, n * size); 45 | if (array->elts == NULL) { 46 | return NGX_ERROR; 47 | } 48 | 49 | return NGX_OK; 50 | } 51 | 52 | 53 | #endif /* _NGX_ARRAY_H_INCLUDED_ */ 54 | -------------------------------------------------------------------------------- /src/core/ngx_crc.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_CRC_H_INCLUDED_ 9 | #define _NGX_CRC_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | /* 32-bit crc16 */ 17 | 18 | static ngx_inline uint32_t 19 | ngx_crc(u_char *data, size_t len) 20 | { 21 | uint32_t sum; 22 | 23 | for (sum = 0; len; len--) { 24 | 25 | /* 26 | * gcc 2.95.2 x86 and icc 7.1.006 compile 27 | * that operator into the single "rol" opcode, 28 | * msvc 6.0sp2 compiles it into four opcodes. 29 | */ 30 | sum = sum >> 1 | sum << 31; 31 | 32 | sum += *data++; 33 | } 34 | 35 | return sum; 36 | } 37 | 38 | 39 | #endif /* _NGX_CRC_H_INCLUDED_ */ 40 | -------------------------------------------------------------------------------- /src/core/ngx_crc32.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_CRC32_H_INCLUDED_ 9 | #define _NGX_CRC32_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | extern uint32_t *ngx_crc32_table_short; 17 | extern uint32_t ngx_crc32_table256[]; 18 | 19 | 20 | static ngx_inline uint32_t 21 | ngx_crc32_short(u_char *p, size_t len) 22 | { 23 | u_char c; 24 | uint32_t crc; 25 | 26 | crc = 0xffffffff; 27 | 28 | while (len--) { 29 | c = *p++; 30 | crc = ngx_crc32_table_short[(crc ^ (c & 0xf)) & 0xf] ^ (crc >> 4); 31 | crc = ngx_crc32_table_short[(crc ^ (c >> 4)) & 0xf] ^ (crc >> 4); 32 | } 33 | 34 | return crc ^ 0xffffffff; 35 | } 36 | 37 | 38 | static ngx_inline uint32_t 39 | ngx_crc32_long(u_char *p, size_t len) 40 | { 41 | uint32_t crc; 42 | 43 | crc = 0xffffffff; 44 | 45 | while (len--) { 46 | crc = ngx_crc32_table256[(crc ^ *p++) & 0xff] ^ (crc >> 8); 47 | } 48 | 49 | return crc ^ 0xffffffff; 50 | } 51 | 52 | 53 | #define ngx_crc32_init(crc) \ 54 | crc = 0xffffffff 55 | 56 | 57 | static ngx_inline void 58 | ngx_crc32_update(uint32_t *crc, u_char *p, size_t len) 59 | { 60 | uint32_t c; 61 | 62 | c = *crc; 63 | 64 | while (len--) { 65 | c = ngx_crc32_table256[(c ^ *p++) & 0xff] ^ (c >> 8); 66 | } 67 | 68 | *crc = c; 69 | } 70 | 71 | 72 | #define ngx_crc32_final(crc) \ 73 | crc ^= 0xffffffff 74 | 75 | 76 | ngx_int_t ngx_crc32_table_init(void); 77 | 78 | 79 | #endif /* _NGX_CRC32_H_INCLUDED_ */ 80 | -------------------------------------------------------------------------------- /src/core/ngx_crypt.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_CRYPT_H_INCLUDED_ 9 | #define _NGX_CRYPT_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | ngx_int_t ngx_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, 17 | u_char **encrypted); 18 | 19 | 20 | #endif /* _NGX_CRYPT_H_INCLUDED_ */ 21 | -------------------------------------------------------------------------------- /src/core/ngx_list.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | ngx_list_t * 13 | ngx_list_create(ngx_pool_t *pool, ngx_uint_t n, size_t size) 14 | { 15 | ngx_list_t *list; 16 | 17 | list = ngx_palloc(pool, sizeof(ngx_list_t)); 18 | if (list == NULL) { 19 | return NULL; 20 | } 21 | 22 | if (ngx_list_init(list, pool, n, size) != NGX_OK) { 23 | return NULL; 24 | } 25 | 26 | return list; 27 | } 28 | 29 | 30 | void * 31 | ngx_list_push(ngx_list_t *l) 32 | { 33 | void *elt; 34 | ngx_list_part_t *last; 35 | 36 | last = l->last; 37 | 38 | if (last->nelts == l->nalloc) { 39 | 40 | /* the last part is full, allocate a new list part */ 41 | 42 | last = ngx_palloc(l->pool, sizeof(ngx_list_part_t)); 43 | if (last == NULL) { 44 | return NULL; 45 | } 46 | 47 | last->elts = ngx_palloc(l->pool, l->nalloc * l->size); 48 | if (last->elts == NULL) { 49 | return NULL; 50 | } 51 | 52 | last->nelts = 0; 53 | last->next = NULL; 54 | 55 | l->last->next = last; 56 | l->last = last; 57 | } 58 | 59 | elt = (char *) last->elts + l->size * last->nelts; 60 | last->nelts++; 61 | 62 | return elt; 63 | } 64 | -------------------------------------------------------------------------------- /src/core/ngx_list.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_LIST_H_INCLUDED_ 9 | #define _NGX_LIST_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | typedef struct ngx_list_part_s ngx_list_part_t; 17 | 18 | struct ngx_list_part_s { 19 | void *elts; 20 | ngx_uint_t nelts; 21 | ngx_list_part_t *next; 22 | }; 23 | 24 | 25 | typedef struct { 26 | ngx_list_part_t *last; 27 | ngx_list_part_t part; 28 | size_t size; 29 | ngx_uint_t nalloc; 30 | ngx_pool_t *pool; 31 | } ngx_list_t; 32 | 33 | 34 | ngx_list_t *ngx_list_create(ngx_pool_t *pool, ngx_uint_t n, size_t size); 35 | 36 | static ngx_inline ngx_int_t 37 | ngx_list_init(ngx_list_t *list, ngx_pool_t *pool, ngx_uint_t n, size_t size) 38 | { 39 | list->part.elts = ngx_palloc(pool, n * size); 40 | if (list->part.elts == NULL) { 41 | return NGX_ERROR; 42 | } 43 | 44 | list->part.nelts = 0; 45 | list->part.next = NULL; 46 | list->last = &list->part; 47 | list->size = size; 48 | list->nalloc = n; 49 | list->pool = pool; 50 | 51 | return NGX_OK; 52 | } 53 | 54 | 55 | /* 56 | * 57 | * the iteration through the list: 58 | * 59 | * part = &list.part; 60 | * data = part->elts; 61 | * 62 | * for (i = 0 ;; i++) { 63 | * 64 | * if (i >= part->nelts) { 65 | * if (part->next == NULL) { 66 | * break; 67 | * } 68 | * 69 | * part = part->next; 70 | * data = part->elts; 71 | * i = 0; 72 | * } 73 | * 74 | * ... data[i] ... 75 | * 76 | * } 77 | */ 78 | 79 | 80 | void *ngx_list_push(ngx_list_t *list); 81 | 82 | 83 | #endif /* _NGX_LIST_H_INCLUDED_ */ 84 | -------------------------------------------------------------------------------- /src/core/ngx_md5.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_MD5_H_INCLUDED_ 9 | #define _NGX_MD5_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | #if (NGX_HAVE_MD5) 17 | 18 | #if (NGX_HAVE_OPENSSL_MD5_H) 19 | #include 20 | #else 21 | #include 22 | #endif 23 | 24 | 25 | typedef MD5_CTX ngx_md5_t; 26 | 27 | 28 | #if (NGX_OPENSSL_MD5) 29 | 30 | #define ngx_md5_init MD5_Init 31 | #define ngx_md5_update MD5_Update 32 | #define ngx_md5_final MD5_Final 33 | 34 | #else 35 | 36 | #define ngx_md5_init MD5Init 37 | #define ngx_md5_update MD5Update 38 | #define ngx_md5_final MD5Final 39 | 40 | #endif 41 | 42 | 43 | #else /* !NGX_HAVE_MD5 */ 44 | 45 | 46 | typedef struct { 47 | uint64_t bytes; 48 | uint32_t a, b, c, d; 49 | u_char buffer[64]; 50 | } ngx_md5_t; 51 | 52 | 53 | void ngx_md5_init(ngx_md5_t *ctx); 54 | void ngx_md5_update(ngx_md5_t *ctx, const void *data, size_t size); 55 | void ngx_md5_final(u_char result[16], ngx_md5_t *ctx); 56 | 57 | 58 | #endif 59 | 60 | #endif /* _NGX_MD5_H_INCLUDED_ */ 61 | -------------------------------------------------------------------------------- /src/core/ngx_murmurhash.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Austin Appleby 4 | */ 5 | 6 | 7 | #include 8 | #include 9 | 10 | 11 | uint32_t 12 | ngx_murmur_hash2(u_char *data, size_t len) 13 | { 14 | uint32_t h, k; 15 | 16 | h = 0 ^ len; 17 | 18 | while (len >= 4) { 19 | k = data[0]; 20 | k |= data[1] << 8; 21 | k |= data[2] << 16; 22 | k |= data[3] << 24; 23 | 24 | k *= 0x5bd1e995; 25 | k ^= k >> 24; 26 | k *= 0x5bd1e995; 27 | 28 | h *= 0x5bd1e995; 29 | h ^= k; 30 | 31 | data += 4; 32 | len -= 4; 33 | } 34 | 35 | switch (len) { 36 | case 3: 37 | h ^= data[2] << 16; 38 | case 2: 39 | h ^= data[1] << 8; 40 | case 1: 41 | h ^= data[0]; 42 | h *= 0x5bd1e995; 43 | } 44 | 45 | h ^= h >> 13; 46 | h *= 0x5bd1e995; 47 | h ^= h >> 15; 48 | 49 | return h; 50 | } 51 | -------------------------------------------------------------------------------- /src/core/ngx_murmurhash.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_MURMURHASH_H_INCLUDED_ 9 | #define _NGX_MURMURHASH_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | uint32_t ngx_murmur_hash2(u_char *data, size_t len); 17 | 18 | 19 | #endif /* _NGX_MURMURHASH_H_INCLUDED_ */ 20 | -------------------------------------------------------------------------------- /src/core/ngx_parse.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_PARSE_H_INCLUDED_ 9 | #define _NGX_PARSE_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | ssize_t ngx_parse_size(ngx_str_t *line); 17 | off_t ngx_parse_offset(ngx_str_t *line); 18 | ngx_int_t ngx_parse_time(ngx_str_t *line, ngx_uint_t is_sec); 19 | 20 | 21 | #endif /* _NGX_PARSE_H_INCLUDED_ */ 22 | -------------------------------------------------------------------------------- /src/core/ngx_proxy_protocol.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Roman Arutyunyan 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | u_char * 13 | ngx_proxy_protocol_parse(ngx_connection_t *c, u_char *buf, u_char *last) 14 | { 15 | size_t len; 16 | u_char ch, *p, *addr; 17 | 18 | p = buf; 19 | len = last - buf; 20 | 21 | if (len < 8 || ngx_strncmp(p, "PROXY ", 6) != 0) { 22 | goto invalid; 23 | } 24 | 25 | p += 6; 26 | len -= 6; 27 | 28 | if (len >= 7 && ngx_strncmp(p, "UNKNOWN", 7) == 0) { 29 | ngx_log_debug0(NGX_LOG_DEBUG_CORE, c->log, 0, 30 | "PROXY protocol unknown protocol"); 31 | p += 7; 32 | goto skip; 33 | } 34 | 35 | if (len < 5 || ngx_strncmp(p, "TCP", 3) != 0 36 | || (p[3] != '4' && p[3] != '6') || p[4] != ' ') 37 | { 38 | goto invalid; 39 | } 40 | 41 | p += 5; 42 | addr = p; 43 | 44 | for ( ;; ) { 45 | if (p == last) { 46 | goto invalid; 47 | } 48 | 49 | ch = *p++; 50 | 51 | if (ch == ' ') { 52 | break; 53 | } 54 | 55 | if (ch != ':' && ch != '.' 56 | && (ch < 'a' || ch > 'f') 57 | && (ch < 'A' || ch > 'F') 58 | && (ch < '0' || ch > '9')) 59 | { 60 | goto invalid; 61 | } 62 | } 63 | 64 | len = p - addr - 1; 65 | c->proxy_protocol_addr.data = ngx_pnalloc(c->pool, len); 66 | 67 | if (c->proxy_protocol_addr.data == NULL) { 68 | return NULL; 69 | } 70 | 71 | ngx_memcpy(c->proxy_protocol_addr.data, addr, len); 72 | c->proxy_protocol_addr.len = len; 73 | 74 | ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0, 75 | "PROXY protocol address: \"%V\"", &c->proxy_protocol_addr); 76 | 77 | skip: 78 | 79 | for ( /* void */ ; p < last - 1; p++) { 80 | if (p[0] == CR && p[1] == LF) { 81 | return p + 2; 82 | } 83 | } 84 | 85 | invalid: 86 | 87 | ngx_log_error(NGX_LOG_ERR, c->log, 0, 88 | "broken header: \"%*s\"", (size_t) (last - buf), buf); 89 | 90 | return NULL; 91 | } 92 | -------------------------------------------------------------------------------- /src/core/ngx_proxy_protocol.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Roman Arutyunyan 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_PROXY_PROTOCOL_H_INCLUDED_ 9 | #define _NGX_PROXY_PROTOCOL_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | #define NGX_PROXY_PROTOCOL_MAX_HEADER 107 17 | 18 | 19 | u_char *ngx_proxy_protocol_parse(ngx_connection_t *c, u_char *buf, 20 | u_char *last); 21 | 22 | 23 | #endif /* _NGX_PROXY_PROTOCOL_H_INCLUDED_ */ 24 | -------------------------------------------------------------------------------- /src/core/ngx_queue.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | /* 13 | * find the middle queue element if the queue has odd number of elements 14 | * or the first element of the queue's second part otherwise 15 | */ 16 | 17 | ngx_queue_t * 18 | ngx_queue_middle(ngx_queue_t *queue) 19 | { 20 | ngx_queue_t *middle, *next; 21 | 22 | middle = ngx_queue_head(queue); 23 | 24 | if (middle == ngx_queue_last(queue)) { 25 | return middle; 26 | } 27 | 28 | next = ngx_queue_head(queue); 29 | 30 | for ( ;; ) { 31 | middle = ngx_queue_next(middle); 32 | 33 | next = ngx_queue_next(next); 34 | 35 | if (next == ngx_queue_last(queue)) { 36 | return middle; 37 | } 38 | 39 | next = ngx_queue_next(next); 40 | 41 | if (next == ngx_queue_last(queue)) { 42 | return middle; 43 | } 44 | } 45 | } 46 | 47 | 48 | /* the stable insertion sort */ 49 | 50 | void 51 | ngx_queue_sort(ngx_queue_t *queue, 52 | ngx_int_t (*cmp)(const ngx_queue_t *, const ngx_queue_t *)) 53 | { 54 | ngx_queue_t *q, *prev, *next; 55 | 56 | q = ngx_queue_head(queue); 57 | 58 | if (q == ngx_queue_last(queue)) { 59 | return; 60 | } 61 | 62 | for (q = ngx_queue_next(q); q != ngx_queue_sentinel(queue); q = next) { 63 | 64 | prev = ngx_queue_prev(q); 65 | next = ngx_queue_next(q); 66 | 67 | ngx_queue_remove(q); 68 | 69 | do { 70 | if (cmp(prev, q) <= 0) { 71 | break; 72 | } 73 | 74 | prev = ngx_queue_prev(prev); 75 | 76 | } while (prev != ngx_queue_sentinel(queue)); 77 | 78 | ngx_queue_insert_after(prev, q); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/core/ngx_radix_tree.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_RADIX_TREE_H_INCLUDED_ 9 | #define _NGX_RADIX_TREE_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | #define NGX_RADIX_NO_VALUE (uintptr_t) -1 17 | 18 | typedef struct ngx_radix_node_s ngx_radix_node_t; 19 | 20 | struct ngx_radix_node_s { 21 | ngx_radix_node_t *right; 22 | ngx_radix_node_t *left; 23 | ngx_radix_node_t *parent; 24 | uintptr_t value; 25 | }; 26 | 27 | 28 | typedef struct { 29 | ngx_radix_node_t *root; 30 | ngx_pool_t *pool; 31 | ngx_radix_node_t *free; 32 | char *start; 33 | size_t size; 34 | } ngx_radix_tree_t; 35 | 36 | 37 | ngx_radix_tree_t *ngx_radix_tree_create(ngx_pool_t *pool, 38 | ngx_int_t preallocate); 39 | 40 | ngx_int_t ngx_radix32tree_insert(ngx_radix_tree_t *tree, 41 | uint32_t key, uint32_t mask, uintptr_t value); 42 | ngx_int_t ngx_radix32tree_delete(ngx_radix_tree_t *tree, 43 | uint32_t key, uint32_t mask); 44 | uintptr_t ngx_radix32tree_find(ngx_radix_tree_t *tree, uint32_t key); 45 | 46 | #if (NGX_HAVE_INET6) 47 | ngx_int_t ngx_radix128tree_insert(ngx_radix_tree_t *tree, 48 | u_char *key, u_char *mask, uintptr_t value); 49 | ngx_int_t ngx_radix128tree_delete(ngx_radix_tree_t *tree, 50 | u_char *key, u_char *mask); 51 | uintptr_t ngx_radix128tree_find(ngx_radix_tree_t *tree, u_char *key); 52 | #endif 53 | 54 | 55 | #endif /* _NGX_RADIX_TREE_H_INCLUDED_ */ 56 | -------------------------------------------------------------------------------- /src/core/ngx_regex.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_REGEX_H_INCLUDED_ 9 | #define _NGX_REGEX_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | #define NGX_REGEX_NO_MATCHED PCRE_ERROR_NOMATCH /* -1 */ 19 | 20 | #define NGX_REGEX_CASELESS PCRE_CASELESS 21 | 22 | 23 | typedef struct { 24 | pcre *code; 25 | pcre_extra *extra; 26 | } ngx_regex_t; 27 | 28 | 29 | typedef struct { 30 | ngx_str_t pattern; 31 | ngx_pool_t *pool; 32 | ngx_int_t options; 33 | 34 | ngx_regex_t *regex; 35 | int captures; 36 | int named_captures; 37 | int name_size; 38 | u_char *names; 39 | ngx_str_t err; 40 | } ngx_regex_compile_t; 41 | 42 | 43 | typedef struct { 44 | ngx_regex_t *regex; 45 | u_char *name; 46 | } ngx_regex_elt_t; 47 | 48 | 49 | void ngx_regex_init(void); 50 | ngx_int_t ngx_regex_compile(ngx_regex_compile_t *rc); 51 | 52 | #define ngx_regex_exec(re, s, captures, size) \ 53 | pcre_exec(re->code, re->extra, (const char *) (s)->data, (s)->len, 0, 0, \ 54 | captures, size) 55 | #define ngx_regex_exec_n "pcre_exec()" 56 | 57 | ngx_int_t ngx_regex_exec_array(ngx_array_t *a, ngx_str_t *s, ngx_log_t *log); 58 | 59 | 60 | #endif /* _NGX_REGEX_H_INCLUDED_ */ 61 | -------------------------------------------------------------------------------- /src/core/ngx_sha1.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_SHA1_H_INCLUDED_ 9 | #define _NGX_SHA1_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | #if (NGX_HAVE_OPENSSL_SHA1_H) 17 | #include 18 | #else 19 | #include 20 | #endif 21 | 22 | 23 | typedef SHA_CTX ngx_sha1_t; 24 | 25 | 26 | #define ngx_sha1_init SHA1_Init 27 | #define ngx_sha1_update SHA1_Update 28 | #define ngx_sha1_final SHA1_Final 29 | 30 | 31 | #endif /* _NGX_SHA1_H_INCLUDED_ */ 32 | -------------------------------------------------------------------------------- /src/core/ngx_shmtx.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_SHMTX_H_INCLUDED_ 9 | #define _NGX_SHMTX_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | typedef struct { 17 | ngx_atomic_t lock; 18 | #if (NGX_HAVE_POSIX_SEM) 19 | ngx_atomic_t wait; 20 | #endif 21 | } ngx_shmtx_sh_t; 22 | 23 | 24 | typedef struct { 25 | #if (NGX_HAVE_ATOMIC_OPS) 26 | ngx_atomic_t *lock; 27 | #if (NGX_HAVE_POSIX_SEM) 28 | ngx_atomic_t *wait; 29 | ngx_uint_t semaphore; 30 | sem_t sem; 31 | #endif 32 | #else 33 | ngx_fd_t fd; 34 | u_char *name; 35 | #endif 36 | ngx_uint_t spin; 37 | } ngx_shmtx_t; 38 | 39 | 40 | ngx_int_t ngx_shmtx_create(ngx_shmtx_t *mtx, ngx_shmtx_sh_t *addr, 41 | u_char *name); 42 | void ngx_shmtx_destroy(ngx_shmtx_t *mtx); 43 | ngx_uint_t ngx_shmtx_trylock(ngx_shmtx_t *mtx); 44 | void ngx_shmtx_lock(ngx_shmtx_t *mtx); 45 | void ngx_shmtx_unlock(ngx_shmtx_t *mtx); 46 | ngx_uint_t ngx_shmtx_force_unlock(ngx_shmtx_t *mtx, ngx_pid_t pid); 47 | 48 | 49 | #endif /* _NGX_SHMTX_H_INCLUDED_ */ 50 | -------------------------------------------------------------------------------- /src/core/ngx_slab.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_SLAB_H_INCLUDED_ 9 | #define _NGX_SLAB_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | typedef struct ngx_slab_page_s ngx_slab_page_t; 17 | 18 | struct ngx_slab_page_s { 19 | uintptr_t slab; 20 | ngx_slab_page_t *next; 21 | uintptr_t prev; 22 | }; 23 | 24 | 25 | typedef struct { 26 | ngx_shmtx_sh_t lock; 27 | 28 | size_t min_size; 29 | size_t min_shift; 30 | 31 | ngx_slab_page_t *pages; 32 | ngx_slab_page_t free; 33 | 34 | u_char *start; 35 | u_char *end; 36 | 37 | ngx_shmtx_t mutex; 38 | 39 | u_char *log_ctx; 40 | u_char zero; 41 | 42 | unsigned log_nomem:1; 43 | 44 | void *data; 45 | void *addr; 46 | } ngx_slab_pool_t; 47 | 48 | 49 | void ngx_slab_init(ngx_slab_pool_t *pool); 50 | void *ngx_slab_alloc(ngx_slab_pool_t *pool, size_t size); 51 | void *ngx_slab_alloc_locked(ngx_slab_pool_t *pool, size_t size); 52 | void ngx_slab_free(ngx_slab_pool_t *pool, void *p); 53 | void ngx_slab_free_locked(ngx_slab_pool_t *pool, void *p); 54 | 55 | 56 | #endif /* _NGX_SLAB_H_INCLUDED_ */ 57 | -------------------------------------------------------------------------------- /src/core/ngx_spinlock.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | void 13 | ngx_spinlock(ngx_atomic_t *lock, ngx_atomic_int_t value, ngx_uint_t spin) 14 | { 15 | 16 | #if (NGX_HAVE_ATOMIC_OPS) 17 | 18 | ngx_uint_t i, n; 19 | 20 | for ( ;; ) { 21 | 22 | if (*lock == 0 && ngx_atomic_cmp_set(lock, 0, value)) { 23 | return; 24 | } 25 | 26 | if (ngx_ncpu > 1) { 27 | 28 | for (n = 1; n < spin; n <<= 1) { 29 | 30 | for (i = 0; i < n; i++) { 31 | ngx_cpu_pause(); 32 | } 33 | 34 | if (*lock == 0 && ngx_atomic_cmp_set(lock, 0, value)) { 35 | return; 36 | } 37 | } 38 | } 39 | 40 | ngx_sched_yield(); 41 | } 42 | 43 | #else 44 | 45 | #if (NGX_THREADS) 46 | 47 | #error ngx_spinlock() or ngx_atomic_cmp_set() are not defined ! 48 | 49 | #endif 50 | 51 | #endif 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/core/ngx_times.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_TIMES_H_INCLUDED_ 9 | #define _NGX_TIMES_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | typedef struct { 17 | time_t sec; 18 | ngx_uint_t msec; 19 | ngx_int_t gmtoff; 20 | } ngx_time_t; 21 | 22 | 23 | void ngx_time_init(void); 24 | void ngx_time_update(void); 25 | void ngx_time_sigsafe_update(void); 26 | u_char *ngx_http_time(u_char *buf, time_t t); 27 | u_char *ngx_http_cookie_time(u_char *buf, time_t t); 28 | void ngx_gmtime(time_t t, ngx_tm_t *tp); 29 | 30 | time_t ngx_next_time(time_t when); 31 | #define ngx_next_time_n "mktime()" 32 | 33 | 34 | extern volatile ngx_time_t *ngx_cached_time; 35 | 36 | #define ngx_time() ngx_cached_time->sec 37 | #define ngx_timeofday() (ngx_time_t *) ngx_cached_time 38 | 39 | extern volatile ngx_str_t ngx_cached_err_log_time; 40 | extern volatile ngx_str_t ngx_cached_http_time; 41 | extern volatile ngx_str_t ngx_cached_http_log_time; 42 | extern volatile ngx_str_t ngx_cached_http_log_iso8601; 43 | 44 | /* 45 | * milliseconds elapsed since epoch and truncated to ngx_msec_t, 46 | * used in event timers 47 | */ 48 | extern volatile ngx_msec_t ngx_current_msec; 49 | 50 | 51 | #endif /* _NGX_TIMES_H_INCLUDED_ */ 52 | -------------------------------------------------------------------------------- /src/event/modules/ngx_iocp_module.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_IOCP_MODULE_H_INCLUDED_ 9 | #define _NGX_IOCP_MODULE_H_INCLUDED_ 10 | 11 | 12 | typedef struct { 13 | int threads; 14 | int post_acceptex; 15 | int acceptex_read; 16 | } ngx_iocp_conf_t; 17 | 18 | 19 | extern ngx_module_t ngx_iocp_module; 20 | 21 | 22 | #endif /* _NGX_IOCP_MODULE_H_INCLUDED_ */ 23 | -------------------------------------------------------------------------------- /src/event/ngx_event_busy_lock.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_EVENT_BUSY_LOCK_H_INCLUDED_ 9 | #define _NGX_EVENT_BUSY_LOCK_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | typedef struct ngx_event_busy_lock_ctx_s ngx_event_busy_lock_ctx_t; 17 | 18 | struct ngx_event_busy_lock_ctx_s { 19 | ngx_event_t *event; 20 | ngx_event_handler_pt handler; 21 | void *data; 22 | ngx_msec_t timer; 23 | 24 | unsigned locked:1; 25 | unsigned waiting:1; 26 | unsigned cache_updated:1; 27 | 28 | char *md5; 29 | ngx_int_t slot; 30 | 31 | ngx_event_busy_lock_ctx_t *next; 32 | }; 33 | 34 | 35 | typedef struct { 36 | u_char *md5_mask; 37 | char *md5; 38 | ngx_uint_t cacheable; 39 | 40 | ngx_uint_t busy; 41 | ngx_uint_t max_busy; 42 | 43 | ngx_uint_t waiting; 44 | ngx_uint_t max_waiting; 45 | 46 | ngx_event_busy_lock_ctx_t *events; 47 | ngx_event_busy_lock_ctx_t *last; 48 | 49 | #if (NGX_THREADS) 50 | ngx_mutex_t *mutex; 51 | #endif 52 | } ngx_event_busy_lock_t; 53 | 54 | 55 | ngx_int_t ngx_event_busy_lock(ngx_event_busy_lock_t *bl, 56 | ngx_event_busy_lock_ctx_t *ctx); 57 | ngx_int_t ngx_event_busy_lock_cacheable(ngx_event_busy_lock_t *bl, 58 | ngx_event_busy_lock_ctx_t *ctx); 59 | void ngx_event_busy_unlock(ngx_event_busy_lock_t *bl, 60 | ngx_event_busy_lock_ctx_t *ctx); 61 | void ngx_event_busy_lock_cancel(ngx_event_busy_lock_t *bl, 62 | ngx_event_busy_lock_ctx_t *ctx); 63 | 64 | 65 | #endif /* _NGX_EVENT_BUSY_LOCK_H_INCLUDED_ */ 66 | -------------------------------------------------------------------------------- /src/event/ngx_event_connect.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_EVENT_CONNECT_H_INCLUDED_ 9 | #define _NGX_EVENT_CONNECT_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | #define NGX_PEER_KEEPALIVE 1 18 | #define NGX_PEER_NEXT 2 19 | #define NGX_PEER_FAILED 4 20 | 21 | 22 | typedef struct ngx_peer_connection_s ngx_peer_connection_t; 23 | 24 | typedef ngx_int_t (*ngx_event_get_peer_pt)(ngx_peer_connection_t *pc, 25 | void *data); 26 | typedef void (*ngx_event_free_peer_pt)(ngx_peer_connection_t *pc, void *data, 27 | ngx_uint_t state); 28 | #if (NGX_SSL) 29 | 30 | typedef ngx_int_t (*ngx_event_set_peer_session_pt)(ngx_peer_connection_t *pc, 31 | void *data); 32 | typedef void (*ngx_event_save_peer_session_pt)(ngx_peer_connection_t *pc, 33 | void *data); 34 | #endif 35 | 36 | 37 | struct ngx_peer_connection_s { 38 | ngx_connection_t *connection; 39 | 40 | struct sockaddr *sockaddr; 41 | socklen_t socklen; 42 | ngx_str_t *name; 43 | 44 | ngx_uint_t tries; 45 | 46 | ngx_event_get_peer_pt get; 47 | ngx_event_free_peer_pt free; 48 | void *data; 49 | 50 | #if (NGX_SSL) 51 | ngx_event_set_peer_session_pt set_session; 52 | ngx_event_save_peer_session_pt save_session; 53 | #endif 54 | 55 | #if (NGX_THREADS) 56 | ngx_atomic_t *lock; 57 | #endif 58 | 59 | ngx_addr_t *local; 60 | 61 | int rcvbuf; 62 | 63 | ngx_log_t *log; 64 | 65 | unsigned cached:1; 66 | 67 | /* ngx_connection_log_error_e */ 68 | unsigned log_error:2; 69 | }; 70 | 71 | 72 | ngx_int_t ngx_event_connect_peer(ngx_peer_connection_t *pc); 73 | ngx_int_t ngx_event_get_peer(ngx_peer_connection_t *pc, void *data); 74 | 75 | 76 | #endif /* _NGX_EVENT_CONNECT_H_INCLUDED_ */ 77 | -------------------------------------------------------------------------------- /src/event/ngx_event_mutex.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | ngx_int_t ngx_event_mutex_timedlock(ngx_event_mutex_t *m, ngx_msec_t timer, 14 | ngx_event_t *ev) 15 | { 16 | ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, 17 | "lock event mutex %p lock:%XD", m, m->lock); 18 | 19 | if (m->lock) { 20 | 21 | if (m->events == NULL) { 22 | m->events = ev; 23 | 24 | } else { 25 | m->last->next = ev; 26 | } 27 | 28 | m->last = ev; 29 | ev->next = NULL; 30 | 31 | #if (NGX_THREADS0) 32 | ev->light = 1; 33 | #endif 34 | 35 | ngx_add_timer(ev, timer); 36 | 37 | return NGX_AGAIN; 38 | } 39 | 40 | m->lock = 1; 41 | 42 | return NGX_OK; 43 | } 44 | 45 | 46 | ngx_int_t ngx_event_mutex_unlock(ngx_event_mutex_t *m, ngx_log_t *log) 47 | { 48 | ngx_event_t *ev; 49 | 50 | if (m->lock == 0) { 51 | ngx_log_error(NGX_LOG_ALERT, log, 0, 52 | "tring to unlock the free event mutex %p", m); 53 | return NGX_ERROR; 54 | } 55 | 56 | ngx_log_debug2(NGX_LOG_DEBUG_EVENT, log, 0, 57 | "unlock event mutex %p, next event: %p", m, m->events); 58 | 59 | m->lock = 0; 60 | 61 | if (m->events) { 62 | ev = m->events; 63 | m->events = ev->next; 64 | 65 | ev->next = (ngx_event_t *) ngx_posted_events; 66 | ngx_posted_events = ev; 67 | } 68 | 69 | return NGX_OK; 70 | } 71 | -------------------------------------------------------------------------------- /src/http/modules/ngx_http_ssl_module.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_HTTP_SSL_H_INCLUDED_ 9 | #define _NGX_HTTP_SSL_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | typedef struct { 18 | ngx_flag_t enable; 19 | 20 | ngx_ssl_t ssl; 21 | 22 | ngx_flag_t prefer_server_ciphers; 23 | 24 | ngx_uint_t protocols; 25 | 26 | ngx_uint_t verify; 27 | ngx_uint_t verify_depth; 28 | 29 | size_t buffer_size; 30 | 31 | ssize_t builtin_session_cache; 32 | 33 | time_t session_timeout; 34 | 35 | ngx_str_t certificate; 36 | ngx_str_t certificate_key; 37 | ngx_str_t dhparam; 38 | ngx_str_t ecdh_curve; 39 | ngx_str_t client_certificate; 40 | ngx_str_t trusted_certificate; 41 | ngx_str_t crl; 42 | 43 | ngx_str_t ciphers; 44 | 45 | ngx_shm_zone_t *shm_zone; 46 | 47 | ngx_flag_t session_tickets; 48 | ngx_array_t *session_ticket_keys; 49 | 50 | ngx_flag_t stapling; 51 | ngx_flag_t stapling_verify; 52 | ngx_str_t stapling_file; 53 | ngx_str_t stapling_responder; 54 | 55 | u_char *file; 56 | ngx_uint_t line; 57 | } ngx_http_ssl_srv_conf_t; 58 | 59 | 60 | extern ngx_module_t ngx_http_ssl_module; 61 | 62 | 63 | #endif /* _NGX_HTTP_SSL_H_INCLUDED_ */ 64 | -------------------------------------------------------------------------------- /src/http/modules/perl/Makefile.PL: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (C) Igor Sysoev 3 | # Copyright (C) Nginx, Inc. 4 | 5 | use 5.006001; 6 | use ExtUtils::MakeMaker; 7 | 8 | WriteMakefile( 9 | NAME => 'nginx', 10 | VERSION_FROM => 'nginx.pm', # finds $VERSION 11 | PREREQ_PM => {}, # e.g., Module::Name => 1.1 12 | 13 | ABSTRACT_FROM => 'nginx.pm', # retrieve abstract from module 14 | AUTHOR => 'Igor Sysoev', 15 | 16 | CCFLAGS => "$ENV{NGX_PM_CFLAGS}", 17 | OPTIMIZE => '-O', 18 | 19 | INC => join(" ", map { 20 | m#^/# ? "-I $_" : "-I ../../../../../$_" 21 | } (split /\s+/, $ENV{NGX_INCS})), 22 | 23 | depend => { 24 | 'nginx.c' => join(" ", map { 25 | m#^/# ? $_ : "../../../../../$_" 26 | } (split(/\s+/, $ENV{NGX_DEPS}), 27 | "src/http/modules/perl/ngx_http_perl_module.h")) 28 | }, 29 | 30 | PM => { 31 | 'nginx.pm' => '$(INST_LIBDIR)/nginx.pm' 32 | } 33 | ); 34 | -------------------------------------------------------------------------------- /src/http/modules/perl/ngx_http_perl_module.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_HTTP_PERL_MODULE_H_INCLUDED_ 9 | #define _NGX_HTTP_PERL_MODULE_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | 21 | typedef ngx_http_request_t *nginx; 22 | 23 | typedef struct { 24 | ngx_str_t filename; 25 | ngx_str_t redirect_uri; 26 | ngx_str_t redirect_args; 27 | 28 | SV *next; 29 | 30 | ngx_uint_t done; /* unsigned done:1; */ 31 | 32 | ngx_array_t *variables; /* array of ngx_http_perl_var_t */ 33 | 34 | #if (NGX_HTTP_SSI) 35 | ngx_http_ssi_ctx_t *ssi; 36 | #endif 37 | } ngx_http_perl_ctx_t; 38 | 39 | 40 | typedef struct { 41 | ngx_uint_t hash; 42 | ngx_str_t name; 43 | ngx_str_t value; 44 | } ngx_http_perl_var_t; 45 | 46 | 47 | extern ngx_module_t ngx_http_perl_module; 48 | 49 | 50 | /* 51 | * workaround for "unused variable `Perl___notused'" warning 52 | * when building with perl 5.6.1 53 | */ 54 | #ifndef PERL_IMPLICIT_CONTEXT 55 | #undef dTHXa 56 | #define dTHXa(a) 57 | #endif 58 | 59 | 60 | extern void boot_DynaLoader(pTHX_ CV* cv); 61 | 62 | 63 | void ngx_http_perl_handle_request(ngx_http_request_t *r); 64 | void ngx_http_perl_sleep_handler(ngx_http_request_t *r); 65 | 66 | 67 | #endif /* _NGX_HTTP_PERL_MODULE_H_INCLUDED_ */ 68 | -------------------------------------------------------------------------------- /src/http/modules/perl/typemap: -------------------------------------------------------------------------------- 1 | TYPEMAP 2 | 3 | nginx T_PTROBJ 4 | -------------------------------------------------------------------------------- /src/http/ngx_http_busy_lock.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_HTTP_BUSY_LOCK_H_INCLUDED_ 9 | #define _NGX_HTTP_BUSY_LOCK_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | typedef struct { 19 | u_char *md5_mask; 20 | char *md5; 21 | int cacheable; 22 | 23 | int busy; 24 | int max_busy; 25 | 26 | int waiting; 27 | int max_waiting; 28 | 29 | time_t timeout; 30 | 31 | ngx_event_mutex_t *mutex; 32 | } ngx_http_busy_lock_t; 33 | 34 | 35 | typedef struct { 36 | time_t time; 37 | ngx_event_t *event; 38 | void (*event_handler)(ngx_event_t *ev); 39 | u_char *md5; 40 | int slot; 41 | } ngx_http_busy_lock_ctx_t; 42 | 43 | 44 | int ngx_http_busy_lock(ngx_http_busy_lock_t *bl, ngx_http_busy_lock_ctx_t *bc); 45 | int ngx_http_busy_lock_cacheable(ngx_http_busy_lock_t *bl, 46 | ngx_http_busy_lock_ctx_t *bc, int lock); 47 | void ngx_http_busy_unlock(ngx_http_busy_lock_t *bl, 48 | ngx_http_busy_lock_ctx_t *bc); 49 | 50 | char *ngx_http_set_busy_lock_slot(ngx_conf_t *cf, ngx_command_t *cmd, 51 | void *conf); 52 | 53 | 54 | #endif /* _NGX_HTTP_BUSY_LOCK_H_INCLUDED_ */ 55 | -------------------------------------------------------------------------------- /src/http/ngx_http_spdy_module.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Nginx, Inc. 4 | * Copyright (C) Valentin V. Bartenev 5 | */ 6 | 7 | 8 | #ifndef _NGX_HTTP_SPDY_MODULE_H_INCLUDED_ 9 | #define _NGX_HTTP_SPDY_MODULE_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | typedef struct { 18 | size_t recv_buffer_size; 19 | u_char *recv_buffer; 20 | } ngx_http_spdy_main_conf_t; 21 | 22 | 23 | typedef struct { 24 | size_t pool_size; 25 | ngx_uint_t concurrent_streams; 26 | ngx_uint_t streams_index_mask; 27 | ngx_msec_t recv_timeout; 28 | ngx_msec_t keepalive_timeout; 29 | ngx_int_t headers_comp; 30 | } ngx_http_spdy_srv_conf_t; 31 | 32 | 33 | typedef struct { 34 | size_t chunk_size; 35 | } ngx_http_spdy_loc_conf_t; 36 | 37 | 38 | extern ngx_module_t ngx_http_spdy_module; 39 | 40 | 41 | #endif /* _NGX_HTTP_SPDY_MODULE_H_INCLUDED_ */ 42 | -------------------------------------------------------------------------------- /src/mail/ngx_mail_imap_module.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_MAIL_IMAP_MODULE_H_INCLUDED_ 9 | #define _NGX_MAIL_IMAP_MODULE_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | typedef struct { 18 | size_t client_buffer_size; 19 | 20 | ngx_str_t capability; 21 | ngx_str_t starttls_capability; 22 | ngx_str_t starttls_only_capability; 23 | 24 | ngx_uint_t auth_methods; 25 | 26 | ngx_array_t capabilities; 27 | } ngx_mail_imap_srv_conf_t; 28 | 29 | 30 | void ngx_mail_imap_init_session(ngx_mail_session_t *s, ngx_connection_t *c); 31 | void ngx_mail_imap_init_protocol(ngx_event_t *rev); 32 | void ngx_mail_imap_auth_state(ngx_event_t *rev); 33 | ngx_int_t ngx_mail_imap_parse_command(ngx_mail_session_t *s); 34 | 35 | 36 | extern ngx_module_t ngx_mail_imap_module; 37 | 38 | 39 | #endif /* _NGX_MAIL_IMAP_MODULE_H_INCLUDED_ */ 40 | -------------------------------------------------------------------------------- /src/mail/ngx_mail_pop3_module.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_MAIL_POP3_MODULE_H_INCLUDED_ 9 | #define _NGX_MAIL_POP3_MODULE_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | typedef struct { 18 | ngx_str_t capability; 19 | ngx_str_t starttls_capability; 20 | ngx_str_t starttls_only_capability; 21 | ngx_str_t auth_capability; 22 | 23 | ngx_uint_t auth_methods; 24 | 25 | ngx_array_t capabilities; 26 | } ngx_mail_pop3_srv_conf_t; 27 | 28 | 29 | void ngx_mail_pop3_init_session(ngx_mail_session_t *s, ngx_connection_t *c); 30 | void ngx_mail_pop3_init_protocol(ngx_event_t *rev); 31 | void ngx_mail_pop3_auth_state(ngx_event_t *rev); 32 | ngx_int_t ngx_mail_pop3_parse_command(ngx_mail_session_t *s); 33 | 34 | 35 | extern ngx_module_t ngx_mail_pop3_module; 36 | 37 | 38 | #endif /* _NGX_MAIL_POP3_MODULE_H_INCLUDED_ */ 39 | -------------------------------------------------------------------------------- /src/mail/ngx_mail_smtp_module.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_MAIL_SMTP_MODULE_H_INCLUDED_ 9 | #define _NGX_MAIL_SMTP_MODULE_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | typedef struct { 19 | ngx_msec_t greeting_delay; 20 | 21 | size_t client_buffer_size; 22 | 23 | ngx_str_t capability; 24 | ngx_str_t starttls_capability; 25 | ngx_str_t starttls_only_capability; 26 | 27 | ngx_str_t server_name; 28 | ngx_str_t greeting; 29 | 30 | ngx_uint_t auth_methods; 31 | 32 | ngx_array_t capabilities; 33 | } ngx_mail_smtp_srv_conf_t; 34 | 35 | 36 | void ngx_mail_smtp_init_session(ngx_mail_session_t *s, ngx_connection_t *c); 37 | void ngx_mail_smtp_init_protocol(ngx_event_t *rev); 38 | void ngx_mail_smtp_auth_state(ngx_event_t *rev); 39 | ngx_int_t ngx_mail_smtp_parse_command(ngx_mail_session_t *s); 40 | 41 | 42 | extern ngx_module_t ngx_mail_smtp_module; 43 | 44 | 45 | #endif /* _NGX_MAIL_SMTP_MODULE_H_INCLUDED_ */ 46 | -------------------------------------------------------------------------------- /src/mail/ngx_mail_ssl_module.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_MAIL_SSL_H_INCLUDED_ 9 | #define _NGX_MAIL_SSL_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | #define NGX_MAIL_STARTTLS_OFF 0 18 | #define NGX_MAIL_STARTTLS_ON 1 19 | #define NGX_MAIL_STARTTLS_ONLY 2 20 | 21 | 22 | typedef struct { 23 | ngx_flag_t enable; 24 | ngx_flag_t prefer_server_ciphers; 25 | 26 | ngx_ssl_t ssl; 27 | 28 | ngx_uint_t starttls; 29 | ngx_uint_t protocols; 30 | 31 | ssize_t builtin_session_cache; 32 | 33 | time_t session_timeout; 34 | 35 | ngx_str_t certificate; 36 | ngx_str_t certificate_key; 37 | ngx_str_t dhparam; 38 | ngx_str_t ecdh_curve; 39 | 40 | ngx_str_t ciphers; 41 | 42 | ngx_shm_zone_t *shm_zone; 43 | 44 | ngx_flag_t session_tickets; 45 | ngx_array_t *session_ticket_keys; 46 | 47 | u_char *file; 48 | ngx_uint_t line; 49 | } ngx_mail_ssl_conf_t; 50 | 51 | 52 | extern ngx_module_t ngx_mail_ssl_module; 53 | 54 | 55 | #endif /* _NGX_MAIL_SSL_H_INCLUDED_ */ 56 | -------------------------------------------------------------------------------- /src/misc/ngx_cpp_test_module.cpp: -------------------------------------------------------------------------------- 1 | 2 | // stub module to test header files' C++ compatibilty 3 | 4 | extern "C" { 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | } 18 | 19 | // nginx header files should go before other, because they define 64-bit off_t 20 | // #include 21 | 22 | 23 | void ngx_cpp_test_handler(void *data); 24 | 25 | void 26 | ngx_cpp_test_handler(void *data) 27 | { 28 | return; 29 | } 30 | -------------------------------------------------------------------------------- /src/mysql/config: -------------------------------------------------------------------------------- 1 | 2 | ngx_addon_name=ngx_mysql 3 | 4 | HTTP_MODULES="$HTTP_MODULES ngx_http_mysql_test_module" 5 | 6 | HTTP_INCS="$HTTP_INCS $ngx_addon_dir" 7 | HTTP_DEPS="$HTTP_DEPS $ngx_addon_dir/ngx_mysql.h" 8 | #CORE_LIBS="$CORE_LIBS -lmd" 9 | 10 | USE_SHA1=YES 11 | 12 | NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_mysql.c" 13 | NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_mysql_test.c" 14 | -------------------------------------------------------------------------------- /src/os/unix/ngx_aio_read_chain.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | ssize_t 14 | ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl) 15 | { 16 | int n; 17 | u_char *buf, *prev; 18 | size_t size; 19 | ssize_t total; 20 | 21 | if (c->read->pending_eof) { 22 | c->read->ready = 0; 23 | return 0; 24 | } 25 | 26 | total = 0; 27 | 28 | while (cl) { 29 | 30 | /* we can post the single aio operation only */ 31 | 32 | if (!c->read->ready) { 33 | return total ? total : NGX_AGAIN; 34 | } 35 | 36 | buf = cl->buf->last; 37 | prev = cl->buf->last; 38 | size = 0; 39 | 40 | /* coalesce the neighbouring bufs */ 41 | 42 | while (cl && prev == cl->buf->last) { 43 | size += cl->buf->end - cl->buf->last; 44 | prev = cl->buf->end; 45 | cl = cl->next; 46 | } 47 | 48 | n = ngx_aio_read(c, buf, size); 49 | 50 | ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "aio_read: %d", n); 51 | 52 | if (n == NGX_AGAIN) { 53 | return total ? total : NGX_AGAIN; 54 | } 55 | 56 | if (n == NGX_ERROR) { 57 | return NGX_ERROR; 58 | } 59 | 60 | if (n == 0) { 61 | c->read->pending_eof = 1; 62 | if (total) { 63 | c->read->eof = 0; 64 | c->read->ready = 1; 65 | } 66 | return total; 67 | } 68 | 69 | if (n > 0) { 70 | total += n; 71 | } 72 | 73 | ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, 74 | "aio_read total: %d", total); 75 | } 76 | 77 | return total ? total : NGX_AGAIN; 78 | } 79 | -------------------------------------------------------------------------------- /src/os/unix/ngx_alloc.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | ngx_uint_t ngx_pagesize; 13 | ngx_uint_t ngx_pagesize_shift; 14 | ngx_uint_t ngx_cacheline_size; 15 | 16 | 17 | void * 18 | ngx_alloc(size_t size, ngx_log_t *log) 19 | { 20 | void *p; 21 | 22 | p = malloc(size); 23 | if (p == NULL) { 24 | ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, 25 | "malloc(%uz) failed", size); 26 | } 27 | 28 | ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0, "malloc: %p:%uz", p, size); 29 | 30 | return p; 31 | } 32 | 33 | 34 | void * 35 | ngx_calloc(size_t size, ngx_log_t *log) 36 | { 37 | void *p; 38 | 39 | p = ngx_alloc(size, log); 40 | 41 | if (p) { 42 | ngx_memzero(p, size); 43 | } 44 | 45 | return p; 46 | } 47 | 48 | 49 | #if (NGX_HAVE_POSIX_MEMALIGN) 50 | 51 | void * 52 | ngx_memalign(size_t alignment, size_t size, ngx_log_t *log) 53 | { 54 | void *p; 55 | int err; 56 | 57 | err = posix_memalign(&p, alignment, size); 58 | 59 | if (err) { 60 | ngx_log_error(NGX_LOG_EMERG, log, err, 61 | "posix_memalign(%uz, %uz) failed", alignment, size); 62 | p = NULL; 63 | } 64 | 65 | ngx_log_debug3(NGX_LOG_DEBUG_ALLOC, log, 0, 66 | "posix_memalign: %p:%uz @%uz", p, size, alignment); 67 | 68 | return p; 69 | } 70 | 71 | #elif (NGX_HAVE_MEMALIGN) 72 | 73 | void * 74 | ngx_memalign(size_t alignment, size_t size, ngx_log_t *log) 75 | { 76 | void *p; 77 | 78 | p = memalign(alignment, size); 79 | if (p == NULL) { 80 | ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, 81 | "memalign(%uz, %uz) failed", alignment, size); 82 | } 83 | 84 | ngx_log_debug3(NGX_LOG_DEBUG_ALLOC, log, 0, 85 | "memalign: %p:%uz @%uz", p, size, alignment); 86 | 87 | return p; 88 | } 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /src/os/unix/ngx_alloc.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_ALLOC_H_INCLUDED_ 9 | #define _NGX_ALLOC_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | void *ngx_alloc(size_t size, ngx_log_t *log); 17 | void *ngx_calloc(size_t size, ngx_log_t *log); 18 | 19 | #define ngx_free free 20 | 21 | 22 | /* 23 | * Linux has memalign() or posix_memalign() 24 | * Solaris has memalign() 25 | * FreeBSD 7.0 has posix_memalign(), besides, early version's malloc() 26 | * aligns allocations bigger than page size at the page boundary 27 | */ 28 | 29 | #if (NGX_HAVE_POSIX_MEMALIGN || NGX_HAVE_MEMALIGN) 30 | 31 | void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log); 32 | 33 | #else 34 | 35 | #define ngx_memalign(alignment, size, log) ngx_alloc(size, log) 36 | 37 | #endif 38 | 39 | 40 | extern ngx_uint_t ngx_pagesize; 41 | extern ngx_uint_t ngx_pagesize_shift; 42 | extern ngx_uint_t ngx_cacheline_size; 43 | 44 | 45 | #endif /* _NGX_ALLOC_H_INCLUDED_ */ 46 | -------------------------------------------------------------------------------- /src/os/unix/ngx_channel.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_CHANNEL_H_INCLUDED_ 9 | #define _NGX_CHANNEL_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | typedef struct { 18 | ngx_uint_t command; 19 | ngx_pid_t pid; 20 | ngx_int_t slot; 21 | ngx_fd_t fd; 22 | } ngx_channel_t; 23 | 24 | 25 | ngx_int_t ngx_write_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size, 26 | ngx_log_t *log); 27 | ngx_int_t ngx_read_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size, 28 | ngx_log_t *log); 29 | ngx_int_t ngx_add_channel_event(ngx_cycle_t *cycle, ngx_fd_t fd, 30 | ngx_int_t event, ngx_event_handler_pt handler); 31 | void ngx_close_channel(ngx_fd_t *fd, ngx_log_t *log); 32 | 33 | 34 | #endif /* _NGX_CHANNEL_H_INCLUDED_ */ 35 | -------------------------------------------------------------------------------- /src/os/unix/ngx_daemon.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | ngx_int_t 13 | ngx_daemon(ngx_log_t *log) 14 | { 15 | int fd; 16 | 17 | switch (fork()) { 18 | case -1: 19 | ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "fork() failed"); 20 | return NGX_ERROR; 21 | 22 | case 0: 23 | break; 24 | 25 | default: 26 | exit(0); 27 | } 28 | 29 | ngx_pid = ngx_getpid(); 30 | 31 | if (setsid() == -1) { 32 | ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "setsid() failed"); 33 | return NGX_ERROR; 34 | } 35 | 36 | umask(0); 37 | 38 | fd = open("/dev/null", O_RDWR); 39 | if (fd == -1) { 40 | ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, 41 | "open(\"/dev/null\") failed"); 42 | return NGX_ERROR; 43 | } 44 | 45 | if (dup2(fd, STDIN_FILENO) == -1) { 46 | ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "dup2(STDIN) failed"); 47 | return NGX_ERROR; 48 | } 49 | 50 | if (dup2(fd, STDOUT_FILENO) == -1) { 51 | ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "dup2(STDOUT) failed"); 52 | return NGX_ERROR; 53 | } 54 | 55 | #if 0 56 | if (dup2(fd, STDERR_FILENO) == -1) { 57 | ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "dup2(STDERR) failed"); 58 | return NGX_ERROR; 59 | } 60 | #endif 61 | 62 | if (fd > STDERR_FILENO) { 63 | if (close(fd) == -1) { 64 | ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "close() failed"); 65 | return NGX_ERROR; 66 | } 67 | } 68 | 69 | return NGX_OK; 70 | } 71 | -------------------------------------------------------------------------------- /src/os/unix/ngx_darwin.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_DARWIN_H_INCLUDED_ 9 | #define _NGX_DARWIN_H_INCLUDED_ 10 | 11 | 12 | void ngx_debug_init(void); 13 | ngx_chain_t *ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, 14 | off_t limit); 15 | 16 | extern int ngx_darwin_kern_osreldate; 17 | extern int ngx_darwin_hw_ncpu; 18 | extern u_long ngx_darwin_net_inet_tcp_sendspace; 19 | 20 | extern ngx_uint_t ngx_debug_malloc; 21 | 22 | 23 | #endif /* _NGX_DARWIN_H_INCLUDED_ */ 24 | -------------------------------------------------------------------------------- /src/os/unix/ngx_darwin_config.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_DARWIN_CONFIG_H_INCLUDED_ 9 | #define _NGX_DARWIN_CONFIG_H_INCLUDED_ 10 | 11 | 12 | #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_0 13 | 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include /* offsetof() */ 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include /* statfs() */ 32 | 33 | #include /* FIONBIO */ 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #include 45 | #include 46 | #include /* TCP_NODELAY */ 47 | #include 48 | #include 49 | #include 50 | 51 | #include 52 | #include 53 | 54 | 55 | #ifndef IOV_MAX 56 | #define IOV_MAX 64 57 | #endif 58 | 59 | 60 | #include 61 | 62 | 63 | #if (NGX_HAVE_POSIX_SEM) 64 | #include 65 | #endif 66 | 67 | 68 | #if (NGX_HAVE_POLL) 69 | #include 70 | #endif 71 | 72 | 73 | #if (NGX_HAVE_KQUEUE) 74 | #include 75 | #endif 76 | 77 | 78 | #define NGX_LISTEN_BACKLOG -1 79 | 80 | 81 | #ifndef NGX_HAVE_INHERITED_NONBLOCK 82 | #define NGX_HAVE_INHERITED_NONBLOCK 1 83 | #endif 84 | 85 | 86 | #ifndef NGX_HAVE_CASELESS_FILESYSTEM 87 | #define NGX_HAVE_CASELESS_FILESYSTEM 1 88 | #endif 89 | 90 | 91 | #define NGX_HAVE_OS_SPECIFIC_INIT 1 92 | #define NGX_HAVE_DEBUG_MALLOC 1 93 | 94 | 95 | extern char **environ; 96 | 97 | 98 | #endif /* _NGX_DARWIN_CONFIG_H_INCLUDED_ */ 99 | -------------------------------------------------------------------------------- /src/os/unix/ngx_errno.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | /* 13 | * The strerror() messages are copied because: 14 | * 15 | * 1) strerror() and strerror_r() functions are not Async-Signal-Safe, 16 | * therefore, they cannot be used in signal handlers; 17 | * 18 | * 2) a direct sys_errlist[] array may be used instead of these functions, 19 | * but Linux linker warns about its usage: 20 | * 21 | * warning: `sys_errlist' is deprecated; use `strerror' or `strerror_r' instead 22 | * warning: `sys_nerr' is deprecated; use `strerror' or `strerror_r' instead 23 | * 24 | * causing false bug reports. 25 | */ 26 | 27 | 28 | static ngx_str_t *ngx_sys_errlist; 29 | static ngx_str_t ngx_unknown_error = ngx_string("Unknown error"); 30 | 31 | 32 | u_char * 33 | ngx_strerror(ngx_err_t err, u_char *errstr, size_t size) 34 | { 35 | ngx_str_t *msg; 36 | 37 | msg = ((ngx_uint_t) err < NGX_SYS_NERR) ? &ngx_sys_errlist[err]: 38 | &ngx_unknown_error; 39 | size = ngx_min(size, msg->len); 40 | 41 | return ngx_cpymem(errstr, msg->data, size); 42 | } 43 | 44 | 45 | ngx_int_t 46 | ngx_strerror_init(void) 47 | { 48 | char *msg; 49 | u_char *p; 50 | size_t len; 51 | ngx_err_t err; 52 | 53 | /* 54 | * ngx_strerror() is not ready to work at this stage, therefore, 55 | * malloc() is used and possible errors are logged using strerror(). 56 | */ 57 | 58 | len = NGX_SYS_NERR * sizeof(ngx_str_t); 59 | 60 | ngx_sys_errlist = malloc(len); 61 | if (ngx_sys_errlist == NULL) { 62 | goto failed; 63 | } 64 | 65 | for (err = 0; err < NGX_SYS_NERR; err++) { 66 | msg = strerror(err); 67 | len = ngx_strlen(msg); 68 | 69 | p = malloc(len); 70 | if (p == NULL) { 71 | goto failed; 72 | } 73 | 74 | ngx_memcpy(p, msg, len); 75 | ngx_sys_errlist[err].len = len; 76 | ngx_sys_errlist[err].data = p; 77 | } 78 | 79 | return NGX_OK; 80 | 81 | failed: 82 | 83 | err = errno; 84 | ngx_log_stderr(0, "malloc(%uz) failed (%d: %s)", len, err, strerror(err)); 85 | 86 | return NGX_ERROR; 87 | } 88 | -------------------------------------------------------------------------------- /src/os/unix/ngx_errno.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_ERRNO_H_INCLUDED_ 9 | #define _NGX_ERRNO_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | typedef int ngx_err_t; 17 | 18 | #define NGX_EPERM EPERM 19 | #define NGX_ENOENT ENOENT 20 | #define NGX_ENOPATH ENOENT 21 | #define NGX_ESRCH ESRCH 22 | #define NGX_EINTR EINTR 23 | #define NGX_ECHILD ECHILD 24 | #define NGX_ENOMEM ENOMEM 25 | #define NGX_EACCES EACCES 26 | #define NGX_EBUSY EBUSY 27 | #define NGX_EEXIST EEXIST 28 | #define NGX_EXDEV EXDEV 29 | #define NGX_ENOTDIR ENOTDIR 30 | #define NGX_EISDIR EISDIR 31 | #define NGX_EINVAL EINVAL 32 | #define NGX_ENFILE ENFILE 33 | #define NGX_EMFILE EMFILE 34 | #define NGX_ENOSPC ENOSPC 35 | #define NGX_EPIPE EPIPE 36 | #define NGX_EINPROGRESS EINPROGRESS 37 | #define NGX_ENOPROTOOPT ENOPROTOOPT 38 | #define NGX_EOPNOTSUPP EOPNOTSUPP 39 | #define NGX_EADDRINUSE EADDRINUSE 40 | #define NGX_ECONNABORTED ECONNABORTED 41 | #define NGX_ECONNRESET ECONNRESET 42 | #define NGX_ENOTCONN ENOTCONN 43 | #define NGX_ETIMEDOUT ETIMEDOUT 44 | #define NGX_ECONNREFUSED ECONNREFUSED 45 | #define NGX_ENAMETOOLONG ENAMETOOLONG 46 | #define NGX_ENETDOWN ENETDOWN 47 | #define NGX_ENETUNREACH ENETUNREACH 48 | #define NGX_EHOSTDOWN EHOSTDOWN 49 | #define NGX_EHOSTUNREACH EHOSTUNREACH 50 | #define NGX_ENOSYS ENOSYS 51 | #define NGX_ECANCELED ECANCELED 52 | #define NGX_EILSEQ EILSEQ 53 | #define NGX_ENOMOREFILES 0 54 | #define NGX_ELOOP ELOOP 55 | #define NGX_EBADF EBADF 56 | 57 | #if (NGX_HAVE_OPENAT) 58 | #define NGX_EMLINK EMLINK 59 | #endif 60 | 61 | #if (__hpux__) 62 | #define NGX_EAGAIN EWOULDBLOCK 63 | #else 64 | #define NGX_EAGAIN EAGAIN 65 | #endif 66 | 67 | 68 | #define ngx_errno errno 69 | #define ngx_socket_errno errno 70 | #define ngx_set_errno(err) errno = err 71 | #define ngx_set_socket_errno(err) errno = err 72 | 73 | 74 | u_char *ngx_strerror(ngx_err_t err, u_char *errstr, size_t size); 75 | ngx_int_t ngx_strerror_init(void); 76 | 77 | 78 | #endif /* _NGX_ERRNO_H_INCLUDED_ */ 79 | -------------------------------------------------------------------------------- /src/os/unix/ngx_freebsd.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_FREEBSD_H_INCLUDED_ 9 | #define _NGX_FREEBSD_H_INCLUDED_ 10 | 11 | 12 | void ngx_debug_init(void); 13 | ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, 14 | off_t limit); 15 | 16 | extern int ngx_freebsd_kern_osreldate; 17 | extern int ngx_freebsd_hw_ncpu; 18 | extern u_long ngx_freebsd_net_inet_tcp_sendspace; 19 | 20 | extern ngx_uint_t ngx_freebsd_sendfile_nbytes_bug; 21 | extern ngx_uint_t ngx_freebsd_use_tcp_nopush; 22 | extern ngx_uint_t ngx_debug_malloc; 23 | 24 | 25 | #endif /* _NGX_FREEBSD_H_INCLUDED_ */ 26 | -------------------------------------------------------------------------------- /src/os/unix/ngx_gcc_atomic_amd64.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #if (NGX_SMP) 9 | #define NGX_SMP_LOCK "lock;" 10 | #else 11 | #define NGX_SMP_LOCK 12 | #endif 13 | 14 | 15 | /* 16 | * "cmpxchgq r, [m]": 17 | * 18 | * if (rax == [m]) { 19 | * zf = 1; 20 | * [m] = r; 21 | * } else { 22 | * zf = 0; 23 | * rax = [m]; 24 | * } 25 | * 26 | * 27 | * The "r" is any register, %rax (%r0) - %r16. 28 | * The "=a" and "a" are the %rax register. 29 | * Although we can return result in any register, we use "a" because it is 30 | * used in cmpxchgq anyway. The result is actually in %al but not in $rax, 31 | * however as the code is inlined gcc can test %al as well as %rax. 32 | * 33 | * The "cc" means that flags were changed. 34 | */ 35 | 36 | static ngx_inline ngx_atomic_uint_t 37 | ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, 38 | ngx_atomic_uint_t set) 39 | { 40 | u_char res; 41 | 42 | __asm__ volatile ( 43 | 44 | NGX_SMP_LOCK 45 | " cmpxchgq %3, %1; " 46 | " sete %0; " 47 | 48 | : "=a" (res) : "m" (*lock), "a" (old), "r" (set) : "cc", "memory"); 49 | 50 | return res; 51 | } 52 | 53 | 54 | /* 55 | * "xaddq r, [m]": 56 | * 57 | * temp = [m]; 58 | * [m] += r; 59 | * r = temp; 60 | * 61 | * 62 | * The "+r" is any register, %rax (%r0) - %r16. 63 | * The "cc" means that flags were changed. 64 | */ 65 | 66 | static ngx_inline ngx_atomic_int_t 67 | ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add) 68 | { 69 | __asm__ volatile ( 70 | 71 | NGX_SMP_LOCK 72 | " xaddq %0, %1; " 73 | 74 | : "+r" (add) : "m" (*value) : "cc", "memory"); 75 | 76 | return add; 77 | } 78 | 79 | 80 | #define ngx_memory_barrier() __asm__ volatile ("" ::: "memory") 81 | 82 | #define ngx_cpu_pause() __asm__ ("pause") 83 | -------------------------------------------------------------------------------- /src/os/unix/ngx_gcc_atomic_sparc64.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | /* 9 | * "casa [r1] 0x80, r2, r0" and 10 | * "casxa [r1] 0x80, r2, r0" do the following: 11 | * 12 | * if ([r1] == r2) { 13 | * swap(r0, [r1]); 14 | * } else { 15 | * r0 = [r1]; 16 | * } 17 | * 18 | * so "r0 == r2" means that the operation was successful. 19 | * 20 | * 21 | * The "r" means the general register. 22 | * The "+r" means the general register used for both input and output. 23 | */ 24 | 25 | 26 | #if (NGX_PTR_SIZE == 4) 27 | #define NGX_CASA "casa" 28 | #else 29 | #define NGX_CASA "casxa" 30 | #endif 31 | 32 | 33 | static ngx_inline ngx_atomic_uint_t 34 | ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, 35 | ngx_atomic_uint_t set) 36 | { 37 | __asm__ volatile ( 38 | 39 | NGX_CASA " [%1] 0x80, %2, %0" 40 | 41 | : "+r" (set) : "r" (lock), "r" (old) : "memory"); 42 | 43 | return (set == old); 44 | } 45 | 46 | 47 | static ngx_inline ngx_atomic_int_t 48 | ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add) 49 | { 50 | ngx_atomic_uint_t old, res; 51 | 52 | old = *value; 53 | 54 | for ( ;; ) { 55 | 56 | res = old + add; 57 | 58 | __asm__ volatile ( 59 | 60 | NGX_CASA " [%1] 0x80, %2, %0" 61 | 62 | : "+r" (res) : "r" (value), "r" (old) : "memory"); 63 | 64 | if (res == old) { 65 | return res; 66 | } 67 | 68 | old = res; 69 | } 70 | } 71 | 72 | 73 | #if (NGX_SMP) 74 | #define ngx_memory_barrier() \ 75 | __asm__ volatile ( \ 76 | "membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad" \ 77 | ::: "memory") 78 | #else 79 | #define ngx_memory_barrier() __asm__ volatile ("" ::: "memory") 80 | #endif 81 | 82 | #define ngx_cpu_pause() 83 | -------------------------------------------------------------------------------- /src/os/unix/ngx_linux.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_LINUX_H_INCLUDED_ 9 | #define _NGX_LINUX_H_INCLUDED_ 10 | 11 | 12 | ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, 13 | off_t limit); 14 | 15 | extern int ngx_linux_rtsig_max; 16 | 17 | 18 | #endif /* _NGX_LINUX_H_INCLUDED_ */ 19 | -------------------------------------------------------------------------------- /src/os/unix/ngx_linux_init.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | u_char ngx_linux_kern_ostype[50]; 13 | u_char ngx_linux_kern_osrelease[50]; 14 | 15 | int ngx_linux_rtsig_max; 16 | 17 | 18 | static ngx_os_io_t ngx_linux_io = { 19 | ngx_unix_recv, 20 | ngx_readv_chain, 21 | ngx_udp_unix_recv, 22 | ngx_unix_send, 23 | #if (NGX_HAVE_SENDFILE) 24 | ngx_linux_sendfile_chain, 25 | NGX_IO_SENDFILE 26 | #else 27 | ngx_writev_chain, 28 | 0 29 | #endif 30 | }; 31 | 32 | 33 | ngx_int_t 34 | ngx_os_specific_init(ngx_log_t *log) 35 | { 36 | struct utsname u; 37 | 38 | if (uname(&u) == -1) { 39 | ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "uname() failed"); 40 | return NGX_ERROR; 41 | } 42 | 43 | (void) ngx_cpystrn(ngx_linux_kern_ostype, (u_char *) u.sysname, 44 | sizeof(ngx_linux_kern_ostype)); 45 | 46 | (void) ngx_cpystrn(ngx_linux_kern_osrelease, (u_char *) u.release, 47 | sizeof(ngx_linux_kern_osrelease)); 48 | 49 | #if (NGX_HAVE_RTSIG) 50 | { 51 | int name[2]; 52 | size_t len; 53 | ngx_err_t err; 54 | 55 | name[0] = CTL_KERN; 56 | name[1] = KERN_RTSIGMAX; 57 | len = sizeof(ngx_linux_rtsig_max); 58 | 59 | if (sysctl(name, 2, &ngx_linux_rtsig_max, &len, NULL, 0) == -1) { 60 | err = ngx_errno; 61 | 62 | if (err != NGX_ENOTDIR && err != NGX_ENOSYS) { 63 | ngx_log_error(NGX_LOG_ALERT, log, err, 64 | "sysctl(KERN_RTSIGMAX) failed"); 65 | 66 | return NGX_ERROR; 67 | } 68 | 69 | ngx_linux_rtsig_max = 0; 70 | } 71 | 72 | } 73 | #endif 74 | 75 | ngx_os_io = ngx_linux_io; 76 | 77 | return NGX_OK; 78 | } 79 | 80 | 81 | void 82 | ngx_os_specific_status(ngx_log_t *log) 83 | { 84 | ngx_log_error(NGX_LOG_NOTICE, log, 0, "OS: %s %s", 85 | ngx_linux_kern_ostype, ngx_linux_kern_osrelease); 86 | 87 | #if (NGX_HAVE_RTSIG) 88 | ngx_log_error(NGX_LOG_NOTICE, log, 0, "sysctl(KERN_RTSIGMAX): %d", 89 | ngx_linux_rtsig_max); 90 | #endif 91 | } 92 | -------------------------------------------------------------------------------- /src/os/unix/ngx_os.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_OS_H_INCLUDED_ 9 | #define _NGX_OS_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | #define NGX_IO_SENDFILE 1 17 | 18 | 19 | typedef ssize_t (*ngx_recv_pt)(ngx_connection_t *c, u_char *buf, size_t size); 20 | typedef ssize_t (*ngx_recv_chain_pt)(ngx_connection_t *c, ngx_chain_t *in); 21 | typedef ssize_t (*ngx_send_pt)(ngx_connection_t *c, u_char *buf, size_t size); 22 | typedef ngx_chain_t *(*ngx_send_chain_pt)(ngx_connection_t *c, ngx_chain_t *in, 23 | off_t limit); 24 | 25 | typedef struct { 26 | ngx_recv_pt recv; 27 | ngx_recv_chain_pt recv_chain; 28 | ngx_recv_pt udp_recv; 29 | ngx_send_pt send; 30 | ngx_send_chain_pt send_chain; 31 | ngx_uint_t flags; 32 | } ngx_os_io_t; 33 | 34 | 35 | ngx_int_t ngx_os_init(ngx_log_t *log); 36 | void ngx_os_status(ngx_log_t *log); 37 | ngx_int_t ngx_os_specific_init(ngx_log_t *log); 38 | void ngx_os_specific_status(ngx_log_t *log); 39 | ngx_int_t ngx_daemon(ngx_log_t *log); 40 | ngx_int_t ngx_os_signal_process(ngx_cycle_t *cycle, char *sig, ngx_int_t pid); 41 | 42 | 43 | ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size); 44 | ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *entry); 45 | ssize_t ngx_udp_unix_recv(ngx_connection_t *c, u_char *buf, size_t size); 46 | ssize_t ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size); 47 | ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, 48 | off_t limit); 49 | 50 | #if (NGX_HAVE_AIO) 51 | ssize_t ngx_aio_read(ngx_connection_t *c, u_char *buf, size_t size); 52 | ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl); 53 | ssize_t ngx_aio_write(ngx_connection_t *c, u_char *buf, size_t size); 54 | ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in, 55 | off_t limit); 56 | #endif 57 | 58 | 59 | extern ngx_os_io_t ngx_os_io; 60 | extern ngx_int_t ngx_ncpu; 61 | extern ngx_int_t ngx_max_sockets; 62 | extern ngx_uint_t ngx_inherited_nonblocking; 63 | extern ngx_uint_t ngx_tcp_nodelay_and_tcp_nopush; 64 | 65 | 66 | #if (NGX_FREEBSD) 67 | #include 68 | 69 | 70 | #elif (NGX_LINUX) 71 | #include 72 | 73 | 74 | #elif (NGX_SOLARIS) 75 | #include 76 | 77 | 78 | #elif (NGX_DARWIN) 79 | #include 80 | #endif 81 | 82 | 83 | #endif /* _NGX_OS_H_INCLUDED_ */ 84 | -------------------------------------------------------------------------------- /src/os/unix/ngx_process.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_PROCESS_H_INCLUDED_ 9 | #define _NGX_PROCESS_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | typedef pid_t ngx_pid_t; 17 | 18 | #define NGX_INVALID_PID -1 19 | 20 | typedef void (*ngx_spawn_proc_pt) (ngx_cycle_t *cycle, void *data); 21 | 22 | typedef struct { 23 | ngx_pid_t pid; 24 | int status; 25 | ngx_socket_t channel[2]; 26 | 27 | ngx_spawn_proc_pt proc; 28 | void *data; 29 | char *name; 30 | 31 | unsigned respawn:1; 32 | unsigned just_spawn:1; 33 | unsigned detached:1; 34 | unsigned exiting:1; 35 | unsigned exited:1; 36 | } ngx_process_t; 37 | 38 | 39 | typedef struct { 40 | char *path; 41 | char *name; 42 | char *const *argv; 43 | char *const *envp; 44 | } ngx_exec_ctx_t; 45 | 46 | 47 | #define NGX_MAX_PROCESSES 1024 48 | 49 | #define NGX_PROCESS_NORESPAWN -1 50 | #define NGX_PROCESS_JUST_SPAWN -2 51 | #define NGX_PROCESS_RESPAWN -3 52 | #define NGX_PROCESS_JUST_RESPAWN -4 53 | #define NGX_PROCESS_DETACHED -5 54 | 55 | 56 | #define ngx_getpid getpid 57 | 58 | #ifndef ngx_log_pid 59 | #define ngx_log_pid ngx_pid 60 | #endif 61 | 62 | 63 | ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle, 64 | ngx_spawn_proc_pt proc, void *data, char *name, ngx_int_t respawn); 65 | ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx); 66 | ngx_int_t ngx_init_signals(ngx_log_t *log); 67 | void ngx_debug_point(void); 68 | 69 | 70 | #if (NGX_HAVE_SCHED_YIELD) 71 | #define ngx_sched_yield() sched_yield() 72 | #else 73 | #define ngx_sched_yield() usleep(1) 74 | #endif 75 | 76 | 77 | extern int ngx_argc; 78 | extern char **ngx_argv; 79 | extern char **ngx_os_argv; 80 | 81 | extern ngx_pid_t ngx_pid; 82 | extern ngx_socket_t ngx_channel; 83 | extern ngx_int_t ngx_process_slot; 84 | extern ngx_int_t ngx_last_process; 85 | extern ngx_process_t ngx_processes[NGX_MAX_PROCESSES]; 86 | 87 | 88 | #endif /* _NGX_PROCESS_H_INCLUDED_ */ 89 | -------------------------------------------------------------------------------- /src/os/unix/ngx_process_cycle.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_PROCESS_CYCLE_H_INCLUDED_ 9 | #define _NGX_PROCESS_CYCLE_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | #define NGX_CMD_OPEN_CHANNEL 1 17 | #define NGX_CMD_CLOSE_CHANNEL 2 18 | #define NGX_CMD_QUIT 3 19 | #define NGX_CMD_TERMINATE 4 20 | #define NGX_CMD_REOPEN 5 21 | 22 | 23 | #define NGX_PROCESS_SINGLE 0 24 | #define NGX_PROCESS_MASTER 1 25 | #define NGX_PROCESS_SIGNALLER 2 26 | #define NGX_PROCESS_WORKER 3 27 | #define NGX_PROCESS_HELPER 4 28 | 29 | 30 | typedef struct { 31 | ngx_event_handler_pt handler; 32 | char *name; 33 | ngx_msec_t delay; 34 | } ngx_cache_manager_ctx_t; 35 | 36 | 37 | void ngx_master_process_cycle(ngx_cycle_t *cycle); 38 | void ngx_single_process_cycle(ngx_cycle_t *cycle); 39 | 40 | 41 | extern ngx_uint_t ngx_process; 42 | extern ngx_pid_t ngx_pid; 43 | extern ngx_pid_t ngx_new_binary; 44 | extern ngx_uint_t ngx_inherited; 45 | extern ngx_uint_t ngx_daemonized; 46 | extern ngx_uint_t ngx_threaded; 47 | extern ngx_uint_t ngx_exiting; 48 | 49 | extern sig_atomic_t ngx_reap; 50 | extern sig_atomic_t ngx_sigio; 51 | extern sig_atomic_t ngx_sigalrm; 52 | extern sig_atomic_t ngx_quit; 53 | extern sig_atomic_t ngx_debug_quit; 54 | extern sig_atomic_t ngx_terminate; 55 | extern sig_atomic_t ngx_noaccept; 56 | extern sig_atomic_t ngx_reconfigure; 57 | extern sig_atomic_t ngx_reopen; 58 | extern sig_atomic_t ngx_change_binary; 59 | 60 | 61 | #endif /* _NGX_PROCESS_CYCLE_H_INCLUDED_ */ 62 | -------------------------------------------------------------------------------- /src/os/unix/ngx_send.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | ssize_t 14 | ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size) 15 | { 16 | ssize_t n; 17 | ngx_err_t err; 18 | ngx_event_t *wev; 19 | 20 | wev = c->write; 21 | 22 | #if (NGX_HAVE_KQUEUE) 23 | 24 | if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) { 25 | (void) ngx_connection_error(c, wev->kq_errno, 26 | "kevent() reported about an closed connection"); 27 | wev->error = 1; 28 | return NGX_ERROR; 29 | } 30 | 31 | #endif 32 | 33 | for ( ;; ) { 34 | n = send(c->fd, buf, size, 0); 35 | 36 | ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, 37 | "send: fd:%d %d of %d", c->fd, n, size); 38 | 39 | if (n > 0) { 40 | if (n < (ssize_t) size) { 41 | wev->ready = 0; 42 | } 43 | 44 | c->sent += n; 45 | 46 | return n; 47 | } 48 | 49 | err = ngx_socket_errno; 50 | 51 | if (n == 0) { 52 | ngx_log_error(NGX_LOG_ALERT, c->log, err, "send() returned zero"); 53 | wev->ready = 0; 54 | return n; 55 | } 56 | 57 | if (err == NGX_EAGAIN || err == NGX_EINTR) { 58 | wev->ready = 0; 59 | 60 | ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, 61 | "send() not ready"); 62 | 63 | if (err == NGX_EAGAIN) { 64 | return NGX_AGAIN; 65 | } 66 | 67 | } else { 68 | wev->error = 1; 69 | (void) ngx_connection_error(c, err, "send() failed"); 70 | return NGX_ERROR; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/os/unix/ngx_setaffinity.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Nginx, Inc. 4 | */ 5 | 6 | 7 | #include 8 | #include 9 | 10 | 11 | #if (NGX_HAVE_CPUSET_SETAFFINITY) 12 | 13 | #include 14 | 15 | void 16 | ngx_setaffinity(uint64_t cpu_affinity, ngx_log_t *log) 17 | { 18 | cpuset_t mask; 19 | ngx_uint_t i; 20 | 21 | ngx_log_error(NGX_LOG_NOTICE, log, 0, 22 | "cpuset_setaffinity(0x%08Xl)", cpu_affinity); 23 | 24 | CPU_ZERO(&mask); 25 | i = 0; 26 | do { 27 | if (cpu_affinity & 1) { 28 | CPU_SET(i, &mask); 29 | } 30 | i++; 31 | cpu_affinity >>= 1; 32 | } while (cpu_affinity); 33 | 34 | if (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, 35 | sizeof(cpuset_t), &mask) == -1) 36 | { 37 | ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, 38 | "cpuset_setaffinity() failed"); 39 | } 40 | } 41 | 42 | #elif (NGX_HAVE_SCHED_SETAFFINITY) 43 | 44 | void 45 | ngx_setaffinity(uint64_t cpu_affinity, ngx_log_t *log) 46 | { 47 | cpu_set_t mask; 48 | ngx_uint_t i; 49 | 50 | ngx_log_error(NGX_LOG_NOTICE, log, 0, 51 | "sched_setaffinity(0x%08Xl)", cpu_affinity); 52 | 53 | CPU_ZERO(&mask); 54 | i = 0; 55 | do { 56 | if (cpu_affinity & 1) { 57 | CPU_SET(i, &mask); 58 | } 59 | i++; 60 | cpu_affinity >>= 1; 61 | } while (cpu_affinity); 62 | 63 | if (sched_setaffinity(0, sizeof(cpu_set_t), &mask) == -1) { 64 | ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, 65 | "sched_setaffinity() failed"); 66 | } 67 | } 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/os/unix/ngx_setaffinity.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Nginx, Inc. 4 | */ 5 | 6 | #ifndef _NGX_SETAFFINITY_H_INCLUDED_ 7 | #define _NGX_SETAFFINITY_H_INCLUDED_ 8 | 9 | 10 | #if (NGX_HAVE_SCHED_SETAFFINITY || NGX_HAVE_CPUSET_SETAFFINITY) 11 | 12 | #define NGX_HAVE_CPU_AFFINITY 1 13 | 14 | void ngx_setaffinity(uint64_t cpu_affinity, ngx_log_t *log); 15 | 16 | #else 17 | 18 | #define ngx_setaffinity(cpu_affinity, log) 19 | 20 | #endif 21 | 22 | 23 | #endif /* _NGX_SETAFFINITY_H_INCLUDED_ */ 24 | -------------------------------------------------------------------------------- /src/os/unix/ngx_setproctitle.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_SETPROCTITLE_H_INCLUDED_ 9 | #define _NGX_SETPROCTITLE_H_INCLUDED_ 10 | 11 | 12 | #if (NGX_HAVE_SETPROCTITLE) 13 | 14 | /* FreeBSD, NetBSD, OpenBSD */ 15 | 16 | #define ngx_init_setproctitle(log) 17 | #define ngx_setproctitle(title) setproctitle("%s", title) 18 | 19 | 20 | #else /* !NGX_HAVE_SETPROCTITLE */ 21 | 22 | #if !defined NGX_SETPROCTITLE_USES_ENV 23 | 24 | #if (NGX_SOLARIS) 25 | 26 | #define NGX_SETPROCTITLE_USES_ENV 1 27 | #define NGX_SETPROCTITLE_PAD ' ' 28 | 29 | ngx_int_t ngx_init_setproctitle(ngx_log_t *log); 30 | void ngx_setproctitle(char *title); 31 | 32 | #elif (NGX_LINUX) || (NGX_DARWIN) 33 | 34 | #define NGX_SETPROCTITLE_USES_ENV 1 35 | #define NGX_SETPROCTITLE_PAD '\0' 36 | 37 | ngx_int_t ngx_init_setproctitle(ngx_log_t *log); 38 | void ngx_setproctitle(char *title); 39 | 40 | #else 41 | 42 | #define ngx_init_setproctitle(log) 43 | #define ngx_setproctitle(title) 44 | 45 | #endif /* OSes */ 46 | 47 | #endif /* NGX_SETPROCTITLE_USES_ENV */ 48 | 49 | #endif /* NGX_HAVE_SETPROCTITLE */ 50 | 51 | 52 | #endif /* _NGX_SETPROCTITLE_H_INCLUDED_ */ 53 | -------------------------------------------------------------------------------- /src/os/unix/ngx_shmem.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_SHMEM_H_INCLUDED_ 9 | #define _NGX_SHMEM_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | typedef struct { 17 | u_char *addr; 18 | size_t size; 19 | ngx_str_t name; 20 | ngx_log_t *log; 21 | ngx_uint_t exists; /* unsigned exists:1; */ 22 | } ngx_shm_t; 23 | 24 | 25 | ngx_int_t ngx_shm_alloc(ngx_shm_t *shm); 26 | void ngx_shm_free(ngx_shm_t *shm); 27 | 28 | 29 | #endif /* _NGX_SHMEM_H_INCLUDED_ */ 30 | -------------------------------------------------------------------------------- /src/os/unix/ngx_socket.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | /* 13 | * ioctl(FIONBIO) sets a non-blocking mode with the single syscall 14 | * while fcntl(F_SETFL, O_NONBLOCK) needs to learn the current state 15 | * using fcntl(F_GETFL). 16 | * 17 | * ioctl() and fcntl() are syscalls at least in FreeBSD 2.x, Linux 2.2 18 | * and Solaris 7. 19 | * 20 | * ioctl() in Linux 2.4 and 2.6 uses BKL, however, fcntl(F_SETFL) uses it too. 21 | */ 22 | 23 | 24 | #if (NGX_HAVE_FIONBIO) 25 | 26 | int 27 | ngx_nonblocking(ngx_socket_t s) 28 | { 29 | int nb; 30 | 31 | nb = 1; 32 | 33 | return ioctl(s, FIONBIO, &nb); 34 | } 35 | 36 | 37 | int 38 | ngx_blocking(ngx_socket_t s) 39 | { 40 | int nb; 41 | 42 | nb = 0; 43 | 44 | return ioctl(s, FIONBIO, &nb); 45 | } 46 | 47 | #endif 48 | 49 | 50 | #if (NGX_FREEBSD) 51 | 52 | int 53 | ngx_tcp_nopush(ngx_socket_t s) 54 | { 55 | int tcp_nopush; 56 | 57 | tcp_nopush = 1; 58 | 59 | return setsockopt(s, IPPROTO_TCP, TCP_NOPUSH, 60 | (const void *) &tcp_nopush, sizeof(int)); 61 | } 62 | 63 | 64 | int 65 | ngx_tcp_push(ngx_socket_t s) 66 | { 67 | int tcp_nopush; 68 | 69 | tcp_nopush = 0; 70 | 71 | return setsockopt(s, IPPROTO_TCP, TCP_NOPUSH, 72 | (const void *) &tcp_nopush, sizeof(int)); 73 | } 74 | 75 | #elif (NGX_LINUX) 76 | 77 | 78 | int 79 | ngx_tcp_nopush(ngx_socket_t s) 80 | { 81 | int cork; 82 | 83 | cork = 1; 84 | 85 | return setsockopt(s, IPPROTO_TCP, TCP_CORK, 86 | (const void *) &cork, sizeof(int)); 87 | } 88 | 89 | 90 | int 91 | ngx_tcp_push(ngx_socket_t s) 92 | { 93 | int cork; 94 | 95 | cork = 0; 96 | 97 | return setsockopt(s, IPPROTO_TCP, TCP_CORK, 98 | (const void *) &cork, sizeof(int)); 99 | } 100 | 101 | #else 102 | 103 | int 104 | ngx_tcp_nopush(ngx_socket_t s) 105 | { 106 | return 0; 107 | } 108 | 109 | 110 | int 111 | ngx_tcp_push(ngx_socket_t s) 112 | { 113 | return 0; 114 | } 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /src/os/unix/ngx_socket.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_SOCKET_H_INCLUDED_ 9 | #define _NGX_SOCKET_H_INCLUDED_ 10 | 11 | 12 | #include 13 | 14 | 15 | #define NGX_WRITE_SHUTDOWN SHUT_WR 16 | 17 | typedef int ngx_socket_t; 18 | 19 | #define ngx_socket socket 20 | #define ngx_socket_n "socket()" 21 | 22 | 23 | #if (NGX_HAVE_FIONBIO) 24 | 25 | int ngx_nonblocking(ngx_socket_t s); 26 | int ngx_blocking(ngx_socket_t s); 27 | 28 | #define ngx_nonblocking_n "ioctl(FIONBIO)" 29 | #define ngx_blocking_n "ioctl(!FIONBIO)" 30 | 31 | #else 32 | 33 | #define ngx_nonblocking(s) fcntl(s, F_SETFL, fcntl(s, F_GETFL) | O_NONBLOCK) 34 | #define ngx_nonblocking_n "fcntl(O_NONBLOCK)" 35 | 36 | #define ngx_blocking(s) fcntl(s, F_SETFL, fcntl(s, F_GETFL) & ~O_NONBLOCK) 37 | #define ngx_blocking_n "fcntl(!O_NONBLOCK)" 38 | 39 | #endif 40 | 41 | int ngx_tcp_nopush(ngx_socket_t s); 42 | int ngx_tcp_push(ngx_socket_t s); 43 | 44 | #if (NGX_LINUX) 45 | 46 | #define ngx_tcp_nopush_n "setsockopt(TCP_CORK)" 47 | #define ngx_tcp_push_n "setsockopt(!TCP_CORK)" 48 | 49 | #else 50 | 51 | #define ngx_tcp_nopush_n "setsockopt(TCP_NOPUSH)" 52 | #define ngx_tcp_push_n "setsockopt(!TCP_NOPUSH)" 53 | 54 | #endif 55 | 56 | 57 | #define ngx_shutdown_socket shutdown 58 | #define ngx_shutdown_socket_n "shutdown()" 59 | 60 | #define ngx_close_socket close 61 | #define ngx_close_socket_n "close() socket" 62 | 63 | 64 | #endif /* _NGX_SOCKET_H_INCLUDED_ */ 65 | -------------------------------------------------------------------------------- /src/os/unix/ngx_solaris.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_SOLARIS_H_INCLUDED_ 9 | #define _NGX_SOLARIS_H_INCLUDED_ 10 | 11 | 12 | ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in, 13 | off_t limit); 14 | 15 | 16 | #endif /* _NGX_SOLARIS_H_INCLUDED_ */ 17 | -------------------------------------------------------------------------------- /src/os/unix/ngx_solaris_config.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_SOLARIS_CONFIG_H_INCLUDED_ 9 | #define _NGX_SOLARIS_CONFIG_H_INCLUDED_ 10 | 11 | 12 | #ifndef _REENTRANT 13 | #define _REENTRANT 14 | #endif 15 | 16 | #define _FILE_OFFSET_BITS 64 /* must be before */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include /* offsetof() */ 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include /* statvfs() */ 35 | 36 | #include /* FIONBIO */ 37 | #include 38 | #include 39 | #include 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #include 47 | #include 48 | #include /* TCP_NODELAY */ 49 | #include 50 | #include 51 | #include 52 | 53 | #include 54 | #include /* IOV_MAX */ 55 | #include 56 | #include 57 | 58 | #define NGX_ALIGNMENT _MAX_ALIGNMENT 59 | 60 | #include 61 | 62 | 63 | #if (NGX_HAVE_POSIX_SEM) 64 | #include 65 | #endif 66 | 67 | 68 | #if (NGX_HAVE_POLL) 69 | #include 70 | #endif 71 | 72 | 73 | #if (NGX_HAVE_DEVPOLL) 74 | #include 75 | #include 76 | #endif 77 | 78 | 79 | #if (NGX_HAVE_EVENTPORT) 80 | #include 81 | #endif 82 | 83 | 84 | #if (NGX_HAVE_SENDFILE) 85 | #include 86 | #endif 87 | 88 | 89 | #define NGX_LISTEN_BACKLOG 511 90 | 91 | 92 | #ifndef NGX_HAVE_INHERITED_NONBLOCK 93 | #define NGX_HAVE_INHERITED_NONBLOCK 1 94 | #endif 95 | 96 | 97 | #ifndef NGX_HAVE_SO_SNDLOWAT 98 | /* setsockopt(SO_SNDLOWAT) returns ENOPROTOOPT */ 99 | #define NGX_HAVE_SO_SNDLOWAT 0 100 | #endif 101 | 102 | 103 | #define NGX_HAVE_OS_SPECIFIC_INIT 1 104 | #define ngx_debug_init() 105 | 106 | 107 | extern char **environ; 108 | 109 | 110 | #endif /* _NGX_SOLARIS_CONFIG_H_INCLUDED_ */ 111 | -------------------------------------------------------------------------------- /src/os/unix/ngx_solaris_init.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | char ngx_solaris_sysname[20]; 13 | char ngx_solaris_release[10]; 14 | char ngx_solaris_version[50]; 15 | 16 | 17 | static ngx_os_io_t ngx_solaris_io = { 18 | ngx_unix_recv, 19 | ngx_readv_chain, 20 | ngx_udp_unix_recv, 21 | ngx_unix_send, 22 | #if (NGX_HAVE_SENDFILE) 23 | ngx_solaris_sendfilev_chain, 24 | NGX_IO_SENDFILE 25 | #else 26 | ngx_writev_chain, 27 | 0 28 | #endif 29 | }; 30 | 31 | 32 | ngx_int_t 33 | ngx_os_specific_init(ngx_log_t *log) 34 | { 35 | if (sysinfo(SI_SYSNAME, ngx_solaris_sysname, sizeof(ngx_solaris_sysname)) 36 | == -1) 37 | { 38 | ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, 39 | "sysinfo(SI_SYSNAME) failed"); 40 | return NGX_ERROR; 41 | } 42 | 43 | if (sysinfo(SI_RELEASE, ngx_solaris_release, sizeof(ngx_solaris_release)) 44 | == -1) 45 | { 46 | ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, 47 | "sysinfo(SI_RELEASE) failed"); 48 | return NGX_ERROR; 49 | } 50 | 51 | if (sysinfo(SI_VERSION, ngx_solaris_version, sizeof(ngx_solaris_version)) 52 | == -1) 53 | { 54 | ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, 55 | "sysinfo(SI_SYSNAME) failed"); 56 | return NGX_ERROR; 57 | } 58 | 59 | 60 | ngx_os_io = ngx_solaris_io; 61 | 62 | return NGX_OK; 63 | } 64 | 65 | 66 | void 67 | ngx_os_specific_status(ngx_log_t *log) 68 | { 69 | 70 | ngx_log_error(NGX_LOG_NOTICE, log, 0, "OS: %s %s", 71 | ngx_solaris_sysname, ngx_solaris_release); 72 | 73 | ngx_log_error(NGX_LOG_NOTICE, log, 0, "version: %s", 74 | ngx_solaris_version); 75 | } 76 | -------------------------------------------------------------------------------- /src/os/unix/ngx_sunpro_amd64.il: -------------------------------------------------------------------------------- 1 | / 2 | / Copyright (C) Igor Sysoev 3 | / Copyright (C) Nginx, Inc. 4 | / 5 | 6 | / ngx_atomic_uint_t ngx_atomic_cmp_set(ngx_atomic_t *lock, 7 | / ngx_atomic_uint_t old, ngx_atomic_uint_t set); 8 | / 9 | / the arguments are passed in %rdi, %rsi, %rdx 10 | / the result is returned in the %rax 11 | 12 | .inline ngx_atomic_cmp_set,0 13 | movq %rsi, %rax 14 | lock 15 | cmpxchgq %rdx, (%rdi) 16 | setz %al 17 | movzbq %al, %rax 18 | .end 19 | 20 | 21 | / ngx_atomic_int_t ngx_atomic_fetch_add(ngx_atomic_t *value, 22 | / ngx_atomic_int_t add); 23 | / 24 | / the arguments are passed in %rdi, %rsi 25 | / the result is returned in the %rax 26 | 27 | .inline ngx_atomic_fetch_add,0 28 | movq %rsi, %rax 29 | lock 30 | xaddq %rax, (%rdi) 31 | .end 32 | 33 | 34 | / ngx_cpu_pause() 35 | / 36 | / the "rep; nop" is used instead of "pause" to avoid the "[ PAUSE ]" hardware 37 | / capability added by linker because Solaris/amd64 does not know about it: 38 | / 39 | / ld.so.1: nginx: fatal: hardware capability unsupported: 0x2000 [ PAUSE ] 40 | 41 | .inline ngx_cpu_pause,0 42 | rep; nop 43 | .end 44 | -------------------------------------------------------------------------------- /src/os/unix/ngx_sunpro_atomic_sparc64.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #if (NGX_PTR_SIZE == 4) 9 | #define NGX_CASA ngx_casa 10 | #else 11 | #define NGX_CASA ngx_casxa 12 | #endif 13 | 14 | 15 | ngx_atomic_uint_t 16 | ngx_casa(ngx_atomic_uint_t set, ngx_atomic_uint_t old, ngx_atomic_t *lock); 17 | 18 | ngx_atomic_uint_t 19 | ngx_casxa(ngx_atomic_uint_t set, ngx_atomic_uint_t old, ngx_atomic_t *lock); 20 | 21 | /* the code in src/os/unix/ngx_sunpro_sparc64.il */ 22 | 23 | 24 | static ngx_inline ngx_atomic_uint_t 25 | ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old, 26 | ngx_atomic_uint_t set) 27 | { 28 | set = NGX_CASA(set, old, lock); 29 | 30 | return (set == old); 31 | } 32 | 33 | 34 | static ngx_inline ngx_atomic_int_t 35 | ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add) 36 | { 37 | ngx_atomic_uint_t old, res; 38 | 39 | old = *value; 40 | 41 | for ( ;; ) { 42 | 43 | res = old + add; 44 | 45 | res = NGX_CASA(res, old, value); 46 | 47 | if (res == old) { 48 | return res; 49 | } 50 | 51 | old = res; 52 | } 53 | } 54 | 55 | 56 | #define ngx_memory_barrier() \ 57 | __asm (".volatile"); \ 58 | __asm ("membar #LoadLoad | #LoadStore | #StoreStore | #StoreLoad"); \ 59 | __asm (".nonvolatile") 60 | 61 | #define ngx_cpu_pause() 62 | -------------------------------------------------------------------------------- /src/os/unix/ngx_sunpro_sparc64.il: -------------------------------------------------------------------------------- 1 | / 2 | / Copyright (C) Igor Sysoev 3 | / Copyright (C) Nginx, Inc. 4 | / 5 | 6 | 7 | / "casa [%o2] 0x80, %o1, %o0" and 8 | / "casxa [%o2] 0x80, %o1, %o0" do the following: 9 | / 10 | / if ([%o2] == %o1) { 11 | / swap(%o0, [%o2]); 12 | / } else { 13 | / %o0 = [%o2]; 14 | / } 15 | 16 | 17 | / ngx_atomic_uint_t ngx_casa(ngx_atomic_uint_t set, ngx_atomic_uint_t old, 18 | / ngx_atomic_t *lock); 19 | / 20 | / the arguments are passed in the %o0, %o1, %o2 21 | / the result is returned in the %o0 22 | 23 | .inline ngx_casa,0 24 | casa [%o2] 0x80, %o1, %o0 25 | .end 26 | 27 | 28 | / ngx_atomic_uint_t ngx_casxa(ngx_atomic_uint_t set, ngx_atomic_uint_t old, 29 | / ngx_atomic_t *lock); 30 | / 31 | / the arguments are passed in the %o0, %o1, %o2 32 | / the result is returned in the %o0 33 | 34 | .inline ngx_casxa,0 35 | casxa [%o2] 0x80, %o1, %o0 36 | .end 37 | -------------------------------------------------------------------------------- /src/os/unix/ngx_sunpro_x86.il: -------------------------------------------------------------------------------- 1 | / 2 | / Copyright (C) Igor Sysoev 3 | / Copyright (C) Nginx, Inc. 4 | / 5 | 6 | / ngx_atomic_uint_t ngx_atomic_cmp_set(ngx_atomic_t *lock, 7 | / ngx_atomic_uint_t old, ngx_atomic_uint_t set); 8 | / 9 | / the arguments are passed on stack (%esp), 4(%esp), 8(%esp) 10 | 11 | .inline ngx_atomic_cmp_set,0 12 | movl (%esp), %ecx 13 | movl 4(%esp), %eax 14 | movl 8(%esp), %edx 15 | lock 16 | cmpxchgl %edx, (%ecx) 17 | setz %al 18 | movzbl %al, %eax 19 | .end 20 | 21 | 22 | / ngx_atomic_int_t ngx_atomic_fetch_add(ngx_atomic_t *value, 23 | / ngx_atomic_int_t add); 24 | / 25 | / the arguments are passed on stack (%esp), 4(%esp) 26 | 27 | .inline ngx_atomic_fetch_add,0 28 | movl (%esp), %ecx 29 | movl 4(%esp), %eax 30 | lock 31 | xaddl %eax, (%ecx) 32 | .end 33 | 34 | 35 | / ngx_cpu_pause() 36 | / 37 | / the "rep; nop" is used instead of "pause" to avoid the "[ PAUSE ]" hardware 38 | / capability added by linker because Solaris/i386 does not know about it: 39 | / 40 | / ld.so.1: nginx: fatal: hardware capability unsupported: 0x2000 [ PAUSE ] 41 | 42 | .inline ngx_cpu_pause,0 43 | rep; nop 44 | .end 45 | -------------------------------------------------------------------------------- /src/os/unix/ngx_time.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | /* 13 | * FreeBSD does not test /etc/localtime change, however, we can workaround it 14 | * by calling tzset() with TZ and then without TZ to update timezone. 15 | * The trick should work since FreeBSD 2.1.0. 16 | * 17 | * Linux does not test /etc/localtime change in localtime(), 18 | * but may stat("/etc/localtime") several times in every strftime(), 19 | * therefore we use it to update timezone. 20 | * 21 | * Solaris does not test /etc/TIMEZONE change too and no workaround available. 22 | */ 23 | 24 | void 25 | ngx_timezone_update(void) 26 | { 27 | #if (NGX_FREEBSD) 28 | 29 | if (getenv("TZ")) { 30 | return; 31 | } 32 | 33 | putenv("TZ=UTC"); 34 | 35 | tzset(); 36 | 37 | unsetenv("TZ"); 38 | 39 | tzset(); 40 | 41 | #elif (NGX_LINUX) 42 | time_t s; 43 | struct tm *t; 44 | char buf[4]; 45 | 46 | s = time(0); 47 | 48 | t = localtime(&s); 49 | 50 | strftime(buf, 4, "%H", t); 51 | 52 | #endif 53 | } 54 | 55 | 56 | void 57 | ngx_localtime(time_t s, ngx_tm_t *tm) 58 | { 59 | #if (NGX_HAVE_LOCALTIME_R) 60 | (void) localtime_r(&s, tm); 61 | 62 | #else 63 | ngx_tm_t *t; 64 | 65 | t = localtime(&s); 66 | *tm = *t; 67 | 68 | #endif 69 | 70 | tm->ngx_tm_mon++; 71 | tm->ngx_tm_year += 1900; 72 | } 73 | 74 | 75 | void 76 | ngx_libc_localtime(time_t s, struct tm *tm) 77 | { 78 | #if (NGX_HAVE_LOCALTIME_R) 79 | (void) localtime_r(&s, tm); 80 | 81 | #else 82 | struct tm *t; 83 | 84 | t = localtime(&s); 85 | *tm = *t; 86 | 87 | #endif 88 | } 89 | 90 | 91 | void 92 | ngx_libc_gmtime(time_t s, struct tm *tm) 93 | { 94 | #if (NGX_HAVE_LOCALTIME_R) 95 | (void) gmtime_r(&s, tm); 96 | 97 | #else 98 | struct tm *t; 99 | 100 | t = gmtime(&s); 101 | *tm = *t; 102 | 103 | #endif 104 | } 105 | -------------------------------------------------------------------------------- /src/os/unix/ngx_time.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_TIME_H_INCLUDED_ 9 | #define _NGX_TIME_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | typedef ngx_rbtree_key_t ngx_msec_t; 17 | typedef ngx_rbtree_key_int_t ngx_msec_int_t; 18 | 19 | typedef struct tm ngx_tm_t; 20 | 21 | #define ngx_tm_sec tm_sec 22 | #define ngx_tm_min tm_min 23 | #define ngx_tm_hour tm_hour 24 | #define ngx_tm_mday tm_mday 25 | #define ngx_tm_mon tm_mon 26 | #define ngx_tm_year tm_year 27 | #define ngx_tm_wday tm_wday 28 | #define ngx_tm_isdst tm_isdst 29 | 30 | #define ngx_tm_sec_t int 31 | #define ngx_tm_min_t int 32 | #define ngx_tm_hour_t int 33 | #define ngx_tm_mday_t int 34 | #define ngx_tm_mon_t int 35 | #define ngx_tm_year_t int 36 | #define ngx_tm_wday_t int 37 | 38 | 39 | #if (NGX_HAVE_GMTOFF) 40 | #define ngx_tm_gmtoff tm_gmtoff 41 | #define ngx_tm_zone tm_zone 42 | #endif 43 | 44 | 45 | #if (NGX_SOLARIS) 46 | 47 | #define ngx_timezone(isdst) (- (isdst ? altzone : timezone) / 60) 48 | 49 | #else 50 | 51 | #define ngx_timezone(isdst) (- (isdst ? timezone + 3600 : timezone) / 60) 52 | 53 | #endif 54 | 55 | 56 | void ngx_timezone_update(void); 57 | void ngx_localtime(time_t s, ngx_tm_t *tm); 58 | void ngx_libc_localtime(time_t s, struct tm *tm); 59 | void ngx_libc_gmtime(time_t s, struct tm *tm); 60 | 61 | #define ngx_gettimeofday(tp) (void) gettimeofday(tp, NULL); 62 | #define ngx_msleep(ms) (void) usleep(ms * 1000) 63 | #define ngx_sleep(s) (void) sleep(s) 64 | 65 | 66 | #endif /* _NGX_TIME_H_INCLUDED_ */ 67 | -------------------------------------------------------------------------------- /src/os/unix/ngx_user.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_USER_H_INCLUDED_ 9 | #define _NGX_USER_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | typedef uid_t ngx_uid_t; 17 | typedef gid_t ngx_gid_t; 18 | 19 | 20 | ngx_int_t ngx_libc_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, 21 | u_char **encrypted); 22 | 23 | 24 | #endif /* _NGX_USER_H_INCLUDED_ */ 25 | -------------------------------------------------------------------------------- /src/os/unix/rfork_thread.S: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | /* 12 | * rfork_thread(3) - rfork_thread(flags, stack, func, arg); 13 | */ 14 | 15 | #define KERNCALL int $0x80 16 | 17 | ENTRY(rfork_thread) 18 | push %ebp 19 | mov %esp, %ebp 20 | push %esi 21 | 22 | mov 12(%ebp), %esi # the thread stack address 23 | 24 | sub $4, %esi 25 | mov 20(%ebp), %eax # the thread argument 26 | mov %eax, (%esi) 27 | 28 | sub $4, %esi 29 | mov 16(%ebp), %eax # the thread start address 30 | mov %eax, (%esi) 31 | 32 | push 8(%ebp) # rfork(2) flags 33 | push $0 34 | mov $SYS_rfork, %eax 35 | KERNCALL 36 | jc error 37 | 38 | cmp $0, %edx 39 | jne child 40 | 41 | parent: 42 | add $8, %esp 43 | pop %esi 44 | leave 45 | ret 46 | 47 | child: 48 | mov %esi, %esp 49 | pop %eax 50 | call *%eax # call a thread start address ... 51 | add $4, %esp 52 | 53 | push %eax 54 | push $0 55 | mov $SYS_exit, %eax # ... and exit(2) after a thread would return 56 | KERNCALL 57 | 58 | error: 59 | add $8, %esp 60 | pop %esi 61 | leave 62 | PIC_PROLOGUE 63 | 64 | /* libc's cerror: jmp PIC_PLT(HIDENAME(cerror)) */ 65 | 66 | push %eax 67 | call PIC_PLT(CNAME(__error)) 68 | pop %ecx 69 | PIC_EPILOGUE 70 | mov %ecx, (%eax) 71 | mov $-1, %eax 72 | mov $-1, %edx 73 | ret 74 | -------------------------------------------------------------------------------- /src/os/win32/nginx.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexStocks/nginx-vs2015/1af691e4bbfc057298d105f6b7476a123e2fab99/src/os/win32/nginx.ico -------------------------------------------------------------------------------- /src/os/win32/nginx.rc: -------------------------------------------------------------------------------- 1 | 2 | // Copyright (C) Igor Sysoev 3 | // Copyright (C) Nginx, Inc. 4 | 5 | 6 | nginx icon discardable "src\\os\\win32\\nginx.ico" 7 | -------------------------------------------------------------------------------- /src/os/win32/nginx_icon16.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char * nginx_xpm[] = { 3 | "16 16 2 2", 4 | /* colors */ 5 | " c none", 6 | "GG c #009900", 7 | /* pixels */ 8 | " ", 9 | " GGGGGGGGGGGGGGGG ", 10 | " GGGGGGGGGGGGGGGG ", 11 | " GGGGGGGGGGGGGGGGGGGG ", 12 | " GGGGGG GGGGGG ", 13 | " GGGGGG GGGGGG ", 14 | " GGGGGG ", 15 | " GGGGGG GGGGGGGGGGGGGGGG ", 16 | " GGGGGG GGGGGGGGGGGGGGGGGG ", 17 | " GGGGGG GGGGGGGGGGGGGG ", 18 | " GGGGGG GGGGGG ", 19 | " GGGGGG GGGGGG ", 20 | " GGGGGGGGGGGGGGGGGGGG ", 21 | " GGGGGGGGGGGGGGGG ", 22 | " GGGGGGGGGGGGGGGG ", 23 | " " 24 | }; 25 | -------------------------------------------------------------------------------- /src/os/win32/nginx_icon32.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char * nginx_xpm[] = { 3 | "32 32 2 2", 4 | /* colors */ 5 | " c none", 6 | "GG c #009900", 7 | /* pixels */ 8 | " ", 9 | " ", 10 | " ", 11 | " ", 12 | " GGGGGGGGGGGGGGGGGGGGGGGGGGGG ", 13 | " GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG ", 14 | " GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG ", 15 | " GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG ", 16 | " GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG ", 17 | " GGGGGGGGGG GGGGGGGGGG ", 18 | " GGGGGGGGGG GGGGGGGGGG ", 19 | " GGGGGGGGGG GGGGGGGGGG ", 20 | " GGGGGGGGGG GGGGGGGGGG ", 21 | " GGGGGGGGGG ", 22 | " GGGGGGGGGG ", 23 | " GGGGGGGGGG GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG ", 24 | " GGGGGGGGGG GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG ", 25 | " GGGGGGGGGG GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG ", 26 | " GGGGGGGGGG GGGGGGGGGGGGGGGGGGGGGGGGGGGGGG ", 27 | " GGGGGGGGGG GGGGGGGGGGGGGGGGGGGGGGGGGG ", 28 | " GGGGGGGGGG GGGGGGGGGG ", 29 | " GGGGGGGGGG GGGGGGGGGG ", 30 | " GGGGGGGGGG GGGGGGGGGG ", 31 | " GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG ", 32 | " GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG ", 33 | " GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG ", 34 | " GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG ", 35 | " GGGGGGGGGGGGGGGGGGGGGGGGGGGG ", 36 | " ", 37 | " ", 38 | " ", 39 | " " 40 | -------------------------------------------------------------------------------- /src/os/win32/ngx_alloc.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | ngx_uint_t ngx_pagesize; 13 | ngx_uint_t ngx_pagesize_shift; 14 | ngx_uint_t ngx_cacheline_size; 15 | 16 | 17 | void *ngx_alloc(size_t size, ngx_log_t *log) 18 | { 19 | void *p; 20 | 21 | p = malloc(size); 22 | if (p == NULL) { 23 | ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, 24 | "malloc(%uz) failed", size); 25 | } 26 | 27 | ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0, "malloc: %p:%uz", p, size); 28 | 29 | return p; 30 | } 31 | 32 | 33 | void *ngx_calloc(size_t size, ngx_log_t *log) 34 | { 35 | void *p; 36 | 37 | p = ngx_alloc(size, log); 38 | 39 | if (p) { 40 | ngx_memzero(p, size); 41 | } 42 | 43 | return p; 44 | } 45 | -------------------------------------------------------------------------------- /src/os/win32/ngx_alloc.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_ALLOC_H_INCLUDED_ 9 | #define _NGX_ALLOC_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | void *ngx_alloc(size_t size, ngx_log_t *log); 17 | void *ngx_calloc(size_t size, ngx_log_t *log); 18 | 19 | #define ngx_free free 20 | #define ngx_memalign(alignment, size, log) ngx_alloc(size, log) 21 | 22 | extern ngx_uint_t ngx_pagesize; 23 | extern ngx_uint_t ngx_pagesize_shift; 24 | extern ngx_uint_t ngx_cacheline_size; 25 | 26 | 27 | #endif /* _NGX_ALLOC_H_INCLUDED_ */ 28 | -------------------------------------------------------------------------------- /src/os/win32/ngx_atomic.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_ATOMIC_H_INCLUDED_ 9 | #define _NGX_ATOMIC_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | #define NGX_HAVE_ATOMIC_OPS 1 17 | 18 | typedef int32_t ngx_atomic_int_t; 19 | typedef uint32_t ngx_atomic_uint_t; 20 | typedef volatile ngx_atomic_uint_t ngx_atomic_t; 21 | #define NGX_ATOMIC_T_LEN (sizeof("-2147483648") - 1) 22 | 23 | 24 | #if defined( __WATCOMC__ ) || defined( __BORLANDC__ ) || defined(__GNUC__) \ 25 | || ( _MSC_VER >= 1300 ) 26 | 27 | /* the new SDK headers */ 28 | 29 | #define ngx_atomic_cmp_set(lock, old, set) \ 30 | ((ngx_atomic_uint_t) InterlockedCompareExchange((long *) lock, set, old) \ 31 | == old) 32 | 33 | #else 34 | 35 | /* the old MS VC6.0SP2 SDK headers */ 36 | 37 | #define ngx_atomic_cmp_set(lock, old, set) \ 38 | (InterlockedCompareExchange((void **) lock, (void *) set, (void *) old) \ 39 | == (void *) old) 40 | 41 | #endif 42 | 43 | 44 | #define ngx_atomic_fetch_add(p, add) InterlockedExchangeAdd((long *) p, add) 45 | 46 | 47 | #define ngx_memory_barrier() 48 | 49 | 50 | #if defined( __BORLANDC__ ) || ( __WATCOMC__ < 1230 ) 51 | 52 | /* 53 | * Borland C++ 5.5 (tasm32) and Open Watcom C prior to 1.3 54 | * do not understand the "pause" instruction 55 | */ 56 | 57 | #define ngx_cpu_pause() 58 | #else 59 | #define ngx_cpu_pause() __asm { pause } 60 | #endif 61 | 62 | 63 | void ngx_spinlock(ngx_atomic_t *lock, ngx_atomic_int_t value, ngx_uint_t spin); 64 | 65 | #define ngx_trylock(lock) (*(lock) == 0 && ngx_atomic_cmp_set(lock, 0, 1)) 66 | #define ngx_unlock(lock) *(lock) = 0 67 | 68 | 69 | #endif /* _NGX_ATOMIC_H_INCLUDED_ */ 70 | -------------------------------------------------------------------------------- /src/os/win32/ngx_errno.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | u_char * 13 | ngx_strerror(ngx_err_t err, u_char *errstr, size_t size) 14 | { 15 | u_int len; 16 | static u_long lang = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); 17 | 18 | if (size == 0) { 19 | return errstr; 20 | } 21 | 22 | len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 23 | NULL, err, lang, (char *) errstr, size, NULL); 24 | 25 | if (len == 0 && lang && GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND) { 26 | 27 | /* 28 | * Try to use English messages first and fallback to a language, 29 | * based on locale: non-English Windows have no English messages 30 | * at all. This way allows to use English messages at least on 31 | * Windows with MUI. 32 | */ 33 | 34 | lang = 0; 35 | 36 | len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 37 | NULL, err, lang, (char *) errstr, size, NULL); 38 | } 39 | 40 | if (len == 0) { 41 | return ngx_snprintf(errstr, size, 42 | "FormatMessage() error:(%d)", GetLastError()); 43 | } 44 | 45 | /* remove ".\r\n\0" */ 46 | while (errstr[len] == '\0' || errstr[len] == CR 47 | || errstr[len] == LF || errstr[len] == '.') 48 | { 49 | --len; 50 | } 51 | 52 | return &errstr[++len]; 53 | } 54 | 55 | 56 | ngx_int_t 57 | ngx_strerror_init(void) 58 | { 59 | return NGX_OK; 60 | } 61 | -------------------------------------------------------------------------------- /src/os/win32/ngx_os.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_OS_H_INCLUDED_ 9 | #define _NGX_OS_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | #define NGX_IO_SENDFILE 1 17 | 18 | 19 | typedef ssize_t (*ngx_recv_pt)(ngx_connection_t *c, u_char *buf, size_t size); 20 | typedef ssize_t (*ngx_recv_chain_pt)(ngx_connection_t *c, ngx_chain_t *in); 21 | typedef ssize_t (*ngx_send_pt)(ngx_connection_t *c, u_char *buf, size_t size); 22 | typedef ngx_chain_t *(*ngx_send_chain_pt)(ngx_connection_t *c, ngx_chain_t *in, 23 | off_t limit); 24 | 25 | typedef struct { 26 | ngx_recv_pt recv; 27 | ngx_recv_chain_pt recv_chain; 28 | ngx_recv_pt udp_recv; 29 | ngx_send_pt send; 30 | ngx_send_chain_pt send_chain; 31 | ngx_uint_t flags; 32 | } ngx_os_io_t; 33 | 34 | 35 | ngx_int_t ngx_os_init(ngx_log_t *log); 36 | void ngx_os_status(ngx_log_t *log); 37 | ngx_int_t ngx_os_signal_process(ngx_cycle_t *cycle, char *sig, ngx_int_t pid); 38 | 39 | ssize_t ngx_wsarecv(ngx_connection_t *c, u_char *buf, size_t size); 40 | ssize_t ngx_overlapped_wsarecv(ngx_connection_t *c, u_char *buf, size_t size); 41 | ssize_t ngx_udp_wsarecv(ngx_connection_t *c, u_char *buf, size_t size); 42 | ssize_t ngx_udp_overlapped_wsarecv(ngx_connection_t *c, u_char *buf, 43 | size_t size); 44 | ssize_t ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain); 45 | ssize_t ngx_wsasend(ngx_connection_t *c, u_char *buf, size_t size); 46 | ssize_t ngx_overlapped_wsasend(ngx_connection_t *c, u_char *buf, size_t size); 47 | ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, 48 | off_t limit); 49 | ngx_chain_t *ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, 50 | off_t limit); 51 | 52 | void ngx_cdecl ngx_event_log(ngx_err_t err, const char *fmt, ...); 53 | 54 | 55 | extern ngx_os_io_t ngx_os_io; 56 | extern ngx_uint_t ngx_ncpu; 57 | extern ngx_uint_t ngx_max_wsabufs; 58 | extern ngx_int_t ngx_max_sockets; 59 | extern ngx_uint_t ngx_inherited_nonblocking; 60 | extern ngx_uint_t ngx_tcp_nodelay_and_tcp_nopush; 61 | extern ngx_uint_t ngx_win32_version; 62 | extern char ngx_unique[]; 63 | 64 | 65 | #endif /* _NGX_OS_H_INCLUDED_ */ 66 | -------------------------------------------------------------------------------- /src/os/win32/ngx_process.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_PROCESS_H_INCLUDED_ 9 | #define _NGX_PROCESS_H_INCLUDED_ 10 | 11 | 12 | typedef DWORD ngx_pid_t; 13 | #define NGX_INVALID_PID 0 14 | 15 | 16 | #define ngx_getpid GetCurrentProcessId 17 | #define ngx_log_pid ngx_pid 18 | 19 | 20 | #define NGX_PROCESS_SYNC_NAME \ 21 | (sizeof("ngx_cache_manager_mutex_") + NGX_INT32_LEN) 22 | 23 | 24 | typedef struct { 25 | HANDLE handle; 26 | ngx_pid_t pid; 27 | char *name; 28 | 29 | HANDLE term; 30 | HANDLE quit; 31 | HANDLE reopen; 32 | 33 | u_char term_event[NGX_PROCESS_SYNC_NAME]; 34 | u_char quit_event[NGX_PROCESS_SYNC_NAME]; 35 | u_char reopen_event[NGX_PROCESS_SYNC_NAME]; 36 | 37 | unsigned just_spawn:1; 38 | unsigned exiting:1; 39 | } ngx_process_t; 40 | 41 | 42 | typedef struct { 43 | char *path; 44 | char *name; 45 | char *args; 46 | char *const *argv; 47 | char *const *envp; 48 | HANDLE child; 49 | } ngx_exec_ctx_t; 50 | 51 | 52 | ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle, char *name, ngx_int_t respawn); 53 | ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx); 54 | 55 | #define ngx_debug_point() 56 | #define ngx_sched_yield() SwitchToThread() 57 | 58 | 59 | #define NGX_MAX_PROCESSES (MAXIMUM_WAIT_OBJECTS - 4) 60 | 61 | #define NGX_PROCESS_RESPAWN -2 62 | #define NGX_PROCESS_JUST_RESPAWN -3 63 | 64 | 65 | extern int ngx_argc; 66 | extern char **ngx_argv; 67 | extern char **ngx_os_argv; 68 | 69 | extern ngx_int_t ngx_last_process; 70 | extern ngx_process_t ngx_processes[NGX_MAX_PROCESSES]; 71 | 72 | extern ngx_pid_t ngx_pid; 73 | 74 | 75 | #endif /* _NGX_PROCESS_H_INCLUDED_ */ 76 | -------------------------------------------------------------------------------- /src/os/win32/ngx_process_cycle.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_PROCESS_CYCLE_H_INCLUDED_ 9 | #define _NGX_PROCESS_CYCLE_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | #define NGX_PROCESS_SINGLE 0 17 | #define NGX_PROCESS_MASTER 1 18 | #define NGX_PROCESS_SIGNALLER 2 19 | #define NGX_PROCESS_WORKER 3 20 | 21 | 22 | void ngx_master_process_cycle(ngx_cycle_t *cycle); 23 | void ngx_single_process_cycle(ngx_cycle_t *cycle); 24 | void ngx_close_handle(HANDLE h); 25 | 26 | 27 | extern ngx_uint_t ngx_process; 28 | extern ngx_pid_t ngx_pid; 29 | extern ngx_uint_t ngx_threaded; 30 | extern ngx_uint_t ngx_exiting; 31 | 32 | extern sig_atomic_t ngx_quit; 33 | extern sig_atomic_t ngx_terminate; 34 | extern sig_atomic_t ngx_reopen; 35 | 36 | extern ngx_uint_t ngx_inherited; 37 | extern ngx_pid_t ngx_new_binary; 38 | 39 | 40 | extern HANDLE ngx_master_process_event; 41 | extern char ngx_master_process_event_name[]; 42 | 43 | 44 | #endif /* _NGX_PROCESS_CYCLE_H_INCLUDED_ */ 45 | -------------------------------------------------------------------------------- /src/os/win32/ngx_shmem.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | ngx_int_t 13 | ngx_shm_alloc(ngx_shm_t *shm) 14 | { 15 | u_char *name; 16 | uint64_t size; 17 | 18 | name = ngx_alloc(shm->name.len + 2 + NGX_INT32_LEN, shm->log); 19 | if (name == NULL) { 20 | return NGX_ERROR; 21 | } 22 | 23 | (void) ngx_sprintf(name, "%V_%s%Z", &shm->name, ngx_unique); 24 | 25 | ngx_set_errno(0); 26 | 27 | size = shm->size; 28 | 29 | shm->handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 30 | (u_long) (size >> 32), 31 | (u_long) (size & 0xffffffff), 32 | (char *) name); 33 | 34 | if (shm->handle == NULL) { 35 | ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, 36 | "CreateFileMapping(%uz, %s) failed", 37 | shm->size, name); 38 | ngx_free(name); 39 | 40 | return NGX_ERROR; 41 | } 42 | 43 | ngx_free(name); 44 | 45 | if (ngx_errno == ERROR_ALREADY_EXISTS) { 46 | shm->exists = 1; 47 | } 48 | 49 | shm->addr = MapViewOfFile(shm->handle, FILE_MAP_WRITE, 0, 0, 0); 50 | 51 | if (shm->addr != NULL) { 52 | return NGX_OK; 53 | } 54 | 55 | ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, 56 | "MapViewOfFile(%uz) of file mapping \"%V\" failed", 57 | shm->size, &shm->name); 58 | 59 | if (CloseHandle(shm->handle) == 0) { 60 | ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, 61 | "CloseHandle() of file mapping \"%V\" failed", 62 | &shm->name); 63 | } 64 | 65 | return NGX_ERROR; 66 | } 67 | 68 | 69 | void 70 | ngx_shm_free(ngx_shm_t *shm) 71 | { 72 | if (UnmapViewOfFile(shm->addr) == 0) { 73 | ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, 74 | "UnmapViewOfFile(%p) of file mapping \"%V\" failed", 75 | shm->addr, &shm->name); 76 | } 77 | 78 | if (CloseHandle(shm->handle) == 0) { 79 | ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, 80 | "CloseHandle() of file mapping \"%V\" failed", 81 | &shm->name); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/os/win32/ngx_shmem.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_SHMEM_H_INCLUDED_ 9 | #define _NGX_SHMEM_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | typedef struct { 17 | u_char *addr; 18 | size_t size; 19 | ngx_str_t name; 20 | HANDLE handle; 21 | ngx_log_t *log; 22 | ngx_uint_t exists; /* unsigned exists:1; */ 23 | } ngx_shm_t; 24 | 25 | 26 | ngx_int_t ngx_shm_alloc(ngx_shm_t *shm); 27 | void ngx_shm_free(ngx_shm_t *shm); 28 | 29 | 30 | #endif /* _NGX_SHMEM_H_INCLUDED_ */ 31 | -------------------------------------------------------------------------------- /src/os/win32/ngx_socket.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | int 13 | ngx_nonblocking(ngx_socket_t s) 14 | { 15 | unsigned long nb = 1; 16 | 17 | return ioctlsocket(s, FIONBIO, &nb); 18 | } 19 | 20 | 21 | int 22 | ngx_blocking(ngx_socket_t s) 23 | { 24 | unsigned long nb = 0; 25 | 26 | return ioctlsocket(s, FIONBIO, &nb); 27 | } 28 | 29 | 30 | int 31 | ngx_tcp_push(ngx_socket_t s) 32 | { 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /src/os/win32/ngx_stat.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | int ngx_file_type(char *file, ngx_file_info_t *sb) 13 | { 14 | sb->dwFileAttributes = GetFileAttributes(file); 15 | 16 | if (sb->dwFileAttributes == INVALID_FILE_ATTRIBUTES) { 17 | return -1; 18 | } 19 | 20 | return 0; 21 | } 22 | 23 | /* 24 | int ngx_stat(char *file, ngx_stat_t *sb) 25 | { 26 | *sb = GetFileAttributes(file); 27 | 28 | if (*sb == INVALID_FILE_ATTRIBUTES) { 29 | return -1; 30 | } 31 | 32 | return 0; 33 | } 34 | */ 35 | -------------------------------------------------------------------------------- /src/os/win32/ngx_thread.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | ngx_int_t ngx_threads_n; 13 | 14 | 15 | static size_t stack_size; 16 | 17 | 18 | ngx_err_t 19 | ngx_create_thread(ngx_tid_t *tid, 20 | ngx_thread_value_t (__stdcall *func)(void *arg), void *arg, ngx_log_t *log) 21 | { 22 | u_long id; 23 | ngx_err_t err; 24 | 25 | *tid = CreateThread(NULL, stack_size, func, arg, 0, &id); 26 | 27 | if (*tid != NULL) { 28 | ngx_log_error(NGX_LOG_NOTICE, log, 0, 29 | "create thread " NGX_TID_T_FMT, id); 30 | return 0; 31 | } 32 | 33 | err = ngx_errno; 34 | ngx_log_error(NGX_LOG_ALERT, log, err, "CreateThread() failed"); 35 | return err; 36 | } 37 | 38 | 39 | ngx_int_t 40 | ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle) 41 | { 42 | stack_size = size; 43 | 44 | return NGX_OK; 45 | } 46 | 47 | 48 | ngx_err_t 49 | ngx_thread_key_create(ngx_tls_key_t *key) 50 | { 51 | *key = TlsAlloc(); 52 | 53 | if (*key == TLS_OUT_OF_INDEXES) { 54 | return ngx_errno; 55 | } 56 | 57 | return 0; 58 | } 59 | 60 | 61 | ngx_err_t 62 | ngx_thread_set_tls(ngx_tls_key_t *key, void *data) 63 | { 64 | if (TlsSetValue(*key, data) == 0) { 65 | return ngx_errno; 66 | } 67 | 68 | return 0; 69 | } 70 | 71 | 72 | ngx_mutex_t * 73 | ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags) 74 | { 75 | ngx_mutex_t *m; 76 | 77 | m = ngx_alloc(sizeof(ngx_mutex_t), log); 78 | if (m == NULL) { 79 | return NULL; 80 | } 81 | 82 | m->log = log; 83 | 84 | /* STUB */ 85 | 86 | return m; 87 | } 88 | 89 | 90 | /* STUB */ 91 | 92 | void 93 | ngx_mutex_lock(ngx_mutex_t *m) { 94 | return; 95 | } 96 | 97 | 98 | 99 | ngx_int_t 100 | ngx_mutex_trylock(ngx_mutex_t *m) { 101 | return NGX_OK; 102 | } 103 | 104 | 105 | void 106 | ngx_mutex_unlock(ngx_mutex_t *m) { 107 | return; 108 | } 109 | 110 | /**/ 111 | -------------------------------------------------------------------------------- /src/os/win32/ngx_thread.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_THREAD_H_INCLUDED_ 9 | #define _NGX_THREAD_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | typedef HANDLE ngx_tid_t; 17 | typedef DWORD ngx_tls_key_t; 18 | typedef DWORD ngx_thread_value_t; 19 | 20 | 21 | typedef struct { 22 | HANDLE mutex; 23 | ngx_log_t *log; 24 | } ngx_mutex_t; 25 | 26 | 27 | ngx_err_t ngx_create_thread(ngx_tid_t *tid, 28 | ngx_thread_value_t (__stdcall *func)(void *arg), void *arg, ngx_log_t *log); 29 | ngx_int_t ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle); 30 | 31 | ngx_err_t ngx_thread_key_create(ngx_tls_key_t *key); 32 | #define ngx_thread_key_create_n "TlsAlloc()" 33 | ngx_err_t ngx_thread_set_tls(ngx_tls_key_t *key, void *data); 34 | #define ngx_thread_set_tls_n "TlsSetValue()" 35 | #define ngx_thread_get_tls TlsGetValue 36 | 37 | 38 | #define ngx_thread_volatile volatile 39 | 40 | #define ngx_log_tid GetCurrentThreadId() 41 | #define NGX_TID_T_FMT "%ud" 42 | 43 | 44 | ngx_mutex_t *ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags); 45 | 46 | void ngx_mutex_lock(ngx_mutex_t *m); 47 | ngx_int_t ngx_mutex_trylock(ngx_mutex_t *m); 48 | void ngx_mutex_unlock(ngx_mutex_t *m); 49 | 50 | 51 | /* STUB */ 52 | #define NGX_MUTEX_LIGHT 0 53 | /**/ 54 | 55 | 56 | extern ngx_int_t ngx_threads_n; 57 | 58 | 59 | #endif /* _NGX_THREAD_H_INCLUDED_ */ 60 | -------------------------------------------------------------------------------- /src/os/win32/ngx_time.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | 11 | 12 | void 13 | ngx_gettimeofday(struct timeval *tp) 14 | { 15 | uint64_t intervals; 16 | FILETIME ft; 17 | 18 | GetSystemTimeAsFileTime(&ft); 19 | 20 | /* 21 | * A file time is a 64-bit value that represents the number 22 | * of 100-nanosecond intervals that have elapsed since 23 | * January 1, 1601 12:00 A.M. UTC. 24 | * 25 | * Between January 1, 1970 (Epoch) and January 1, 1601 there were 26 | * 134744 days, 27 | * 11644473600 seconds or 28 | * 11644473600,000,000,0 100-nanosecond intervals. 29 | * 30 | * See also MSKB Q167296. 31 | */ 32 | 33 | intervals = ((uint64_t) ft.dwHighDateTime << 32) | ft.dwLowDateTime; 34 | intervals -= 116444736000000000; 35 | 36 | tp->tv_sec = (long) (intervals / 10000000); 37 | tp->tv_usec = (long) ((intervals % 10000000) / 10); 38 | } 39 | 40 | 41 | void 42 | ngx_libc_localtime(time_t s, struct tm *tm) 43 | { 44 | struct tm *t; 45 | 46 | t = localtime(&s); 47 | *tm = *t; 48 | } 49 | 50 | 51 | void 52 | ngx_libc_gmtime(time_t s, struct tm *tm) 53 | { 54 | struct tm *t; 55 | 56 | t = gmtime(&s); 57 | *tm = *t; 58 | } 59 | 60 | 61 | ngx_int_t 62 | ngx_gettimezone(void) 63 | { 64 | u_long n; 65 | TIME_ZONE_INFORMATION tz; 66 | 67 | n = GetTimeZoneInformation(&tz); 68 | 69 | switch (n) { 70 | 71 | case TIME_ZONE_ID_UNKNOWN: 72 | return -tz.Bias; 73 | 74 | case TIME_ZONE_ID_STANDARD: 75 | return -(tz.Bias + tz.StandardBias); 76 | 77 | case TIME_ZONE_ID_DAYLIGHT: 78 | return -(tz.Bias + tz.DaylightBias); 79 | 80 | default: /* TIME_ZONE_ID_INVALID */ 81 | return 0; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/os/win32/ngx_time.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_TIME_H_INCLUDED_ 9 | #define _NGX_TIME_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | typedef ngx_rbtree_key_t ngx_msec_t; 17 | typedef ngx_rbtree_key_int_t ngx_msec_int_t; 18 | 19 | typedef SYSTEMTIME ngx_tm_t; 20 | typedef FILETIME ngx_mtime_t; 21 | 22 | #define ngx_tm_sec wSecond 23 | #define ngx_tm_min wMinute 24 | #define ngx_tm_hour wHour 25 | #define ngx_tm_mday wDay 26 | #define ngx_tm_mon wMonth 27 | #define ngx_tm_year wYear 28 | #define ngx_tm_wday wDayOfWeek 29 | 30 | #define ngx_tm_sec_t u_short 31 | #define ngx_tm_min_t u_short 32 | #define ngx_tm_hour_t u_short 33 | #define ngx_tm_mday_t u_short 34 | #define ngx_tm_mon_t u_short 35 | #define ngx_tm_year_t u_short 36 | #define ngx_tm_wday_t u_short 37 | 38 | 39 | #define ngx_msleep Sleep 40 | 41 | #define NGX_HAVE_GETTIMEZONE 1 42 | 43 | #define ngx_timezone_update() 44 | 45 | ngx_int_t ngx_gettimezone(void); 46 | void ngx_libc_localtime(time_t s, struct tm *tm); 47 | void ngx_libc_gmtime(time_t s, struct tm *tm); 48 | void ngx_gettimeofday(struct timeval *tp); 49 | 50 | 51 | #endif /* _NGX_TIME_H_INCLUDED_ */ 52 | -------------------------------------------------------------------------------- /src/os/win32/ngx_user.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Igor Sysoev 3 | * Copyright (C) Nginx, Inc. 4 | */ 5 | 6 | 7 | #include 8 | #include 9 | 10 | 11 | #if (NGX_CRYPT) 12 | 13 | ngx_int_t 14 | ngx_libc_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted) 15 | { 16 | /* STUB: a plain text password */ 17 | 18 | *encrypted = key; 19 | 20 | return NGX_OK; 21 | } 22 | 23 | #endif /* NGX_CRYPT */ 24 | -------------------------------------------------------------------------------- /src/os/win32/ngx_user.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #ifndef _NGX_USER_H_INCLUDED_ 9 | #define _NGX_USER_H_INCLUDED_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | /* STUB */ 17 | #define ngx_uid_t ngx_int_t 18 | #define ngx_gid_t ngx_int_t 19 | 20 | 21 | ngx_int_t ngx_libc_crypt(ngx_pool_t *pool, u_char *key, u_char *salt, 22 | u_char **encrypted); 23 | 24 | 25 | #endif /* _NGX_USER_H_INCLUDED_ */ 26 | -------------------------------------------------------------------------------- /src/os/win32/ngx_wsarecv_chain.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) Igor Sysoev 4 | * Copyright (C) Nginx, Inc. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | #define NGX_WSABUFS 8 14 | 15 | 16 | ssize_t 17 | ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain) 18 | { 19 | int rc; 20 | u_char *prev; 21 | u_long bytes, flags; 22 | size_t size; 23 | ngx_err_t err; 24 | ngx_array_t vec; 25 | ngx_event_t *rev; 26 | LPWSABUF wsabuf; 27 | WSABUF wsabufs[NGX_WSABUFS]; 28 | 29 | prev = NULL; 30 | wsabuf = NULL; 31 | flags = 0; 32 | size = 0; 33 | bytes = 0; 34 | 35 | vec.elts = wsabufs; 36 | vec.nelts = 0; 37 | vec.size = sizeof(WSABUF); 38 | vec.nalloc = NGX_WSABUFS; 39 | vec.pool = c->pool; 40 | 41 | /* coalesce the neighbouring bufs */ 42 | 43 | while (chain) { 44 | if (prev == chain->buf->last) { 45 | wsabuf->len += chain->buf->end - chain->buf->last; 46 | 47 | } else { 48 | wsabuf = ngx_array_push(&vec); 49 | if (wsabuf == NULL) { 50 | return NGX_ERROR; 51 | } 52 | 53 | wsabuf->buf = (char *) chain->buf->last; 54 | wsabuf->len = chain->buf->end - chain->buf->last; 55 | } 56 | 57 | size += chain->buf->end - chain->buf->last; 58 | prev = chain->buf->end; 59 | chain = chain->next; 60 | } 61 | 62 | ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, 63 | "WSARecv: %d:%d", vec.nelts, wsabuf->len); 64 | 65 | 66 | rc = WSARecv(c->fd, vec.elts, vec.nelts, &bytes, &flags, NULL, NULL); 67 | 68 | rev = c->read; 69 | 70 | if (rc == -1) { 71 | rev->ready = 0; 72 | err = ngx_socket_errno; 73 | 74 | if (err == WSAEWOULDBLOCK) { 75 | ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err, 76 | "WSARecv() not ready"); 77 | return NGX_AGAIN; 78 | } 79 | 80 | rev->error = 1; 81 | ngx_connection_error(c, err, "WSARecv() failed"); 82 | return NGX_ERROR; 83 | } 84 | 85 | if (bytes < size) { 86 | rev->ready = 0; 87 | } 88 | 89 | if (bytes == 0) { 90 | rev->eof = 1; 91 | } 92 | 93 | return bytes; 94 | } 95 | -------------------------------------------------------------------------------- /win/conf/fastcgi.conf: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 3 | fastcgi_param QUERY_STRING $query_string; 4 | fastcgi_param REQUEST_METHOD $request_method; 5 | fastcgi_param CONTENT_TYPE $content_type; 6 | fastcgi_param CONTENT_LENGTH $content_length; 7 | 8 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 9 | fastcgi_param REQUEST_URI $request_uri; 10 | fastcgi_param DOCUMENT_URI $document_uri; 11 | fastcgi_param DOCUMENT_ROOT $document_root; 12 | fastcgi_param SERVER_PROTOCOL $server_protocol; 13 | fastcgi_param HTTPS $https if_not_empty; 14 | 15 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 16 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 17 | 18 | fastcgi_param REMOTE_ADDR $remote_addr; 19 | fastcgi_param REMOTE_PORT $remote_port; 20 | fastcgi_param SERVER_ADDR $server_addr; 21 | fastcgi_param SERVER_PORT $server_port; 22 | fastcgi_param SERVER_NAME $server_name; 23 | 24 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 25 | fastcgi_param REDIRECT_STATUS 200; 26 | -------------------------------------------------------------------------------- /win/conf/fastcgi_params: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param QUERY_STRING $query_string; 3 | fastcgi_param REQUEST_METHOD $request_method; 4 | fastcgi_param CONTENT_TYPE $content_type; 5 | fastcgi_param CONTENT_LENGTH $content_length; 6 | 7 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 8 | fastcgi_param REQUEST_URI $request_uri; 9 | fastcgi_param DOCUMENT_URI $document_uri; 10 | fastcgi_param DOCUMENT_ROOT $document_root; 11 | fastcgi_param SERVER_PROTOCOL $server_protocol; 12 | fastcgi_param HTTPS $https if_not_empty; 13 | 14 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 15 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 16 | 17 | fastcgi_param REMOTE_ADDR $remote_addr; 18 | fastcgi_param REMOTE_PORT $remote_port; 19 | fastcgi_param SERVER_ADDR $server_addr; 20 | fastcgi_param SERVER_PORT $server_port; 21 | fastcgi_param SERVER_NAME $server_name; 22 | 23 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 24 | fastcgi_param REDIRECT_STATUS 200; 25 | -------------------------------------------------------------------------------- /win/conf/scgi_params: -------------------------------------------------------------------------------- 1 | 2 | scgi_param REQUEST_METHOD $request_method; 3 | scgi_param REQUEST_URI $request_uri; 4 | scgi_param QUERY_STRING $query_string; 5 | scgi_param CONTENT_TYPE $content_type; 6 | 7 | scgi_param DOCUMENT_URI $document_uri; 8 | scgi_param DOCUMENT_ROOT $document_root; 9 | scgi_param SCGI 1; 10 | scgi_param SERVER_PROTOCOL $server_protocol; 11 | scgi_param HTTPS $https if_not_empty; 12 | 13 | scgi_param REMOTE_ADDR $remote_addr; 14 | scgi_param REMOTE_PORT $remote_port; 15 | scgi_param SERVER_PORT $server_port; 16 | scgi_param SERVER_NAME $server_name; 17 | -------------------------------------------------------------------------------- /win/conf/uwsgi_params: -------------------------------------------------------------------------------- 1 | 2 | uwsgi_param QUERY_STRING $query_string; 3 | uwsgi_param REQUEST_METHOD $request_method; 4 | uwsgi_param CONTENT_TYPE $content_type; 5 | uwsgi_param CONTENT_LENGTH $content_length; 6 | 7 | uwsgi_param REQUEST_URI $request_uri; 8 | uwsgi_param PATH_INFO $document_uri; 9 | uwsgi_param DOCUMENT_ROOT $document_root; 10 | uwsgi_param SERVER_PROTOCOL $server_protocol; 11 | uwsgi_param HTTPS $https if_not_empty; 12 | 13 | uwsgi_param REMOTE_ADDR $remote_addr; 14 | uwsgi_param REMOTE_PORT $remote_port; 15 | uwsgi_param SERVER_PORT $server_port; 16 | uwsgi_param SERVER_NAME $server_name; 17 | -------------------------------------------------------------------------------- /win/generate/ngx_auto_headers.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef NGX_WIN32 4 | #define NGX_WIN32 1 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /win/generate/ngx_pch.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /win/html/50x.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Error 5 | 12 | 13 | 14 |

An error occurred.

15 |

Sorry, the page you are looking for is currently unavailable.
16 | Please try again later.

17 |

If you are the system administrator of this resource then you should check 18 | the error log for details.

19 |

Faithfully yours, nginx.

20 | 21 | 22 | -------------------------------------------------------------------------------- /win/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Welcome to nginx! 5 | 12 | 13 | 14 |

Welcome to nginx!

15 |

If you see this page, the nginx web server is successfully installed and 16 | working. Further configuration is required.

17 | 18 |

For online documentation and support please refer to 19 | nginx.org.
20 | Commercial support is available at 21 | nginx.com.

22 | 23 |

Thank you for using nginx.

24 | 25 | 26 | -------------------------------------------------------------------------------- /win/logs/access.log: -------------------------------------------------------------------------------- 1 | 127.0.0.1 - - [17/Jul/2014:16:03:58 +0800] "GET /index.html HTTP/1.1" 200 612 "-" "Wget/1.13.4 (cygwin)" "-" 2 | 127.0.0.1 - - [17/Jul/2014:16:04:13 +0800] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0" "-" 3 | 127.0.0.1 - - [17/Jul/2014:16:04:13 +0800] "GET /favicon.ico HTTP/1.1" 404 168 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0" "-" 4 | 127.0.0.1 - - [17/Jul/2014:16:04:13 +0800] "GET /favicon.ico HTTP/1.1" 404 168 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0" "-" 5 | 127.0.0.1 - - [17/Jul/2014:16:04:21 +0800] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0" "-" 6 | 127.0.0.1 - - [17/Jul/2014:19:08:53 +0800] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0" "-" 7 | 127.0.0.1 - - [17/Jul/2014:19:08:53 +0800] "GET /favicon.ico HTTP/1.1" 404 168 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0" "-" 8 | 127.0.0.1 - - [17/Jul/2014:19:08:53 +0800] "GET /favicon.ico HTTP/1.1" 404 168 "-" "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0" "-" 9 | -------------------------------------------------------------------------------- /win/logs/error.log: -------------------------------------------------------------------------------- 1 | 2014/07/17 12:14:48 [emerg] 14988#10044: CreateDirectory() "client_body_temp" failed (123: The filename, directory name, or vo) 2 | 2014/07/17 12:15:11 [emerg] 6868#13560: CreateDirectory() "client_body_temp" failed (123: The filename, directory name, or vo) 3 | 2014/07/17 12:17:34 [emerg] 5868#15984: CreateDirectory() "client_body_temp" failed (123: The filename, directory name, or vo) 4 | 2014/07/17 12:19:17 [emerg] 14168#15468: CreateDirectory() "client_body_temp" failed (123: The filename, directory name, or vo) 5 | 2014/07/17 12:19:32 [emerg] 15804#15900: CreateDirectory() "client_body_temp" failed (123: The filename, directory name, or vo) 6 | 2014/07/17 12:20:17 [emerg] 15116#15848: CreateDirectory() "client_body_temp" failed (123: The filename, directory name, or vo) 7 | 2014/07/17 12:21:21 [emerg] 16248#15484: CreateDirectory() "client_body_temp" failed (123: The filename, directory name, or vo) 8 | 2014/07/17 12:21:49 [emerg] 15204#13476: CreateDirectory() "client_body_temp" failed (123: The filename, directory name, or vo) 9 | 2014/07/17 12:22:04 [emerg] 2176#14140: CreateDirectory() "client_body_temp" failed (123: The filename, directory name, or vo) 10 | 2014/07/17 16:04:13 [error] 9600#14928: *2 CreateFile() "html/favicon.ico" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1" 11 | 2014/07/17 16:04:13 [error] 9600#14928: *2 CreateFile() "html/favicon.ico" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1" 12 | 2014/07/17 19:08:53 [error] 15336#15444: *1 CreateFile() "html/favicon.ico" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost" 13 | 2014/07/17 19:08:53 [error] 15336#15444: *1 CreateFile() "html/favicon.ico" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost" 14 | -------------------------------------------------------------------------------- /win/logs/nginx.pid: -------------------------------------------------------------------------------- 1 | 5944 2 | -------------------------------------------------------------------------------- /win/nginx-1.9.9.sdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexStocks/nginx-vs2015/1af691e4bbfc057298d105f6b7476a123e2fab99/win/nginx-1.9.9.sdf --------------------------------------------------------------------------------