summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES26
-rw-r--r--CHANGES.ru25
-rw-r--r--auto/cc/bcc48
-rw-r--r--auto/cc/conf119
-rw-r--r--auto/cc/gcc109
-rw-r--r--auto/cc/icc69
-rw-r--r--auto/cc/msvc81
-rw-r--r--auto/cc/name51
-rw-r--r--auto/cc/owc82
-rw-r--r--auto/endianess2
-rw-r--r--auto/feature63
-rw-r--r--auto/fmt/fmt66
-rw-r--r--auto/fmt/ptrfmt62
-rw-r--r--auto/headers6
-rw-r--r--auto/inc35
-rw-r--r--auto/include66
-rw-r--r--auto/init42
-rw-r--r--auto/install2
-rw-r--r--auto/lib/md5/conf51
-rw-r--r--auto/lib/md5/make4
-rw-r--r--auto/lib/openssl/conf19
-rw-r--r--auto/lib/pcre/conf57
-rw-r--r--auto/lib/pcre/make6
-rw-r--r--auto/lib/test22
-rw-r--r--auto/lib/zlib/conf25
-rw-r--r--auto/lib/zlib/make4
-rw-r--r--auto/make416
-rw-r--r--auto/options71
-rw-r--r--auto/os/conf69
-rw-r--r--auto/os/freebsd28
-rw-r--r--auto/os/linux80
-rw-r--r--auto/os/solaris65
-rw-r--r--auto/os/win3229
-rw-r--r--auto/sources6
-rw-r--r--auto/stubs8
-rw-r--r--auto/types/sizeof34
-rw-r--r--auto/types/typedef50
-rw-r--r--auto/types/uintptr_t2
-rwxr-xr-xauto/unix137
-rw-r--r--conf/nginx.conf2
-rwxr-xr-xconfigure14
-rw-r--r--src/core/nginx.c39
-rw-r--r--src/core/nginx.h2
-rw-r--r--src/core/ngx_buf.c9
-rw-r--r--src/core/ngx_buf.h1
-rw-r--r--src/core/ngx_conf_file.c14
-rw-r--r--src/core/ngx_config.h18
-rw-r--r--src/core/ngx_connection.h2
-rw-r--r--src/core/ngx_core.h2
-rw-r--r--src/core/ngx_cycle.c12
-rw-r--r--src/core/ngx_log.c10
-rw-r--r--src/core/ngx_log.h12
-rw-r--r--src/core/ngx_output_chain.c36
-rw-r--r--src/core/ngx_string.c266
-rw-r--r--src/core/ngx_string.h3
-rw-r--r--src/core/ngx_times.c32
-rw-r--r--src/core/ngx_times.h4
-rw-r--r--src/event/modules/ngx_epoll_module.c2
-rw-r--r--src/event/modules/ngx_kqueue_module.c22
-rw-r--r--src/event/modules/ngx_rtsig_module.c2
-rw-r--r--src/event/ngx_event.c4
-rw-r--r--src/event/ngx_event.h8
-rw-r--r--src/event/ngx_event_accept.c6
-rw-r--r--src/event/ngx_event_connect.c6
-rw-r--r--src/event/ngx_event_openssl.c1
-rw-r--r--src/http/modules/ngx_http_charset_filter.c31
-rw-r--r--src/http/modules/ngx_http_chunked_filter.c17
-rw-r--r--src/http/modules/ngx_http_gzip_filter.c18
-rw-r--r--src/http/modules/ngx_http_headers_filter.c6
-rw-r--r--src/http/modules/ngx_http_range_filter.c47
-rw-r--r--src/http/modules/ngx_http_userid_filter.c2
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_handler.c13
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_handler.h1
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_header.c5
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_upstream.c8
-rw-r--r--src/http/ngx_http.c274
-rw-r--r--src/http/ngx_http_core_module.c48
-rw-r--r--src/http/ngx_http_core_module.h6
-rw-r--r--src/http/ngx_http_header_filter.c11
-rw-r--r--src/http/ngx_http_log_handler.c23
-rw-r--r--src/http/ngx_http_request.c87
-rw-r--r--src/http/ngx_http_request.h10
-rw-r--r--src/http/ngx_http_write_filter.c1
-rw-r--r--src/os/unix/ngx_files.c56
-rw-r--r--src/os/unix/ngx_files.h2
-rw-r--r--src/os/unix/ngx_freebsd_config.h5
-rw-r--r--src/os/unix/ngx_freebsd_sendfile_chain.c28
-rw-r--r--src/os/unix/ngx_linux_config.h8
-rw-r--r--src/os/unix/ngx_linux_sendfile_chain.c4
-rw-r--r--src/os/unix/ngx_os.h8
-rw-r--r--src/os/unix/ngx_posix_config.h53
-rw-r--r--src/os/unix/ngx_posix_init.c6
-rw-r--r--src/os/unix/ngx_process.c2
-rw-r--r--src/os/unix/ngx_process.h6
-rw-r--r--src/os/unix/ngx_process_cycle.c17
-rw-r--r--src/os/unix/ngx_readv_chain.c6
-rw-r--r--src/os/unix/ngx_recv.c6
-rw-r--r--src/os/unix/ngx_send.c2
-rw-r--r--src/os/unix/ngx_setproctitle.c4
-rw-r--r--src/os/unix/ngx_socket.c4
-rw-r--r--src/os/unix/ngx_socket.h2
-rw-r--r--src/os/unix/ngx_solaris_config.h4
-rw-r--r--src/os/unix/ngx_thread.h2
-rw-r--r--src/os/unix/ngx_time.h8
-rw-r--r--src/os/unix/ngx_writev_chain.c2
105 files changed, 2459 insertions, 1050 deletions
diff --git a/CHANGES b/CHANGES
index a88312f2c..a6c4158ab 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,28 @@
+Changes with nginx 0.1.2 21 Oct 2004
+
+ *) Feature: the --user=USER, --group=GROUP, and --with-ld-opt=OPTIONS
+ options in configure.
+
+ *) Feature: the server_name directive supports *.domain.tld.
+
+ *) Bugfix: the portability improvements.
+
+ *) Bugfix: if configuration file was set in command line, the
+ reconfiguration was impossible, bug appeared in 0.1.1.
+
+ *) Bugfix: proxy module may get caught in an endless loop when sendfile
+ is not used.
+
+ *) Bugfix: with sendfile the response was not recoded according to the
+ charset module directives, bug appeared in 0.1.1.
+
+ *) Bugfix: very seldom bug in the kqueue processing.
+
+ *) Bugfix: the gzip module compressed the proxied responses that was
+ already compressed.
+
+
Changes with nginx 0.1.1 11 Oct 2004
*) Feature: the gzip_types directive.
@@ -12,7 +36,7 @@ Changes with nginx 0.1.1 11 Oct 2004
*) Bugfix: the "Location" header rewrite bug fixed while the proxing.
- *) Bugfix: the ngx_http_chunked_module module bug fixed that caused an
+ *) Bugfix: the ngx_http_chunked_module module may get caught in an
endless loop.
*) Bugfix: the /dev/poll module bugs fixed.
diff --git a/CHANGES.ru b/CHANGES.ru
index eb447c8a5..60e947adf 100644
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,29 @@
+Изменения в nginx 0.1.2 21.10.2004
+
+ *) Добавление: параметры --user=USER, --group=GROUP и
+ --with-ld-opt=OPTIONS в configure.
+
+ *) Добавление: директива server_name поддерживает *.domain.tld.
+
+ *) Исправление: улучшена переносимость на неизвестные платформы.
+
+ *) Исправление: нельзя переконфигурировать nginx, если конфигурационный
+ файл указан в командной строке, ошибка появилась в 0.1.1.
+
+ *) Исправление: модуль проксировании мог привести к зацикливанию, если не
+ использовался sendfile.
+
+ *) Исправление: при использовании sendfile текст ответа не
+ перекодировался согласно директивам модуля charset, ошибка появилась в
+ 0.1.1.
+
+ *) Исправление: очень редкая ошибка при обработке kqueue.
+
+ *) Исправление: модуль сжатия сжимал уже сжатые ответы, полученные при
+ проксировании.
+
+
Изменения в nginx 0.1.1 11.10.2004
*) Добавление: директива gzip_types.
diff --git a/auto/cc/bcc b/auto/cc/bcc
new file mode 100644
index 000000000..5765c4713
--- /dev/null
+++ b/auto/cc/bcc
@@ -0,0 +1,48 @@
+
+# Copyright (C) Igor Sysoev
+
+
+# Borland C++ 5.5
+
+# optimizations
+
+# maximize speed
+CFLAGS="$CFLAGS -O2"
+
+case $CPU in
+ pentium)
+ # optimize for Pentium and Athlon
+ CPU_OPT="-5"
+ ;;
+
+ pentiumpro)
+ # optimize for Pentium Pro, Pentium II and Pentium III
+ CPU_OPT="-6"
+ ;;
+esac
+
+CFLAGS="$CFLAGS $CPU_OPT"
+
+# multithreaded
+CFLAGS="$CFLAGS -tWM"
+
+# stop on warning
+CFLAGS="$CFLAGS -w!"
+
+# disable logo
+CFLAGS="$CFLAGS -q"
+
+# precompiled headers
+CORE_DEPS="$CORE_DEPS $OBJS/ngx_config.csm"
+NGX_PCH="$OBJS/ngx_config.csm"
+NGX_BUILD_PCH="-H=$OBJS/ngx_config.csm"
+NGX_USE_PCH="-Hu -H=$OBJS/ngx_config.csm"
+
+LINK="\$(CC)"
+
+ngx_include_opt="-I"
+ngx_objout="-o"
+ngx_binout="-e"
+ngx_objext="obj"
+ngx_binext=".exe"
+ngx_dirsep='\\'
diff --git a/auto/cc/conf b/auto/cc/conf
new file mode 100644
index 000000000..77eeda79e
--- /dev/null
+++ b/auto/cc/conf
@@ -0,0 +1,119 @@
+
+# Copyright (C) Igor Sysoev
+
+
+ngx_include_opt="-I "
+ngx_compile_opt="-c"
+ngx_objout="-o "
+ngx_binout="-o "
+ngx_objext="o"
+ngx_binext=
+
+ngx_regex_dirsep="\/"
+ngx_dirsep='/'
+
+ngx_regex_cont=' \\\
+ '
+ngx_cont=' \
+ '
+ngx_tab=' \
+ '
+ngx_spacer=
+
+. auto/cc/name
+
+if test -n "$CFLAGS"; then
+
+ CC_TEST_FLAGS="$CFLAGS $NGX_CC_OPT"
+
+ case $NGX_CC_NAME in
+
+ ccc)
+ # Compaq C V6.5-207
+
+ ngx_include_opt="-I"
+ ;;
+
+ esac
+
+else
+
+ case $NGX_CC_NAME in
+ gcc)
+ # gcc 2.7.2.3, 2.8.1, 2.95.4,
+ # 3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4
+
+ . auto/cc/gcc
+ ;;
+
+ icc)
+ # Intel C++ compiler 7.1, 8.0
+
+ . auto/cc/icc
+ ;;
+
+# ccc)
+# # Compaq C V6.5-207
+#
+# . auto/cc/ccc
+# ;;
+
+# acc)
+# # aCC: HP ANSI C++ B3910B A.03.55.02
+#
+# . auto/cc/acc
+# ;;
+
+ msvc)
+ # MSVC 6.0 SP2
+
+ . auto/cc/msvc
+ ;;
+
+ owc)
+ # Open Watcom C 1.0, 1.2
+
+ . auto/cc/owc
+ ;;
+
+ bcc)
+ # Borland C++ 5.5
+
+ . auto/cc/bcc
+ ;;
+
+ esac
+
+ CC_TEST_FLAGS=$NGX_CC_OPT
+
+fi
+
+CFLAGS="$CFLAGS $NGX_CC_OPT"
+
+
+if [ "$PLATFORM" != win32 ]; then
+
+ ngx_feature="gcc variadic macros"
+ ngx_feature_name=HAVE_GCC_VARIADIC_MACROS
+ ngx_feature_run=yes
+ ngx_feature_incs="#include <stdio.h>
+#define var(dummy, args...) sprintf(args)"
+ ngx_feature_libs=
+ ngx_feature_test="char buf[30]; buf[0] = '0';
+ var(0, buf, \"%d\", 1);
+ if (buf[0] != '1') return 1"
+ . auto/feature
+
+
+ ngx_feature="C99 variadic macros"
+ ngx_feature_name=HAVE_C99_VARIADIC_MACROS
+ ngx_feature_run=yes
+ ngx_feature_incs="#include <stdio.h>
+#define var(dummy, ...) sprintf(__VA_ARGS__)"
+ ngx_feature_libs=
+ ngx_feature_test="char buf[30]; buf[0] = '0';
+ var(0, buf, \"%d\", 1);
+ if (buf[0] != '1') return 1"
+ . auto/feature
+
+fi
diff --git a/auto/cc/gcc b/auto/cc/gcc
new file mode 100644
index 000000000..61f048b7b
--- /dev/null
+++ b/auto/cc/gcc
@@ -0,0 +1,109 @@
+
+# Copyright (C) Igor Sysoev
+
+
+# gcc 2.7.2.3, 2.8.1, 2.95.4,
+# 3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4
+
+
+# Solaris 7's /usr/ccs/bin/as does not support "-pipe"
+
+CC_TEST_FLAGS="-pipe"
+
+ngx_feature="gcc -pipe switch"
+ngx_feature_name=
+ngx_feature_run=no
+ngx_feature_incs=
+ngx_feature_libs=
+ngx_feature_test=
+. auto/feature
+
+CC_TEST_FLAGS=
+
+if [ $ngx_found = yes ]; then
+ PIPE="-pipe"
+fi
+
+
+# optimizations
+
+#CFLAGS="$CFLAGS -O2 -fomit-frame-pointer"
+
+case $CPU in
+ pentium)
+ # optimize for Pentium and Athlon
+ CPU_OPT="-march=pentium"
+ ;;
+
+ pentiumpro)
+ # optimize for Pentium Pro, Pentium II and Pentium III
+ CPU_OPT="-march=pentiumpro"
+ ;;
+
+ pentium4)
+ # optimize for Pentium 4, gcc 3.x
+ CPU_OPT="-march=pentium4"
+ ;;
+
+ sparc64)
+ # build 64-bit UltraSparc binary
+ CPU_OPT="-m64"
+ CORE_LINK="$CORE_LINK -m64"
+ CC_AUX_FLAGS="$CC_AUX_FLAGS -m64"
+ ;;
+
+esac
+
+
+# STUB for batch builds
+if [ $CC = gcc27 ]; then CPU_OPT=; fi
+
+
+CFLAGS="$CFLAGS $PIPE $CPU_OPT"
+
+if [ ".$PCRE_OPT" = "." ]; then
+ PCRE_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
+else
+ PCRE_OPT="$PCRE_OPT $PIPE"
+fi
+
+if [ ".$MD5_OPT" = "." ]; then
+ MD5_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
+else
+ MD5_OPT="$MD5_OPT $PIPE"
+fi
+
+if [ ".$ZLIB_OPT" = "." ]; then
+ ZLIB_OPT="-O2 -fomit-frame-pointer $PIPE $CPU_OPT"
+else
+ ZLIB_OPT="$ZLIB_OPT $PIPE"
+fi
+
+
+# warnings
+
+CFLAGS="$CFLAGS -O -W"
+CFLAGS="$CFLAGS -Wall -Wpointer-arith"
+#CFLAGS="$CFLAGS -Wconversion"
+#CFLAGS="$CFLAGS -Winline"
+
+# we have a lot of the unused function arguments
+CFLAGS="$CFLAGS -Wno-unused"
+
+# stop on warning
+CFLAGS="$CFLAGS -Werror"
+
+# debug
+CFLAGS="$CFLAGS -g"
+
+# DragonFly's gcc3 generates DWARF
+#CFLAGS="$CFLAGS -g -gstabs"
+
+if [ ".$CPP" = "." ]; then
+ CPP="$CC -E"
+fi
+
+LINK="\$(CC)"
+
+
+CC_STRONG="-Wall -Werror"
diff --git a/auto/cc/icc b/auto/cc/icc
new file mode 100644
index 000000000..94d5cddc5
--- /dev/null
+++ b/auto/cc/icc
@@ -0,0 +1,69 @@
+
+# Copyright (C) Igor Sysoev
+
+
+# Intel C++ compiler 7.1, 8.0
+
+# optimizations
+
+CFLAGS="$CFLAGS -O"
+# inline functions declared with __inline
+#CFLAGS="$CFLAGS -Ob1"
+# inline any function, at the compiler's discretion
+CFLAGS="$CFLAGS -Ob2"
+
+# single-file IP optimizations
+#IPO="-ip"
+# multi-file IP optimizations
+IPO="-ipo -ipo_obj"
+CFLAGS="$CFLAGS $IPO"
+CORE_LINK="$CORE_LINK $IPO"
+CORE_LINK="$CORE_LINK -opt_report_file=$OBJS/opt_report_file"
+
+case $CPU in
+ pentium)
+ # optimize for Pentium and Athlon
+ CPU_OPT="-march=pentium"
+ ;;
+
+ pentiumpro)
+ # optimize for Pentium Pro, Pentium II and Pentium III
+ CPU_OPT="-mcpu=pentiumpro -march=pentiumpro"
+ ;;
+
+ pentium4)
+ # optimize for Pentium 4, default
+ CPU_OPT="-march=pentium4"
+ ;;
+esac
+
+CFLAGS="$CFLAGS $CPU_OPT"
+
+if [ ".$PCRE_OPT" = "." ]; then
+ PCRE_OPT="-O $IPO $CPU_OPT"
+fi
+
+if [ ".$MD5_OPT" = "." ]; then
+ MD5_OPT="-O $IPO $CPU_OPT"
+fi
+
+if [ ".$ZLIB_OPT" = "." ]; then
+ ZLIB_OPT="-O $IPO $CPU_OPT"
+fi
+
+
+# warnings
+
+CFLAGS="$CFLAGS -w1"
+#CFLAGS="$CFLAGS -w2"
+
+# stop on warning
+CFLAGS="$CFLAGS -Werror"
+
+# debug
+CFLAGS="$CFLAGS -g"
+
+LINK="\$(CC)"
+
+
+CC_STRONG="-w1 -Werror"
diff --git a/auto/cc/msvc b/auto/cc/msvc
new file mode 100644
index 000000000..d47d4b2a0
--- /dev/null
+++ b/auto/cc/msvc
@@ -0,0 +1,81 @@
+
+# Copyright (C) Igor Sysoev
+
+
+# MSVC 6.0 SP2
+
+# optimizations
+
+# maximize speed
+CFLAGS="$CFLAGS -O2"
+# enable global optimization
+CFLAGS="$CFLAGS -Og"
+# enable intrinsic functions
+CFLAGS="$CFLAGS -Oi"
+# inline expansion
+CFLAGS="$CFLAGS -Ob1"
+# enable frame pointer omission
+CFLAGS="$CFLAGS -Oy"
+# disable stack checking calls
+CFLAGS="$CFLAGS -Gs"
+
+case $CPU in
+ pentium)
+ # optimize for Pentium and Athlon
+ CPU_OPT="-G5"
+ ;;
+
+ pentiumpro)
+ # optimize for Pentium Pro, Pentium II and Pentium III
+ CPU_OPT="-G6"
+ ;;
+
+ pentium4)
+ # optimize for Pentium 4
+ #CPU_OPT="-G7"
+ ;;
+esac
+
+CFLAGS="$CFLAGS $CPU_OPT"
+
+
+# warnings
+
+#CFLAGS="$CFLAGS -W3"
+CFLAGS="$CFLAGS -W4"
+
+# stop on warning
+CFLAGS="$CFLAGS -WX"
+
+# link with libcmt.lib, multithreaded
+#LIBC="-MT"
+# link with msvcrt.dll
+LIBC="-MD"
+
+CFLAGS="$CFLAGS $LIBC"
+
+# disable logo
+CFLAGS="$CFLAGS -nologo"
+
+LINK="\$(CC)"
+
+# link flags
+CORE_LINK="$CORE_LINK -link -verbose:lib"
+
+# debug
+CFLAGS="$CFLAGS -Yd"
+CORE_LINK="$CORE_LINK -debug -debugtype:coff"
+
+# precompiled headers
+CORE_DEPS="$CORE_DEPS $OBJS/ngx_config.pch"
+NGX_PCH="$OBJS/ngx_config.pch"
+NGX_BUILD_PCH="-Ycngx_config.h -Fp$OBJS/ngx_config.pch"
+NGX_USE_PCH="-Yungx_config.h -Fp$OBJS/ngx_config.pch"
+
+ngx_objout="-Fo"
+ngx_binout="-Fe"
+ngx_objext="obj"
+ngx_binext=".exe"
+
+#ngx_regex_dirsep='\\'
+#ngx_dirsep="\\"
diff --git a/auto/cc/name b/auto/cc/name
new file mode 100644
index 000000000..b9744799c
--- /dev/null
+++ b/auto/cc/name
@@ -0,0 +1,51 @@
+
+# Copyright (C) Igor Sysoev
+
+
+echo $ngx_n "checking for C compiler ...$ngx_c"
+
+
+if [ $CC = cl ]; then
+ NGX_CC_NAME=msvc
+ echo " using Microsoft Visual C compiler"
+
+else
+if [ $CC = wcl386 ]; then
+ NGX_CC_NAME=owc
+ echo " using Open Watcom C compiler"
+
+else
+if [ $CC = bcc32 ]; then
+ NGX_CC_NAME=bcc
+ echo " using Borland C++ compiler"
+
+else
+if `$CC -v 2>&1 | grep '^gcc version' 2>&1 >/dev/null`; then
+ NGX_CC_NAME=gcc
+ echo " using GNU C compiler"
+
+else
+if `$CC -V 2>&1 | grep '^Intel(R) C++ Compiler' 2>&1 >/dev/null`; then
+ NGX_CC_NAME=icc
+ echo " using Intel C++ compiler"
+
+else
+if `$CC -V 2>&1 | grep '^Compaq C' 2>&1 >/dev/null`; then
+ NGX_CC_NAME=ccc
+ echo " using Compaq C compiler"
+
+else
+if `$CC -V 2>&1 | grep '^aCC: ' 2>&1 >/dev/null`; then
+ NGX_CC_NAME=acc
+ echo " using HP aC++ compiler"
+
+else
+ echo " unknown"
+
+fi # acc
+fi # ccc
+fi # icc
+fi # gcc
+fi # bcc
+fi # owc
+fi # msvc
diff --git a/auto/cc/owc b/auto/cc/owc
new file mode 100644
index 000000000..0c8194dbb
--- /dev/null
+++ b/auto/cc/owc
@@ -0,0 +1,82 @@
+
+# Copyright (C) Igor Sysoev
+
+
+# Open Watcom C 1.0, 1.2
+
+# optimizations
+
+# maximize speed
+CFLAGS="$CFLAGS -ot"
+# reorder instructions for best pipeline usage
+CFLAGS="$CFLAGS -op"
+# inline intrinsic functions
+CFLAGS="$CFLAGS -oi"
+# inline expansion
+CFLAGS="$CFLAGS -oe"
+# disable stack checking calls
+CFLAGS="$CFLAGS -s"
+
+case $CPU in
+ pentium)
+ # optimize for Pentium and Athlon
+ # register-based arguments passing conventions
+ CPU_OPT="-5r"
+ # stack-based arguments passing conventions
+ #CPU_OPT="-5s"
+ ;;
+
+ pentiumpro)
+ # optimize for Pentium Pro, Pentium II and Pentium III
+ # register-based arguments passing conventions
+ CPU_OPT="-6r"
+ # stack-based arguments passing conventions
+ #CPU_OPT="-6s"
+ ;;
+esac
+
+CFLAGS="$CFLAGS $CPU_OPT"
+
+
+# warnings
+
+#CFLAGS="$CFLAGS -w3"
+CFLAGS="$CFLAGS -wx"
+
+# stop on warning
+CFLAGS="$CFLAGS -we"
+
+# built target is NT
+CFLAGS="$CFLAGS -bt=nt"
+
+# multithreaded
+CFLAGS="$CFLAGS -bm"
+
+# debug
+CFLAGS="$CFLAGS -d2"
+
+# quiet
+CFLAGS="$CFLAGS -zq"
+
+# Open Watcom C 1.2
+#have=HAVE_C99_VARIADIC_MACROS . auto/have
+
+# precompiled headers
+CORE_DEPS="$CORE_DEPS $OBJS/ngx_config.pch"
+NGX_PCH="$OBJS/ngx_config.pch"
+NGX_BUILD_PCH="-fhq=$OBJS/ngx_config.pch"
+NGX_USE_PCH="-fh=$OBJS/ngx_config.pch"
+
+LINK="\$(CC)"
+
+# link flags
+CORE_LINK="$CORE_LINK -l=nt"
+
+ngx_include_opt="-i="
+ngx_objout="-fo"
+ngx_binout="-fe="
+ngx_objext="obj"
+ngx_binext=".exe"
+
+ngx_regex_dirsep='\\'
+ngx_dirsep="\\"
diff --git a/auto/endianess b/auto/endianess
index 4df7d01f1..640b46592 100644
--- a/auto/endianess
+++ b/auto/endianess
@@ -2,7 +2,7 @@
# Copyright (C) Igor Sysoev
-echo $ngx_n "checking for system endianess ..." $ngx_c
+echo $ngx_n "checking for system endianess ...$ngx_c"
echo >> $NGX_ERR
echo "checking for system endianess" >> $NGX_ERR
diff --git a/auto/feature b/auto/feature
index bd5b08158..78676ef09 100644
--- a/auto/feature
+++ b/auto/feature
@@ -2,19 +2,28 @@
# Copyright (C) Igor Sysoev
-echo $ngx_n "checking for $ngx_feature ..." $ngx_c
-echo >> $NGX_ERR
-echo "checking for $ngx_feature" >> $NGX_ERR
+echo $ngx_n "checking for $ngx_feature ...$ngx_c"
+
+cat << END >> $NGX_AUTOCONF_ERR
+
+----------------------------------------
+checking for $ngx_feature
+
+END
ngx_found=no
-feature=`echo $ngx_feature_name | tr '[a-z]' '[A-Z]'`
+if test -n "$ngx_feature_name"; then
+ ngx_have_feature=`echo NGX_$ngx_feature_name | tr '[a-z]' '[A-Z]'`
+ # STUB
+ ngx_have_feature0=`echo HAVE_$ngx_feature_name | tr '[a-z]' '[A-Z]'`
+fi
cat << END > $NGX_AUTOTEST.c
#include <sys/types.h>
-$NGX_UNISTD_H
-$ngx_feature_inc
+$NGX_INCLUDE_UNISTD_H
+$ngx_feature_incs
int main() {
$ngx_feature_test;
@@ -23,34 +32,56 @@ int main() {
END
-test="$CC_WARN $CC_TEST_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c \
- $ngx_feature_libs"
-eval "$test >> $NGX_ERR 2>&1"
+
+ngx_test="$CC $CC_TEST_FLAGS $CC_WARN $CC_AUX_FLAGS \
+ -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
+eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
+
if [ -x $NGX_AUTOTEST ]; then
if [ $ngx_feature_run = yes ]; then
+
if $NGX_AUTOTEST 2>&1 > /dev/null; then
echo " found"
- have=HAVE_$feature . auto/have
ngx_found=yes
+
+ if test -n "$ngx_feature_name"; then
+ have=$ngx_have_feature . auto/have
+ fi
+
+ #STUB
+ if test -n "$ngx_feature_name"; then
+ have=$ngx_have_feature0 . auto/have
+ fi
+
else
echo " found but is not working"
fi
else
echo " found"
- have=HAVE_$feature . auto/have
ngx_found=yes
+
+ if test -n "$ngx_feature_name"; then
+ have=$ngx_have_feature . auto/have
+ fi
+
+ #STUB
+ if test -n "$ngx_feature_name"; then
+ have=$ngx_have_feature0 . auto/have
+ fi
+
fi
else
echo " not found"
- echo "---------" >> $NGX_ERR
- cat $NGX_AUTOTEST.c >> $NGX_ERR
- echo "---------" >> $NGX_ERR
- echo $test >> $NGX_ERR
- echo "---------" >> $NGX_ERR
+
+ echo "----------" >> $NGX_AUTOCONF_ERR
+ cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR
+ echo "----------" >> $NGX_AUTOCONF_ERR
+ echo $ngx_test >> $NGX_AUTOCONF_ERR
+ echo "----------" >> $NGX_AUTOCONF_ERR
fi
rm $NGX_AUTOTEST*
diff --git a/auto/fmt/fmt b/auto/fmt/fmt
index 980641ffa..a316d9b17 100644
--- a/auto/fmt/fmt
+++ b/auto/fmt/fmt
@@ -2,14 +2,21 @@
# Copyright (C) Igor Sysoev
-echo $ngx_n "checking for $ngx_type printf() format ..." $ngx_c
-echo >> $NGX_ERR
-echo "checking for $ngx_type printf() format" >> $NGX_ERR
+echo $ngx_n "checking for $ngx_type printf() format ...$ngx_c"
-ngx_fmt=no
-comma=
+cat << END >> $NGX_AUTOCONF_ERR
-for fmt in $ngx_formats
+----------------------------------------
+checking for $ngx_type printf() format
+
+END
+
+
+ngx_format=no
+ngx_comma=
+
+
+for ngx_fmt in $ngx_formats
do
cat << END > $NGX_AUTOTEST.c
@@ -18,52 +25,63 @@ do
#include <sys/time.h>
#include <stdio.h>
#include <sys/resource.h>
-$NGX_INTTYPES_H
-$NGX_AUTO_CONFIG
+$NGX_INCLUDE_INTTYPES_H
+$NGX_INCLUDE_AUTO_CONFIG_H
int main() {
- printf("$fmt", ($ngx_type) $ngx_max_value);
+ printf("$ngx_fmt", ($ngx_type) $ngx_max_value);
return 0;
}
END
- eval "$CC_WARN $CC_TEST_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c \
- >> $NGX_ERR 2>&1"
+ ngx_test="$CC $CC_TEST_FLAGS $CC_WARN $CC_AUX_FLAGS \
+ -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
+ eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
- max_value=`echo $ngx_max_value | sed -e "s/L*\$//"`
+ ngx_max_val=`echo $ngx_max_value | sed -e "s/L*\$//"`
if [ -x $NGX_AUTOTEST ]; then
- if [ "`$NGX_AUTOTEST`" = $max_value ]; then
+
+ if [ "`$NGX_AUTOTEST`" = $ngx_max_val ]; then
+
if [ $ngx_fmt_collect = yes ]; then
- echo $ngx_n "$comma \"${fmt}\" is appropriate" $ngx_c
+ echo $ngx_n "$ngx_comma \"${ngx_fmt}\" is appropriate$ngx_c"
else
- echo $ngx_n "$comma \"${fmt}\" used" $ngx_c
+ echo $ngx_n "$ngx_comma \"${ngx_fmt}\" used$ngx_c"
fi
- ngx_fmt=$fmt
+
+ ngx_format=$ngx_fmt
fi
fi
- rm $NGX_AUTOTEST*
+ rm -f $NGX_AUTOTEST
- if [ $ngx_fmt != no ]; then
+ if [ $ngx_format != no ]; then
if [ $ngx_fmt_collect = yes ]; then
- eval "ngx_${ngx_size}_fmt=\"\${ngx_${ngx_size}_fmt} \$ngx_fmt\""
- comma=","
+ eval "ngx_${ngx_size}_fmt=\"\${ngx_${ngx_size}_fmt} \$ngx_format\""
+ ngx_comma=","
continue
else
break
fi
fi
- echo $ngx_n "$comma \"${fmt}\" is not appropriate" $ngx_c
- comma=","
+ echo $ngx_n "$ngx_comma \"${ngx_fmt}\" is not appropriate$ngx_c"
+ ngx_comma=","
+
+ echo "----------" >> $NGX_AUTOCONF_ERR
+ cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR
+ echo "----------" >> $NGX_AUTOCONF_ERR
+ echo $ngx_test >> $NGX_AUTOCONF_ERR
+ echo "----------" >> $NGX_AUTOCONF_ERR
done
echo
-if [ $ngx_fmt = no ]; then
+if [ $ngx_format = no ]; then
echo "$0: error: printf() $ngx_type format not found"
+
exit 1
fi
@@ -72,7 +90,7 @@ if [ $ngx_fmt_collect = no ]; then
cat << END >> $NGX_AUTO_CONFIG_H
#ifndef $ngx_fmt_name
-#define $ngx_fmt_name "$ngx_fmt"
+#define $ngx_fmt_name "$ngx_format"
#endif
END
diff --git a/auto/fmt/ptrfmt b/auto/fmt/ptrfmt
index 163ca59e2..32ba8a44f 100644
--- a/auto/fmt/ptrfmt
+++ b/auto/fmt/ptrfmt
@@ -2,71 +2,85 @@
# Copyright (C) Igor Sysoev
-echo $ngx_n "checking for $ngx_type printf() format ..." $ngx_c
-echo >> $NGX_ERR
-echo "checking for $ngx_type printf() format" >> $NGX_ERR
+echo $ngx_n "checking for $ngx_type printf() format ...$ngx_c"
-ngx_fmt=no
-comma=
-fmtX=
+cat << END >> $NGX_AUTOCONF_ERR
-for fmt in $ngx_formats
+----------------------------------------
+checking for $ngx_type printf() format
+
+END
+
+
+ngx_format=no
+ngx_comma=
+ngx_fmt_x=
+
+for ngx_fmt in $ngx_formats
do
cat << END > $NGX_AUTOTEST.c
int main() {
- printf("$fmt", ($ngx_type) $ngx_max_value);
+ printf("$ngx_fmt", ($ngx_type) $ngx_max_value);
return 0;
}
END
- eval "$CC_WARN $CC_TEST_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c \
- >> $NGX_ERR 2>&1"
+ ngx_test="$CC $CC_TEST_FLAGS $CC_WARN $CC_AUX_FLAGS \
+ -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
+ eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
- max_value=`echo $ngx_max_value | sed -e "s/L*\$//"`
+ ngx_max_val=`echo $ngx_max_value | sed -e "s/L*\$//"`
if [ -x $NGX_AUTOTEST ]; then
- if [ "`$NGX_AUTOTEST`" = $max_value ]; then
- ngx_fmt=$fmt
+ if [ "`$NGX_AUTOTEST`" = $ngx_max_val ]; then
+ ngx_format=$ngx_fmt
fi
fi
- rm $NGX_AUTOTEST*
+ rm $NGX_AUTOTEST
- if [ $ngx_fmt != no ]; then
+ if [ $ngx_format != no ]; then
break
fi
- fmtX=`echo $fmt | sed -e "s/d/X/"`
+ ngx_fmt_x=`echo $ngx_fmt | sed -e "s/d/X/"`
+
+ echo $ngx_n "$ngx_comma \"${ngx_fmt_x}\" is not appropriate$ngx_c"
+ ngx_comma=","
- echo $ngx_n "$comma \"${fmtX}\" is not appropriate" $ngx_c
- comma=","
+ echo "----------" >> $NGX_AUTOCONF_ERR
+ cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR
+ echo "----------" >> $NGX_AUTOCONF_ERR
+ echo $ngx_test >> $NGX_AUTOCONF_ERR
+ echo "----------" >> $NGX_AUTOCONF_ERR
done
-if [ $ngx_fmt = no ]; then
+if [ $ngx_format = no ]; then
echo "$0: error: printf() $ngx_type format not found"
+
exit 1
fi
if [ $ngx_ptr_size = 4 ]; then
- fmtX="%0`expr 2 \* $ngx_ptr_size`"
+ ngx_fmt_x="%0`expr 2 \* $ngx_ptr_size`"
else
- fmtX="%"
+ ngx_fmt_x="%"
fi
-ngx_fmt=`echo $ngx_fmt | sed -e "s/d/X/" -e "s/^%/$fmtX/"`
+ngx_format=`echo $ngx_format | sed -e "s/d/X/" -e "s/^%/$ngx_fmt_x/"`
-echo "$comma \"${ngx_fmt}\" used"
+echo "$ngx_comma \"${ngx_format}\" used"
cat << END >> $NGX_AUTO_CONFIG_H
#ifndef $ngx_fmt_name
-#define $ngx_fmt_name "$ngx_fmt"
+#define $ngx_fmt_name "$ngx_format"
#endif
END
diff --git a/auto/headers b/auto/headers
index 2bfa685c9..29eec60ab 100644
--- a/auto/headers
+++ b/auto/headers
@@ -2,5 +2,7 @@
# Copyright (C) Igor Sysoev
-ngx_inc="unistd.h"; . auto/inc
-ngx_inc="inttypes.h"; . auto/inc
+ngx_include="unistd.h"; . auto/include
+ngx_include="inttypes.h"; . auto/include
+ngx_include="limits.h"; . auto/include
+ngx_include="sys/filio.h"; . auto/include
diff --git a/auto/inc b/auto/inc
deleted file mode 100644
index 867102223..000000000
--- a/auto/inc
+++ /dev/null
@@ -1,35 +0,0 @@
-
-# Copyright (C) Igor Sysoev
-
-
-echo $ngx_n "checking for $ngx_inc ..." $ngx_c
-echo >> $NGX_ERR
-echo "checking for $ngx_inc" >> $NGX_ERR
-
-ngx_found=no
-
-inc=`echo $ngx_inc | sed -e 's/\./_/' | sed -e 's/\//_/' | tr '[a-z]' '[A-Z]'`
-
-cat << END > $NGX_AUTOTEST.c
-
-#include <$ngx_inc>
-
-int main() {
- return 0;
-}
-
-END
-
-eval "${CC} -o $NGX_AUTOTEST $NGX_AUTOTEST.c >> $NGX_ERR 2>&1"
-
-if [ -x $NGX_AUTOTEST ]; then
- echo " found"
- have=HAVE_$inc . auto/have
- eval "NGX_$inc='#include <$ngx_inc>'"
- ngx_found=yes
-
-else
- echo " not found"
-fi
-
-rm $NGX_AUTOTEST*
diff --git a/auto/include b/auto/include
new file mode 100644
index 000000000..b36916947
--- /dev/null
+++ b/auto/include
@@ -0,0 +1,66 @@
+
+# Copyright (C) Igor Sysoev
+
+
+echo $ngx_n "checking for $ngx_include ...$ngx_c"
+
+cat << END >> $NGX_AUTOCONF_ERR
+
+----------------------------------------
+checking for $ngx_include
+
+END
+
+
+ngx_found=no
+
+cat << END > $NGX_AUTOTEST.c
+
+#include <$ngx_include>
+
+int main() {
+ return 0;
+}
+
+END
+
+
+ngx_test="$CC -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
+
+eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
+
+if [ -x $NGX_AUTOTEST ]; then
+
+ ngx_found=yes
+
+ echo " found"
+
+ ngx_name=`echo $ngx_include | sed -e 's/\./_/' -e 's/\//_/' \
+ | tr '[a-z]' '[A-Z]'`
+
+
+ cat << END >> $NGX_AUTO_HEADERS_H
+
+#ifndef NGX_HAVE_$ngx_name
+#define NGX_HAVE_$ngx_name 1
+#endif
+
+END
+
+
+ eval "NGX_INCLUDE_$ngx_name='#include <$ngx_include>'"
+
+ #STUB
+ eval "NGX_$ngx_name='#include <$ngx_include>'"
+
+else
+ echo " not found"
+
+ echo "----------" >> $NGX_AUTOCONF_ERR
+ cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR
+ echo "----------" >> $NGX_AUTOCONF_ERR
+ echo $ngx_test >> $NGX_AUTOCONF_ERR
+ echo "----------" >> $NGX_AUTOCONF_ERR
+fi
+
+rm $NGX_AUTOTEST*
diff --git a/auto/init b/auto/init
index bc4d8bbec..080cc28c1 100644
--- a/auto/init
+++ b/auto/init
@@ -2,31 +2,33 @@
# Copyright (C) Igor Sysoev
-MAKEFILE=$OBJS/Makefile
+NGX_MAKEFILE=$NGX_OBJS/Makefile
+NGX_MODULES_C=$NGX_OBJS/ngx_modules.c
-NGX_AUTO_CONFIG_H=$OBJS/ngx_auto_config.h
-NGX_MODULES_C=$OBJS/ngx_modules.c
+NGX_AUTO_HEADERS_H=$NGX_OBJS/ngx_auto_headers.h
+NGX_AUTO_CONFIG_H=$NGX_OBJS/ngx_auto_config.h
-NGX_AUTOTEST=$OBJS/autotest
-NGX_ERR=$OBJS/autoconf.err
+NGX_AUTOTEST=$NGX_OBJS/autotest
+NGX_AUTOCONF_ERR=$NGX_OBJS/autoconf.err
-CC_WARN=$CC
+# STUBs
+OBJS=$NGX_OBJS
+NGX_ERR=$OBJS/autoconf.err
+MAKEFILE=$OBJS/Makefile
-PCH=NO
-USEPCH=
-OBJEXT=
-BINEXT=
-DIRSEP='\/'
-MAKE_SL=NO
+NGX_PCH=
+NGX_USE_PCH=
-# checking echo's "-n" option and "\c" capabilties
+# check the echo's "-n" option and "\c" capability
if echo "test\c" | grep c >/dev/null; then
+
if echo -n test | grep n >/dev/null; then
ngx_n=
ngx_c=
+
else
ngx_n=-n
ngx_c=
@@ -38,19 +40,18 @@ else
fi
+# create Makefile
-if test ! -f Makefile; then
-
- cat << END > Makefile
+cat << END > Makefile
build:
- \$(MAKE) -f $OBJS/Makefile
+ \$(MAKE) -f $NGX_MAKEFILE
install:
- \$(MAKE) -f $OBJS/Makefile install
+ \$(MAKE) -f $NGX_MAKEFILE install
clean:
- rm -rf Makefile $OBJS
+ rm -rf Makefile $NGX_OBJS
upgrade:
$SBIN_PATH -t
@@ -58,7 +59,4 @@ upgrade:
sleep 1
test -f $PID_PATH.newbin
kill -WINCH \`cat $PID_PATH\`
-
END
-
-fi
diff --git a/auto/install b/auto/install
index 57e3019cb..0da9b6dd4 100644
--- a/auto/install
+++ b/auto/install
@@ -8,7 +8,7 @@ install:
test -d `dirname $SBIN_PATH` || mkdir -p `dirname $SBIN_PATH`
test ! -f $SBIN_PATH || mv $SBIN_PATH $SBIN_PATH.old
- cp nginx $SBIN_PATH
+ cp $OBJS/nginx $SBIN_PATH
test -d `dirname $CONF_PATH` || mkdir -p `dirname $CONF_PATH`
diff --git a/auto/lib/md5/conf b/auto/lib/md5/conf
index 748bea450..623986f0f 100644
--- a/auto/lib/md5/conf
+++ b/auto/lib/md5/conf
@@ -15,14 +15,14 @@ if [ $MD5 != NONE ]; then
CORE_INCS="$CORE_INCS $MD5"
- case "$CC" in
+ case "$NGX_CC_NAME" in
- cl | wcl386 | bcc32)
+ msvc | owc | bcc)
LINK_DEPS="$LINK_DEPS $MD5/md5.lib"
CORE_LIBS="$CORE_LIBS $MD5/md5.lib"
;;
- *icc)
+ icc)
LINK_DEPS="$LINK_DEPS $MD5/libmd5.a"
# to allow -ipo optimization we link with the *.o but not library
@@ -45,20 +45,19 @@ else
if [ $PLATFORM != win32 ]; then
MD5=NO
- ngx_lib_cflags=
# Solaris 8/9
- ngx_lib_inc="#include <sys/types.h>
-#include <md5.h>"
- ngx_lib="rsaref md5 library"
- ngx_lib_test="MD5_CTX md5; MD5Init(&md5)"
- ngx_libs=-lmd5
- . auto/lib/test
-
+ ngx_feature="rsaref md5 library"
+ ngx_feature_name="rsaref_md5"
+ ngx_feature_run=no
+ ngx_feature_incs="#include <md5.h>"
+ ngx_feature_libs="-lmd5"
+ ngx_feature_test="MD5_CTX md5; MD5Init(&md5)"
+ . auto/feature
if [ $ngx_found = yes ]; then
- CORE_LIBS="$CORE_LIBS $ngx_libs"
+ CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
MD5=YES
MD5_LIB=md5
ngx_found=no
@@ -66,15 +65,18 @@ else
else
# FreeBSD
- ngx_lib="rsaref md library"
- ngx_lib_test="MD5_CTX md5; MD5Init(&md5)"
- ngx_libs=-lmd
- . auto/lib/test
+ ngx_feature="rsaref md library"
+ ngx_feature_name="rsaref_md5"
+ ngx_feature_run=no
+ ngx_feature_incs="#include <md5.h>"
+ ngx_feature_libs="-lmd"
+ ngx_feature_test="MD5_CTX md5; MD5Init(&md5)"
+ . auto/feature
fi
if [ $ngx_found = yes ]; then
- CORE_LIBS="$CORE_LIBS $ngx_libs"
+ CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
MD5=YES
MD5_LIB=md
ngx_found=no
@@ -84,19 +86,20 @@ else
# OpenSSL crypto library
- ngx_lib_inc="#include <openssl/md5.h>"
- ngx_lib="OpenSSL md5 crypto library"
- ngx_lib_test="MD5_CTX md5; MD5_Init(&md5)"
- ngx_libs=-lcrypto
- . auto/lib/test
+ ngx_feature="OpenSSL md5 crypto library"
+ ngx_feature_name="OpenSSL_md5"
+ ngx_feature_run=no
+ ngx_feature_incs="#include <openssl/md5.h>"
+ ngx_feature_libs="-lcrypto"
+ ngx_feature_test="MD5_CTX md5; MD5_Init(&md5)"
+ . auto/feature
fi
fi
if [ $ngx_found = yes ]; then
- have=HAVE_OPENSSL_MD5 . auto/have
have=HAVE_OPENSSL_MD5_H . auto/have
- CORE_LIBS="$CORE_LIBS $ngx_libs"
+ CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
MD5=YES
MD5_LIB=crypto
fi
diff --git a/auto/lib/md5/make b/auto/lib/md5/make
index f718e6c2c..6e2834e6d 100644
--- a/auto/lib/md5/make
+++ b/auto/lib/md5/make
@@ -25,7 +25,7 @@ esac
case $PLATFORM in
win32)
- line=`echo $MD5/md5.lib: | sed -e "s/\//$DIRSEP/g"`
+ line=`echo $MD5/md5.lib: | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "$line" >> $MAKEFILE
;;
@@ -42,7 +42,7 @@ done=NO
case $PLATFORM in
win32)
- md5=`echo $MD5 | sed -e "s/\//$DIRSEP/g"`
+ md5=`echo $MD5 | sed -e "s/\//$ngx_regex_dirsep/g"`
cp auto/lib/md5/$makefile $MD5
echo " cd $md5" >> $MAKEFILE
diff --git a/auto/lib/openssl/conf b/auto/lib/openssl/conf
index 37c084f00..8ef4f3af9 100644
--- a/auto/lib/openssl/conf
+++ b/auto/lib/openssl/conf
@@ -19,23 +19,22 @@ if [ $OPENSSL != NONE ]; then
else
if [ $PLATFORM != win32 ]; then
- OPENSSL=NO
- ngx_lib_cflags=
-
- ngx_lib_inc="#include <openssl/ssl.h>"
- ngx_lib="OpenSSL library"
- ngx_lib_test="SSL_library_init()"
- ngx_libs="-lssl -lcrypto"
- . auto/lib/test
+ OPENSSL=NO
+ ngx_feature="OpenSSL library"
+ ngx_feature_name="OpenSSL"
+ ngx_feature_run=no
+ ngx_feature_incs="#include <openssl/ssl.h>"
+ ngx_feature_libs="-lssl -lcrypto"
+ ngx_feature_test="SSL_library_init()"
+ . auto/feature
if [ $ngx_found = yes ]; then
have=NGX_OPENSSL . auto/have
CORE_DEPS="$CORE_DEPS $OPENSSL_DEPS"
CORE_SRCS="$CORE_SRCS $OPENSSL_SRCS"
- CORE_LIBS="$CORE_LIBS $ngx_libs"
+ CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
OPENSSL=YES
- ngx_found=no
fi
fi
diff --git a/auto/lib/pcre/conf b/auto/lib/pcre/conf
index 16feffa6b..cd516e1e7 100644
--- a/auto/lib/pcre/conf
+++ b/auto/lib/pcre/conf
@@ -7,18 +7,18 @@ if [ $PCRE != NONE ]; then
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
- case "$CC" in
+ case "$NGX_CC_NAME" in
- cl | wcl386 | bcc32)
- have=HAVE_PCRE . auto/have
+ msvc | owc | bcc)
+ have=NGX_PCRE . auto/have
have=PCRE_STATIC . auto/have
CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
LINK_DEPS="$LINK_DEPS $PCRE/pcre.lib"
CORE_LIBS="$CORE_LIBS $PCRE/pcre.lib"
;;
- *icc)
- have=HAVE_PCRE . auto/have
+ icc)
+ have=NGX_PCRE . auto/have
CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre.a"
@@ -31,7 +31,7 @@ if [ $PCRE != NONE ]; then
;;
*)
- have=HAVE_PCRE . auto/have
+ have=NGX_PCRE . auto/have
CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
LINK_DEPS="$LINK_DEPS $PCRE/.libs/libpcre.a"
CORE_LIBS="$CORE_LIBS $PCRE/.libs/libpcre.a"
@@ -43,44 +43,25 @@ if [ $PCRE != NONE ]; then
else
if [ $PLATFORM != win32 ]; then
- PCRE=NO
- ngx_lib_cflags=
-
- # Linux
-
- ngx_lib_inc="#include <pcre.h>"
- ngx_lib="PCRE library"
- ngx_lib_test="pcre *re; re = pcre_compile(NULL, 0, NULL, 0, NULL)"
- ngx_libs="-lpcre"
- . auto/lib/test
-
+ PCRE=NO
+
+ # FreeBSD PCRE port requires --with-cc-opt="-I /usr/local/include"
+ # --with-ld-opt="-L /usr/local/lib"
+
+ ngx_feature="PCRE library"
+ ngx_feature_name="PCRE"
+ ngx_feature_run=no
+ ngx_feature_incs="#include <pcre.h>"
+ ngx_feature_libs="-lpcre"
+ ngx_feature_test="pcre *re; re = pcre_compile(NULL, 0, NULL, 0, NULL)"
+ . auto/feature
if [ $ngx_found = yes ]; then
- have=HAVE_PCRE . auto/have
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
- CORE_LIBS="$CORE_LIBS $ngx_libs"
+ CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
PCRE=YES
ngx_found=no
-
- else
- # FreeBSD PCRE port.
-
- ngx_lib="PCRE library in /usr/local/"
- ngx_lib_cflags="-I /usr/local/include"
- ngx_libs="-L /usr/local/lib -lpcre"
- . auto/lib/test
- fi
-
-
- if [ $ngx_found = yes ]; then
- have=HAVE_PCRE . auto/have
- CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
- CORE_INCS="$CORE_INCS /usr/local/include"
- CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
- CORE_LIBS="$CORE_LIBS $ngx_libs"
- PCRE=YES
fi
fi
-
fi
diff --git a/auto/lib/pcre/make b/auto/lib/pcre/make
index fa7bf27d0..714994df5 100644
--- a/auto/lib/pcre/make
+++ b/auto/lib/pcre/make
@@ -29,8 +29,8 @@ case $PLATFORM in
cp auto/lib/pcre/patch.config.in $PCRE
cp auto/lib/pcre/$makefile $PCRE
- pcre=`echo $PCRE | sed -e "s/\//$DIRSEP/g"`
- line=`echo $PCRE/pcre.h: | sed -e "s/\//$DIRSEP/g"`
+ pcre=`echo $PCRE | sed -e "s/\//$ngx_regex_dirsep/g"`
+ line=`echo $PCRE/pcre.h: | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "$line" >> $MAKEFILE
echo " cd $pcre" >> $MAKEFILE
@@ -39,7 +39,7 @@ case $PLATFORM in
echo >> $MAKEFILE
line="$PCRE/pcre.lib: $PCRE/pcre.h"
- line=`echo $line | sed -e "s/\//$DIRSEP/g"`
+ line=`echo $line | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "$line" >> $MAKEFILE
echo " cd $pcre" >> $MAKEFILE
diff --git a/auto/lib/test b/auto/lib/test
index 7dfaafef1..6821b51da 100644
--- a/auto/lib/test
+++ b/auto/lib/test
@@ -2,14 +2,26 @@
# Copyright (C) Igor Sysoev
-echo $ngx_n "checking for $ngx_lib ..." $ngx_c
-echo >> $NGX_ERR
-echo "checking for $ngx_lib library" >> $NGX_ERR
+echo $ngx_n "checking for $ngx_lib ...$ngx_c"
+
+cat << END >> $NGX_AUTOCONF_ERR
+
+----------------------------------------
+checking for $ngx_lib
+
+END
ngx_found=no
-echo "$ngx_lib_inc" > $NGX_AUTOTEST.c
-echo "int main() { $ngx_lib_test; return 0; }" >> $NGX_AUTOTEST.c
+cat << END > $NGX_AUTOTEST.c
+
+$ngx_lib_incs
+
+int main() {
+ $ngx_lib_test;
+ return 0;
+}
+
eval "$CC $cc_test_flags $ngx_lib_cflags \
-o $NGX_AUTOTEST $NGX_AUTOTEST.c $ngx_libs \
diff --git a/auto/lib/zlib/conf b/auto/lib/zlib/conf
index a01eebe71..f833d6165 100644
--- a/auto/lib/zlib/conf
+++ b/auto/lib/zlib/conf
@@ -5,14 +5,14 @@
if [ $ZLIB != NONE ]; then
CORE_INCS="$CORE_INCS $ZLIB"
- case "$CC" in
+ case "$NGX_CC_NAME" in
- cl | wcl386 | bcc32)
+ msvc | owc | bcc)
LINK_DEPS="$LINK_DEPS $ZLIB/zlib.lib"
CORE_LIBS="$CORE_LIBS $ZLIB/zlib.lib"
;;
- *icc)
+ icc)
LINK_DEPS="$LINK_DEPS $ZLIB/libz.a"
# to allow -ipo optimization we link with the *.o but not library
@@ -38,22 +38,23 @@ if [ $ZLIB != NONE ]; then
else
if [ $PLATFORM != win32 ]; then
+ ZLIB=NO
# FreeBSD, Solaris, Linux
- ngx_lib_cflags=
- ngx_lib_inc="#include <zlib.h>"
- ngx_lib="zlib library"
- ngx_lib_test="z_stream z; deflate(&z, Z_NO_FLUSH)"
- ngx_libs=-lz
- . auto/lib/test
+ ngx_feature="zlib library"
+ ngx_feature_name="zlib"
+ ngx_feature_run=no
+ ngx_feature_incs="#include <zlib.h>"
+ ngx_feature_libs="-lz"
+ ngx_feature_test="z_stream z; deflate(&z, Z_NO_FLUSH)"
+ . auto/feature
if [ $ngx_found = yes ]; then
- CORE_LIBS="$CORE_LIBS $ngx_libs"
+ CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
ZLIB=YES
- else
- ZLIB=NO
+ ngx_found=no
fi
fi
diff --git a/auto/lib/zlib/make b/auto/lib/zlib/make
index 0ced9a25c..582276248 100644
--- a/auto/lib/zlib/make
+++ b/auto/lib/zlib/make
@@ -26,7 +26,7 @@ esac
case $PLATFORM in
win32)
- line=`echo $ZLIB/zlib.lib: | sed -e "s/\//$DIRSEP/g"`
+ line=`echo $ZLIB/zlib.lib: | sed -e "s/\//$ngx_regex_dirsep/g"`
echo "$line" >> $MAKEFILE
;;
@@ -43,7 +43,7 @@ done=NO
case $PLATFORM in
win32)
- zlib=`echo $ZLIB | sed -e "s/\//$DIRSEP/g"`
+ zlib=`echo $ZLIB | sed -e "s/\//$ngx_regex_dirsep/g"`
cp auto/lib/zlib/$makefile $ZLIB
echo " cd $zlib" >> $MAKEFILE
diff --git a/auto/make b/auto/make
index fee8a6f24..8744d1f5f 100644
--- a/auto/make
+++ b/auto/make
@@ -8,353 +8,271 @@ mkdir -p $OBJS/src/core $OBJS/src/event $OBJS/src/event/modules \
$OBJS/src/imap
-echo "CC = $CC" > $MAKEFILE
-echo "CPP = $CPP" >> $MAKEFILE
-echo "LINK = $LINK" >> $MAKEFILE
-if [ "$CC" = wcl386 ]; then
- echo MAKE = wmake >> $MAKEFILE
-fi
-echo "CFLAGS = $CFLAGS" >> $MAKEFILE
-echo >> $MAKEFILE
+ngx_objs_dir=$NGX_OBJS$ngx_regex_dirsep
+ngx_use_pch=`echo $NGX_USE_PCH | sed -e "s/\//$ngx_regex_dirsep/g"`
-if [ $MAKE_SL = YES ]; then
- echo >> $MAKEFILE
-fi
+cat << END >> $NGX_MAKEFILE
-all_inc="$CORE_INCS $OBJS $HTTP_INCS $IMAP_INCS"
-all_inc=`echo " $all_inc" | sed -e "s/ \([^ ]\)/ $INCOPT\1/g"`
-all_inc=`echo $all_inc | sed -e "s/\//$DIRSEP/g"`
+CC = $CC
+CFLAGS = $CFLAGS
+CPP = $CPP
+LINK = $LINK
-echo "ALL_INCS = $all_inc" >> $MAKEFILE
-echo >> $MAKEFILE
-
-all_srcs="$CORE_SRCS"
+END
+if [ "$CC" = wcl386 ]; then
+ echo MAKE = wmake >> $NGX_MAKEFILE
-# CORE_DEPS
+ ngx_regex_cont=' '
+ ngx_cont=' '
+ ngx_tab=' '
-if [ $MAKE_SL = YES ]; then
- echo $ngx_n "CORE_DEPS =" $ngx_c >> $MAKEFILE
-else
- echo "CORE_DEPS = \\" >> $MAKEFILE
fi
-for dep in $CORE_DEPS
-do
- dep=`echo $dep | sed -e "s/\//$DIRSEP/g"`
- if [ $MAKE_SL = YES ]; then
- echo $ngx_n " $dep" $ngx_c >> $MAKEFILE
- else
- echo " $dep \\" >> $MAKEFILE
- fi
-done
-echo >> $MAKEFILE
+# ALL_INCS, required by OpenWatcom C precompiled headers
+ngx_incs=`echo $CORE_INCS $OBJS $HTTP_INCS $IMAP_INCS\
+ | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
+ -e "s/\//$ngx_regex_dirsep/g"`
-# CORE_INCS
+cat << END >> $NGX_MAKEFILE
-if [ $MAKE_SL = YES ]; then
- echo >> $MAKEFILE
-fi
+ALL_INCS = $ngx_include_opt$ngx_incs
-inc="$CORE_INCS $OBJS"
-inc=`echo " $inc" | sed -e "s/ \([^ ]\)/ $INCOPT\1/g" -e "s/\//$DIRSEP/g"`
+END
-echo "CORE_INCS = $inc" >> $MAKEFILE
-echo >> $MAKEFILE
+ngx_all_srcs="$CORE_SRCS"
-if [ $HTTP = YES ]; then
- all_srcs="$all_srcs $HTTP_SRCS"
+# the core dependences and include pathes
- # HTTP_DEPS
+ngx_deps=`echo $CORE_DEPS $NGX_PCH \
+ | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
+ -e "s/\//$ngx_regex_dirsep/g"`
- if [ $MAKE_SL = YES ]; then
- echo $ngx_n "HTTP_DEPS =" $ngx_c >> $MAKEFILE
- else
- echo "HTTP_DEPS = \\" >> $MAKEFILE
- fi
+ngx_incs=`echo $CORE_INCS $OBJS \
+ | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
+ -e "s/\//$ngx_regex_dirsep/g"`
- for dep in $HTTP_DEPS
- do
- dep=`echo $dep | sed -e "s/\//$DIRSEP/g"`
+cat << END >> $NGX_MAKEFILE
- if [ $MAKE_SL = YES ]; then
- echo $ngx_n " $dep" $ngx_c >> $MAKEFILE
- else
- echo " $dep \\" >> $MAKEFILE
- fi
- done
- echo >> $MAKEFILE
+CORE_DEPS = $ngx_deps
- # HTTP_INCS
+CORE_INCS = $ngx_include_opt$ngx_incs
- if [ $MAKE_SL = YES ]; then
- echo >> $MAKEFILE
- fi
+END
- inc="$HTTP_INCS $OBJS"
- inc=`echo " $inc" | sed -e "s/ \([^ ]\)/ $INCOPT\1/g" -e "s/\//$DIRSEP/g"`
- echo "HTTP_INCS = $inc" >> $MAKEFILE
- echo >> $MAKEFILE
+# the http dependences and include pathes
-fi
+if [ $HTTP = YES ]; then
+ ngx_all_srcs="$ngx_all_srcs $HTTP_SRCS"
-if [ $IMAP = YES ]; then
+ ngx_deps=`echo $HTTP_DEPS \
+ | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
+ -e "s/\//$ngx_regex_dirsep/g"`
- all_srcs="$all_srcs $IMAP_SRCS"
+ ngx_incs=`echo $HTTP_INCS \
+ | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
+ -e "s/\//$ngx_regex_dirsep/g"`
- # IMAP_DEPS
+ cat << END >> $NGX_MAKEFILE
- if [ $MAKE_SL = YES ]; then
- echo $ngx_n "IMAP_DEPS =" $ngx_c >> $MAKEFILE
- else
- echo "IMAP_DEPS = \\" >> $MAKEFILE
- fi
+HTTP_DEPS = $ngx_deps
- for dep in $IMAP_DEPS
- do
- dep=`echo $dep | sed -e "s/\//$DIRSEP/g"`
- if [ $MAKE_SL = YES ]; then
- echo $ngx_n " $dep" $ngx_c >> $MAKEFILE
- else
- echo " $dep \\" >> $MAKEFILE
- fi
- done
- echo >> $MAKEFILE
+HTTP_INCS = $ngx_include_opt$ngx_incs
+END
- # IMAP_INCS
+fi
- if [ $MAKE_SL = YES ]; then
- echo >> $MAKEFILE
- fi
- inc="$IMAP_INCS $OBJS"
- inc=`echo " $inc" | sed -e "s/ \([^ ]\)/ $INCOPT\1/g" -e "s/\//$DIRSEP/g"`
+# the imap dependences and include pathes
- echo "IMAP_INCS = $inc" >> $MAKEFILE
- echo >> $MAKEFILE
+if [ $IMAP = YES ]; then
-fi
+ ngx_all_srcs="$ngx_all_srcs $IMAP_SRCS"
+ ngx_deps=`echo $IMAP_DEPS \
+ | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
+ -e "s/\//$ngx_regex_dirsep/g"`
-# nginx
+ ngx_incs=`echo $IMAP_INCS \
+ | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
+ -e "s/\//$ngx_regex_dirsep/g"`
-if [ $MAKE_SL = YES ]; then
- echo $ngx_n "nginx$BINEXT: " $ngx_c >> $MAKEFILE
-else
- echo "nginx$BINEXT: \\" >> $MAKEFILE
-fi
+ cat << END >> $NGX_MAKEFILE
+IMAP_DEPS = $ngx_deps
-# nginx deps
-for src in $all_srcs
-do
- obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\.S\$/.$OBJEXT/"`
- obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
+IMAP_INCS = $ngx_include_opt$ngx_incs
- if [ $MAKE_SL = YES ]; then
- echo $ngx_n " $obj" $ngx_c >> $MAKEFILE
- else
- echo " $obj \\" >> $MAKEFILE
- fi
-done
+END
-for src in $NGX_MODULES_C $LINK_DEPS
-do
- obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/"`
- obj=`echo $obj | sed -e "s/\//$DIRSEP/g"`
+fi
- if [ $MAKE_SL = YES ]; then
- echo $ngx_n " $obj" $ngx_c >> $MAKEFILE
- else
- echo " $obj \\" >> $MAKEFILE
- fi
-done
-echo >> $MAKEFILE
+# nginx
-# nginx build
+ngx_all_srcs=`echo $ngx_all_srcs | sed -e "s/\//$ngx_regex_dirsep/g"`
+ngx_modules_c=`echo $NGX_MODULES_C | sed -e "s/\//$ngx_regex_dirsep/g"`
-if [ $MAKE_SL = YES ]; then
- echo $ngx_n " \$(LINK) ${BINOUT}nginx" $ngx_c >> $MAKEFILE
-else
- echo " \$(LINK) ${BINOUT}nginx \\" >> $MAKEFILE
-fi
+ngx_all_objs=`echo $ngx_all_srcs \
+ | sed -e "s/\([^ ]*\.\)cpp/$NGX_OBJS\/\1$ngx_objext/g" \
+ -e "s/\([^ ]*\.\)cc/$NGX_OBJS\/\1$ngx_objext/g" \
+ -e "s/\([^ ]*\.\)c/$NGX_OBJS\/\1$ngx_objext/g" \
+ -e "s/\([^ ]*\.\)S/$NGX_OBJS\/\1$ngx_objext/g"`
+ngx_modules_obj=`echo $ngx_modules_c | sed -e "s/\(.*\.\)c/\1$ngx_objext/"`
-# nginx build sources
+ngx_deps=`echo $ngx_all_objs $ngx_modules_obj $LINK_DEPS \
+ | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
+ -e "s/\//$ngx_regex_dirsep/g"`
-for src in $all_srcs
-do
- obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\.S\$/.$OBJEXT/"`
- obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
+ngx_objs=`echo $ngx_all_objs $ngx_modules_obj \
+ | sed -e "s/ *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
+ -e "s/\//$ngx_regex_dirsep/g"`
- if [ $MAKE_SL = YES ]; then
- echo $ngx_n " $obj" $ngx_c >> $MAKEFILE
- else
- echo " $obj \\" >> $MAKEFILE
- fi
-done
+ngx_libs=${CORE_LIBS:+`echo $NGX_LD_OPT $CORE_LIBS \
+ | sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_regex_cont/"`}
+ngx_link=${CORE_LINK:+`echo $CORE_LINK \
+ | sed -e "s/\//$ngx_regex_dirsep/g" -e "s/^/$ngx_regex_cont/"`}
-# nginx build ngx_modules.c and libs
+cat << END >> $NGX_MAKEFILE
-obj=`echo $NGX_MODULES_C | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\//$DIRSEP/g"`
-src=`echo $NGX_MODULES_C | sed -e "s/\//$DIRSEP/g"`
-libs=`echo $CORE_LIBS | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\//$DIRSEP/g"`
-link=`echo $CORE_LINK | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\//$DIRSEP/g"`
+$NGX_OBJS${ngx_dirsep}nginx${ngx_binext}: $ngx_deps$ngx_spacer
+ \$(LINK) ${ngx_binout}$NGX_OBJS${ngx_dirsep}nginx$ngx_cont$ngx_objs$ngx_libs$ngx_link
-if [ $MAKE_SL = YES ]; then
- echo " $obj $libs $CORE_LINK" >> $MAKEFILE
- echo >> $MAKEFILE
-else
- echo " $obj \\" >> $MAKEFILE
- echo " $libs \\" >> $MAKEFILE
- echo " $link" >> $MAKEFILE
- echo >> $MAKEFILE
-fi
+END
# ngx_modules.c
-deps="\$(CORE_DEPS)"
-
-if [ $PCH != NO ]; then
- args="\$(CFLAGS) $USEPCH \$(ALL_INCS)"
+if test -n "$NGX_PCH"; then
+ ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
else
- args="\$(CFLAGS) $USEPCH \$(CORE_INCS)"
+ ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS)"
fi
-if [ $MAKE_SL = YES ]; then
- echo "$obj: $NGX_MODULES_C $deps" >> $MAKEFILE
- echo $ngx_n " \$(CC) $COMPOPT $args" $ngx_c >> $MAKEFILE
- echo " $OBJOUT$obj $src" >> $MAKEFILE
- echo >> $MAKEFILE
-else
- echo "$obj: \\" >> $MAKEFILE
- echo " $NGX_MODULES_C $deps" >> $MAKEFILE
- echo " \$(CC) $COMPOPT $args \\" >> $MAKEFILE
- echo " $OBJOUT$obj \\" >> $MAKEFILE
- echo " $src" >> $MAKEFILE
- echo >> $MAKEFILE
-fi
+cat << END >> $NGX_MAKEFILE
+
+$ngx_modules_obj: \$(CORE_DEPS)$ngx_cont$ngx_modules_c
+ $ngx_cc$ngx_tab$ngx_objout$ngx_modules_obj$ngx_tab$ngx_modules_c
+END
-# core sources
-for src in $CORE_SRCS
+# the core sources
+
+for ngx_src in $CORE_SRCS
do
- obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/" -e "s/\.S\$/.$OBJEXT/"`
- obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
- src=`echo $src | sed -e "s/\//$DIRSEP/g"`
-
- if [ $MAKE_SL = YES ]; then
- echo "$obj: $src $deps" >> $MAKEFILE
- echo " \$(CC) $COMPOPT $args $OBJOUT$obj $src" >> $MAKEFILE
- echo >> $MAKEFILE
- else
- echo "$obj: \\" >> $MAKEFILE
- echo " $src $deps" >> $MAKEFILE
- echo " \$(CC) $COMPOPT $args \\" >> $MAKEFILE
- echo " $OBJOUT$obj \\" >> $MAKEFILE
- echo " $src" >> $MAKEFILE
- echo >> $MAKEFILE
- fi
+
+ ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
+ ngx_obj=`echo $ngx_src \
+ | sed -e "s/^\(.*\.\)cpp$/$ngx_objs_dir\1$ngx_objext/g" \
+ -e "s/^\(.*\.\)cc$/$ngx_objs_dir\1$ngx_objext/g" \
+ -e "s/^\(.*\.\)c$/$ngx_objs_dir\1$ngx_objext/g" \
+ -e "s/^\(.*\.\)S$/$ngx_objs_dir\1$ngx_objext/g"`
+
+ cat << END >> $NGX_MAKEFILE
+
+$ngx_obj: \$(CORE_DEPS)$ngx_cont$ngx_src
+ $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src
+
+END
+
done
-# http sources
+# the http sources
if [ $HTTP = YES ]; then
- deps="\$(CORE_DEPS) \$(HTTP_DEPS)"
-
- if [ $PCH != NO ]; then
- args="\$(CFLAGS) $USEPCH \$(ALL_INCS)"
+ if test -n "$NGX_PCH"; then
+ ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
else
- args="\$(CFLAGS) $USEPCH \$(CORE_INCS) \$(HTTP_INCS)"
+ ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(HTTP_INCS)"
fi
- for src in $HTTP_SRCS
+ for ngx_src in $HTTP_SRCS
do
- obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/"`
- obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
- src=`echo $src | sed -e "s/\//$DIRSEP/g"`
-
- if [ $MAKE_SL = YES ]; then
- echo "$obj: $src $deps" >> $MAKEFILE
- echo " \$(CC) $COMPOPT $args $OBJOUT$obj $src" >> $MAKEFILE
- echo >> $MAKEFILE
- else
- echo "$obj: \\" >> $MAKEFILE
- echo " $src $deps" >> $MAKEFILE
- echo " \$(CC) $COMPOPT $args \\" >> $MAKEFILE
- echo " $OBJOUT$obj \\" >> $MAKEFILE
- echo " $src" >> $MAKEFILE
- echo >> $MAKEFILE
- fi
- done
+
+ ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
+ ngx_obj=`echo $ngx_src \
+ | sed -e "s/^\(.*\.\)cpp$/$ngx_objs_dir\1$ngx_objext/g" \
+ -e "s/^\(.*\.\)cc$/$ngx_objs_dir\1$ngx_objext/g" \
+ -e "s/^\(.*\.\)c$/$ngx_objs_dir\1$ngx_objext/g" \
+ -e "s/^\(.*\.\)S$/$ngx_objs_dir\1$ngx_objext/g"`
+
+ cat << END >> $NGX_MAKEFILE
+
+$ngx_obj: \$(CORE_DEPS) \$(HTTP_DEPS)$ngx_cont$ngx_src
+ $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src
+
+END
+
+ done
fi
-# imap sources
+# the imap sources
if [ $IMAP = YES ]; then
- deps="\$(CORE_DEPS) \$(IMAP_DEPS)"
-
- if [ $PCH != NO ]; then
- args="\$(CFLAGS) $USEPCH \$(ALL_INCS)"
+ if test -n "$NGX_PCH"; then
+ ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
else
- args="\$(CFLAGS) $USEPCH \$(CORE_INCS) \$(IMAP_INCS)"
+ ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) \$(CORE_INCS) \$(IMAP_INCS)"
fi
- for src in $IMAP_SRCS
+ for ngx_src in $IMAP_SRCS
do
- obj=`echo $src | sed -e "s/\.c\$/.$OBJEXT/"`
- obj=`echo $OBJS/$obj | sed -e "s/\//$DIRSEP/g"`
- src=`echo $src | sed -e "s/\//$DIRSEP/g"`
-
- if [ $MAKE_SL = YES ]; then
- echo "$obj: $src $deps" >> $MAKEFILE
- echo " \$(CC) $COMPOPT $args $OBJOUT$obj $src" >> $MAKEFILE
- echo >> $MAKEFILE
- else
- echo "$obj: \\" >> $MAKEFILE
- echo " $src $deps" >> $MAKEFILE
- echo " \$(CC) $COMPOPT $args \\" >> $MAKEFILE
- echo " $OBJOUT$obj \\" >> $MAKEFILE
- echo " $src" >> $MAKEFILE
- echo >> $MAKEFILE
- fi
- done
+
+ ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
+ ngx_obj=`echo $ngx_src \
+ | sed -e "s/^\(.*\.\)cpp$/$ngx_objs_dir\1$ngx_objext/g" \
+ -e "s/^\(.*\.\)cc$/$ngx_objs_dir\1$ngx_objext/g" \
+ -e "s/^\(.*\.\)c$/$ngx_objs_dir\1$ngx_objext/g" \
+ -e "s/^\(.*\.\)S$/$ngx_objs_dir\1$ngx_objext/g"`
+
+ cat << END >> $NGX_MAKEFILE
+
+$ngx_obj: \$(CORE_DEPS) \$(IMAP_DEPS)$ngx_cont$ngx_src
+ $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src
+
+END
+
+ done
fi
-# precompiled headers
+# the precompiled headers
+
+if test -n "$NGX_PCH"; then
+ echo "#include <ngx_config.h>" > $OBJS/ngx_pch.c
+
+ ngx_pch="src/core/ngx_config.h $OS_CONFIG $OBJS/ngx_auto_config.h"
+ ngx_pch=`echo "$NGX_PCH: $ngx_pch" | sed -e "s/\//$ngx_regex_dirsep/g"`
+
+ ngx_src="\$(CC) \$(CFLAGS) $NGX_BUILD_PCH $ngx_compile_opt \$(ALL_INCS)"
+ ngx_src="$ngx_src $ngx_objout$OBJS/ngx_pch.obj $OBJS/ngx_pch.c"
+ ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
+
+ cat << END >> $NGX_MAKEFILE
-if [ $PCH != NO ]; then
- echo "#include <ngx_config.h>" > $OBJS/pch.c
+$ngx_pch
+ $ngx_src
- pch="$PCH: src/core/ngx_config.h $OS_CONFIG $OBJS/ngx_auto_config.h"
- pch=`echo $pch | sed -e "s/\//$DIRSEP/g"`
- src="\$(CC) \$(CFLAGS) $BUILDPCH $COMPOPT \$(ALL_INCS)"
- src="$src $OBJOUT$OBJS/pch.obj $OBJS/pch.c"
- src=`echo $src | sed -e "s/\//$DIRSEP/g"`
+END
- echo "$pch" >> $MAKEFILE
- echo " $src" >> $MAKEFILE
- echo >> $MAKEFILE
fi
diff --git a/auto/options b/auto/options
index 259c049ad..75e93766e 100644
--- a/auto/options
+++ b/auto/options
@@ -1,21 +1,25 @@
# Copyright (C) Igor Sysoev
+
help=no
PREFIX=
SBIN_PATH=
CONF_PATH=
-HTTP_LOG_PATH=
ERROR_LOG_PATH=
PID_PATH=
+NGX_USER=
+NGX_GROUP=
+HTTP_LOG_PATH=
-CC=gcc
+CC=${CC:-gcc}
CPP=
-OBJS=objs
+NGX_OBJS=objs
DEBUG=NO
-CC_OPT=
+NGX_CC_OPT=
+NGX_LD_OPT=
CPU=NO
TEST_BUILD_DEVPOLL=NO
@@ -77,10 +81,12 @@ do
--conf-path=*) CONF_PATH="$value" ;;
--error-log-path=*) ERROR_LOG_PATH="$value" ;;
--pid-path=*) PID_PATH="$value" ;;
+ --user=*) NGX_USER="$value" ;;
+ --group=*) NGX_GROUP="$value" ;;
--crossbuild=*) PLATFORM="$value" ;;
- --builddir=*) OBJS="$value" ;;
+ --builddir=*) NGX_OBJS="$value" ;;
--with-rtsig_module) EVENT_RTSIG=YES ;;
--with-select_module) EVENT_SELECT=YES ;;
@@ -109,7 +115,8 @@ do
--with-cc=*) CC="$value" ;;
--with-cpp=*) CPP="$value" ;;
- --with-cc-opt=*) CC_OPT="$value" ;;
+ --with-cc-opt=*) NGX_CC_OPT="$value" ;;
+ --with-ld-opt=*) NGX_LD_OPT="$value" ;;
--with-cpu-opt=*) CPU="$value" ;;
--with-debug) DEBUG=YES ;;
@@ -140,24 +147,35 @@ done
if [ $help = yes ]; then
- echo
- echo " --help this message"
- echo
- echo " --without-select_module disable select_module"
- echo " --without-poll_module disable poll_module"
+cat << END
+
+ --help this message
+
+ --user=USER set non-privilege user
+ for the worker processes
+ --group=GROUP set non-privilege group
+ for the worker processes
+
+ --with-select_module enable select module
+ --without-select_module disable select module
+ --with-poll_module enable poll module
+ --without-poll_module disable poll module
+
+ --without-http_charset_module disable ngx_http_charset_module
+ --without-http_rewrite_module disable ngx_http_rewrite_module
+ --without-http_gzip_module disable ngx_http_gzip_module
+ --without-http_proxy_module disable ngx_http_proxy_module
- echo " --without-http_rewrite_module disable http_rewrite_module"
- echo " --without-http_gzip_module disable http_gzip_module"
- echo " --without-http_proxy_module disable http_proxy_module"
+ --with-cc-opt=OPTIONS additional options for compiler
+ --with-ld-opt=OPTIONS additional options for linker
- echo " --with-cc=NAME name of or path to C compiler"
- echo
+ --with-pcre=DIR path to PCRE library
+ --with-md5=DIR path to md5 library
+ --with-zlib=DIR path to zlib library
+ --with-openssl=DIR path to OpenSSL library
- echo " --with-pcre=DIR path to PCRE library"
- echo " --with-md5=DIR path to md5 library"
- echo " --with-zlib=DIR path to zlib library"
- echo
+END
exit 1
fi
@@ -181,11 +199,22 @@ if [ ".$PLATFORM" = ".win32" -a $EVENT_POLL = YES ]; then
fi
-if [ ".$PREFIX" = "." ]; then
+if test -z "$PREFIX"; then
PREFIX=/usr/local/nginx
fi
+if test -z "$NGX_GROUP"; then
+ NGX_GROUP=NGX_USER
+fi
+
+
+if test -z "$NGX_USER"; then
+ NGX_USER=nobody
+ NGX_GROUP=nobody
+fi
+
+
case ".$SBIN_PATH" in
./*)
;;
diff --git a/auto/os/conf b/auto/os/conf
index abffbe3d8..5154f2bba 100644
--- a/auto/os/conf
+++ b/auto/os/conf
@@ -31,21 +31,7 @@ case $PLATFORM in
;;
win32)
- CORE_INCS="$WIN32_INCS"
- CORE_DEPS="$WIN32_DEPS"
- CORE_SRCS="$WIN32_SRCS $IOCP_SRCS"
- OS_CONFIG="$WIN32_CONFIG"
- EVENT_MODULES="$EVENT_MODULES $IOCP_MODULE"
- EVENT_FOUND=YES
-
- if [ $EVENT_SELECT = NO ]; then
- CORE_SRCS="$CORE_SRCS $SELECT_SRCS"
- EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE"
- fi
-
- have=HAVE_AIO . auto/have
- have=HAVE_IOCP . auto/have
- CORE_LIBS="$CORE_LIBS ws2_32.lib"
+ . auto/os/win32
;;
*)
@@ -55,3 +41,56 @@ case $PLATFORM in
;;
esac
+
+
+if [ $PLATFORM != win32 ]; then
+
+ ngx_feature="/dev/poll"
+ ngx_feature_name="devpoll"
+ ngx_feature_run=no
+ ngx_feature_incs="#include <sys/devpoll.h>"
+ ngx_feature_libs=
+ ngx_feature_test="int n, dp; struct dvpoll dvp;
+ dp = 0;
+ dvp.dp_fds = NULL;
+ dvp.dp_nfds = 0;
+ dvp.dp_timeout = 0;
+ n = ioctl(dp, DP_POLL, &dvp)"
+ . auto/feature
+
+ if [ $ngx_found = yes ]; then
+ have=HAVE_DEVPOLL . auto/have
+ CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS"
+ EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE"
+ EVENT_FOUND=YES
+ fi
+
+
+ if test -z "$NGX_KQUEUE_CHECKED"; then
+ ngx_feature="kqueue"
+ ngx_feature_name="kqueue"
+ ngx_feature_run=no
+ ngx_feature_incs="#include <sys/event.h>"
+ ngx_feature_libs=
+ ngx_feature_test="int kq; kq = kqueue()"
+ . auto/feature
+
+ if [ $ngx_found = yes ]; then
+
+ have=HAVE_KQUEUE . auto/have
+ have=HAVE_CLEAR_EVENT . auto/have
+ EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
+ CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
+ EVENT_FOUND=YES
+
+ ngx_feature="kqueue's NOTE_LOWAT"
+ ngx_feature_name="HAVE_LOWAT_EVENT"
+ ngx_feature_run=no
+ ngx_feature_incs="#include <sys/event.h>"
+ ngx_feature_libs=
+ ngx_feature_test="struct kevent kev;
+ kev.fflags = NOTE_LOWAT;"
+ . auto/feature
+ fi
+ fi
+fi
diff --git a/auto/os/freebsd b/auto/os/freebsd
index 90cb49702..f08ef97b0 100644
--- a/auto/os/freebsd
+++ b/auto/os/freebsd
@@ -2,19 +2,33 @@
# Copyright (C) Igor Sysoev
+cat << END >> $NGX_AUTO_HEADERS_H
+
+#ifndef NGX_FREEBSD
+#define NGX_FREEBSD 1
+#endif
+
+END
+
+
CORE_INCS="$UNIX_INCS"
CORE_DEPS="$UNIX_DEPS $FREEBSD_DEPS"
CORE_SRCS="$UNIX_SRCS $FREEBSD_SRCS"
-PIPE="-pipe"
+ngx_spacer='
+'
-# __FreeBSD_version is the best way to determine whether
-# some capability exists and is safe to use
+# __FreeBSD_version and sysctl kern.osreldate are the best ways
+# to determine whether some capability exists and is safe to use.
+# __FreeBSD_version is used for the testing of the build enviroment.
+# sysctl kern.osreldate is used for the testing of the kernel capabilities.
version=`grep "#define __FreeBSD_version" /usr/include/osreldate.h \
| sed -e 's/^.* \(.*\)$/\1/'`
+osreldate=`/sbin/sysctl -n kern.osreldate`
+
# setproctitle() in libutil
@@ -28,7 +42,7 @@ fi
# sendfile
-if [ $version -gt 300007 ]; then
+if [ $osreldate -gt 300007 ]; then
echo " + using sendfile()"
have=HAVE_SENDFILE . auto/have
@@ -38,8 +52,8 @@ fi
# kqueue
-if [ \( $version -lt 500000 -a $version -ge 410000 \) \
- -o $version -ge 500011 ]
+if [ \( $osreldate -lt 500000 -a $osreldate -ge 410000 \) \
+ -o $osreldate -ge 500011 ]
then
echo " + using kqueue"
@@ -50,6 +64,8 @@ then
EVENT_FOUND=YES
fi
+NGX_KQUEUE_CHECKED=YES
+
# kqueue's NOTE_LAWAT
diff --git a/auto/os/linux b/auto/os/linux
index 8576ea680..e68a0d27d 100644
--- a/auto/os/linux
+++ b/auto/os/linux
@@ -2,15 +2,23 @@
# Copyright (C) Igor Sysoev
+cat << END >> $NGX_AUTO_HEADERS_H
+
+#ifndef NGX_LINUX
+#define NGX_LINUX 1
+#endif
+
+END
+
CORE_INCS="$UNIX_INCS"
CORE_DEPS="$UNIX_DEPS $LINUX_DEPS"
CORE_SRCS="$UNIX_SRCS $LINUX_SRCS"
EVENT_MODULES="$EVENT_MODULES"
-PIPE="-pipe"
-
+ngx_spacer='
+'
-CC_TEST_FLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
+CC_AUX_FLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
# Linux kernel version
@@ -31,14 +39,18 @@ fi
# epoll, EPOLLET version
-ngx_func="epoll";
-ngx_func_inc="#include <sys/epoll.h>"
-ngx_func_test="int efd = 0, fd = 1, n;
- struct epoll_event ee;
- ee.events = EPOLLIN|EPOLLOUT|EPOLLET;
- ee.data.ptr = NULL;
- n = epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ee)"
-. auto/func
+ngx_feature="epoll"
+ngx_feature_name="epoll"
+ngx_feature_run=yes
+ngx_feature_incs="#include <sys/epoll.h>"
+ngx_feature_libs=
+ngx_feature_test="int efd = 0, fd = 1, n;
+ struct epoll_event ee;
+ ee.events = EPOLLIN|EPOLLOUT|EPOLLET;
+ ee.data.ptr = NULL;
+ efd = epoll_create(100);
+ if (efd == -1) return 1;"
+. auto/feature
if [ $ngx_found = yes ]; then
have=HAVE_EPOLL . auto/have
@@ -51,13 +63,16 @@ fi
# sendfile()
-CC_TEST_FLAGS="-D_GNU_SOURCE"
-ngx_func="sendfile()";
-ngx_func_inc="#include <sys/sendfile.h>"
-ngx_func_test="int s = 0, fd = 1;
- ssize_t n; off_t off = 0;
- n = sendfile(s, fd, &off, 1)"
-. auto/func
+CC_AUX_FLAGS="-D_GNU_SOURCE"
+ngx_feature="sendfile()"
+ngx_feature_name="sendfile"
+ngx_feature_run=no
+ngx_feature_incs="#include <sys/sendfile.h>"
+ngx_feature_libs=
+ngx_feature_test="int s = 0, fd = 1;
+ ssize_t n; off_t off = 0;
+ n = sendfile(s, fd, &off, 1)"
+. auto/feature
if [ $ngx_found = yes ]; then
CORE_SRCS="$CORE_SRCS $LINUX_SENDFILE_SRCS"
@@ -66,17 +81,26 @@ fi
# sendfile64()
-CC_TEST_FLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE"
-ngx_func="sendfile64()"; . auto/func
+CC_AUX_FLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
+ngx_feature="sendfile64()"
+ngx_feature_name="HAVE_SENDFILE64"
+ngx_feature_run=no
+ngx_feature_incs="#include <sys/sendfile.h>"
+ngx_feature_libs=
+ngx_feature_test="int s = 0, fd = 1;
+ ssize_t n; off_t off = 0;
+ n = sendfile(s, fd, &off, 1)"
+. auto/feature
-# prctl(PR_SET_DUMPABLE)
+ngx_include="sys/prctl.h"; . auto/include
-ngx_func="prctl()";
-ngx_func_inc="#include <sys/prctl.h>"
-ngx_func_test="prctl(PR_SET_DUMPABLE, 1, 0, 0, 0)"
-. auto/func
+# prctl(PR_SET_DUMPABLE)
-if [ $ngx_found = yes ]; then
- have=HAVE_PR_SET_DUMPABLE . auto/have
-fi
+ngx_feature="prctl(PR_SET_DUMPABLE)"
+ngx_feature_name="HAVE_PR_SET_DUMPABLE"
+ngx_feature_run=yes
+ngx_feature_incs="#include <sys/prctl.h>"
+ngx_feature_libs=
+ngx_feature_test="if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) return 1"
+. auto/feature
diff --git a/auto/os/solaris b/auto/os/solaris
index 29497ff5f..62708cd10 100644
--- a/auto/os/solaris
+++ b/auto/os/solaris
@@ -2,6 +2,14 @@
# Copyright (C) Igor Sysoev
+cat << END >> $NGX_AUTO_HEADERS_H
+
+#ifndef NGX_SOLARIS
+#define NGX_SOLARIS 1
+#endif
+
+END
+
CORE_INCS="$UNIX_INCS"
CORE_DEPS="$UNIX_DEPS $SOLARIS_DEPS"
CORE_SRCS="$UNIX_SRCS $SOLARIS_SRCS "
@@ -9,40 +17,17 @@ EVENT_MODULES="$EVENT_MODULES"
CORE_LIBS="$CORE_LIBS -lsocket -lnsl -lrt"
-# the Solaris's make support
-MAKE_SL=YES
+# Solaris's make does not support a blank line between target and rules
+ngx_spacer=
-
-CC_TEST_FLAGS="-D_FILE_OFFSET_BITS=64"
-
-case $PLATFORM in
-
- SunOS:5.[89]:* | SunOS:5.10:*)
- PIPE="-pipe"
- ;;
-
- *)
- # Solaris 7's /usr/ccs/bin/as does not support "-pipe"
- ;;
-
-esac
+CC_AUX_FLAGS="-D_FILE_OFFSET_BITS=64 -lrt"
case $PLATFORM in
*:sun4u)
+ # "-mcpu=v9" enables the "casa" assembler instruction
CFLAGS="$CFLAGS -mcpu=v9"
-
- if [ ".$CPU" = ".sparc64" ]; then
- CFLAGS="$CFLAGS -m64"
- CPU_OPT="-m64"
- CORE_LINK="$CORE_LINK -m64"
-
- CC_TEST_FLAGS="$CC_TEST_FLAGS -mcpu=v9 -m64"
- fi
- ;;
-
- *)
;;
esac
@@ -57,23 +42,15 @@ if [ $ZLIB_ASM != NO ]; then
fi
-ngx_inc="sys/devpoll.h"; . auto/inc
-
-if [ $ngx_found = yes ]; then
- have=HAVE_DEVPOLL . auto/have
- CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS"
- EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE"
- EVENT_FOUND=YES
-fi
-
-
-ngx_func="sendfilev()";
-ngx_func_inc="#include <sys/sendfile.h>"
-ngx_func_libs="-lsendfile"
-ngx_func_test="int fd = 1; sendfilevec_t vec[1];
- size_t sent; ssize_t n;
- n = sendfilev(fd, vec, 1, &sent)"
-. auto/func
+ngx_feature="sendfilev()"
+ngx_feature_name="sendfile"
+ngx_feature_run=no
+ngx_feature_incs="#include <sys/sendfile.h>"
+ngx_feature_libs="-lsendfile"
+ngx_feature_test="int fd = 1; sendfilevec_t vec[1];
+ size_t sent; ssize_t n;
+ n = sendfilev(fd, vec, 1, &sent)"
+. auto/feature
if [ $ngx_found = yes ]; then
diff --git a/auto/os/win32 b/auto/os/win32
new file mode 100644
index 000000000..9e83e67fe
--- /dev/null
+++ b/auto/os/win32
@@ -0,0 +1,29 @@
+
+# Copyright (C) Igor Sysoev
+
+
+cat << END >> $NGX_AUTO_HEADERS_H
+
+#ifndef NGX_WIN32
+#define NGX_WIN32 1
+#endif
+
+END
+
+
+CORE_INCS="$WIN32_INCS"
+CORE_DEPS="$WIN32_DEPS"
+CORE_SRCS="$WIN32_SRCS $IOCP_SRCS"
+OS_CONFIG="$WIN32_CONFIG"
+CORE_LIBS="$CORE_LIBS ws2_32.lib"
+
+EVENT_MODULES="$EVENT_MODULES $IOCP_MODULE"
+EVENT_FOUND=YES
+
+if [ $EVENT_SELECT = NO ]; then
+ CORE_SRCS="$CORE_SRCS $SELECT_SRCS"
+ EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE"
+fi
+
+have=HAVE_AIO . auto/have
+have=HAVE_IOCP . auto/have
diff --git a/auto/sources b/auto/sources
index 6e21a4134..1622dcd9c 100644
--- a/auto/sources
+++ b/auto/sources
@@ -303,6 +303,6 @@ IMAP_DEPS="src/imap/ngx_imap.h"
IMAP_MODULE=ngx_imap_module
IMAP_SRCS="src/imap/ngx_imap.c \
- src/imap/ngx_imap_handler.c \
- src/imap/ngx_imap_parse.c \
- src/imap/ngx_imap_proxy.c"
+ src/imap/ngx_imap_handler.c \
+ src/imap/ngx_imap_parse.c \
+ src/imap/ngx_imap_proxy.c"
diff --git a/auto/stubs b/auto/stubs
new file mode 100644
index 000000000..af37c5420
--- /dev/null
+++ b/auto/stubs
@@ -0,0 +1,8 @@
+
+# Copyright (C) Igor Sysoev
+
+
+have=NGX_USE_HTTP_FILE_CACHE_UNIQ . auto/have
+have=NGX_SUPPRESS_WARN . auto/have
+
+have=NGX_SMP . auto/have
diff --git a/auto/types/sizeof b/auto/types/sizeof
index ac22e759d..a7094e429 100644
--- a/auto/types/sizeof
+++ b/auto/types/sizeof
@@ -2,9 +2,14 @@
# Copyright (C) Igor Sysoev
-echo $ngx_n "checking for $ngx_type size ..." $ngx_c
-echo >> $NGX_ERR
-echo "checking for $ngx_type size" >> $NGX_ERR
+echo $ngx_n "checking for $ngx_type size ...$ngx_c"
+
+cat << END >> $NGX_AUTOCONF_ERR
+
+----------------------------------------
+checking for $ngx_type size
+
+END
ngx_size=
@@ -12,11 +17,11 @@ cat << END > $NGX_AUTOTEST.c
#include <sys/types.h>
#include <sys/time.h>
-$NGX_UNISTD_H
+$NGX_INCLUDE_UNISTD_H
#include <signal.h>
#include <sys/resource.h>
-$NGX_INTTYPES_H
-$NGX_AUTO_CONFIG
+$NGX_INCLUDE_INTTYPES_H
+$NGX_INCLUDE_AUTO_CONFIG_H
int main() {
printf("%d", sizeof($ngx_type));
@@ -25,14 +30,19 @@ int main() {
END
-eval "$CC $CC_TEST_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c >> $NGX_ERR 2>&1"
+
+ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
+eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
+
if [ -x $NGX_AUTOTEST ]; then
ngx_size=`$NGX_AUTOTEST`
echo " $ngx_size bytes"
fi
-rm $NGX_AUTOTEST*
+
+rm -f $NGX_AUTOTEST
+
case $ngx_size in
4)
@@ -58,5 +68,13 @@ case $ngx_size in
*)
echo
echo "$0: error: can not detect $ngx_type size"
+
+ echo "----------" >> $NGX_AUTOCONF_ERR
+ cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR
+ echo "----------" >> $NGX_AUTOCONF_ERR
+ echo $ngx_test >> $NGX_AUTOCONF_ERR
+ echo "----------" >> $NGX_AUTOCONF_ERR
+
exit 1
esac
+
diff --git a/auto/types/typedef b/auto/types/typedef
index 9762f4812..4b8964396 100644
--- a/auto/types/typedef
+++ b/auto/types/typedef
@@ -2,13 +2,18 @@
# Copyright (C) Igor Sysoev
-echo $ngx_n "checking for $ngx_type ..." $ngx_c
-echo >> $NGX_ERR
-echo "checking for $ngx_type" >> $NGX_ERR
+echo $ngx_n "checking for $ngx_type ...$ngx_c"
-found=no
+cat << END >> $NGX_AUTOCONF_ERR
-for type in $ngx_type $ngx_types
+----------------------------------------
+checking for $ngx_type
+
+END
+
+ngx_found=no
+
+for ngx_try in $ngx_type $ngx_types
do
cat << END > $NGX_AUTOTEST.c
@@ -19,42 +24,51 @@ do
#include <sys/time.h>
#include <sys/resource.h>
#include <netinet/in.h>
-$NGX_INTTYPES_H
+$NGX_INCLUDE_INTTYPES_H
int main() {
- $type i = 0;
+ $ngx_try i = 0;
return 0;
}
END
- eval "$CC -o $NGX_AUTOTEST $NGX_AUTOTEST.c >> $NGX_ERR 2>&1"
+ ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c"
+ eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
if [ -x $NGX_AUTOTEST ]; then
- if [ $type = $ngx_type ]; then
+ if [ $ngx_try = $ngx_type ]; then
echo " found"
- found=yes
+ ngx_found=yes
else
- echo ", $type used"
- found=$type
+ echo ", $ngx_try used"
+ ngx_found=$ngx_try
fi
fi
- rm $NGX_AUTOTEST*
+ rm -f $NGX_AUTOTEST
+
+ if [ $ngx_found = no ]; then
+ echo $ngx_n " $ngx_try not found$ngx_c"
+
+ echo "----------" >> $NGX_AUTOCONF_ERR
+ cat $NGX_AUTOTEST.c >> $NGX_AUTOCONF_ERR
+ echo "----------" >> $NGX_AUTOCONF_ERR
+ echo $ngx_test >> $NGX_AUTOCONF_ERR
+ echo "----------" >> $NGX_AUTOCONF_ERR
- if [ $found = no ]; then
- echo $ngx_n " $type not found" $ngx_c
else
break
fi
done
-if [ $found = no ]; then
+if [ $ngx_found = no ]; then
echo
echo "$0: error: can not define $ngx_type"
+
exit 1
fi
-if [ $found != yes ]; then
- echo "typedef $found $ngx_type;" >> $NGX_AUTO_CONFIG_H
+if [ $ngx_found != yes ]; then
+ echo "typedef $ngx_found $ngx_type;" >> $NGX_AUTO_CONFIG_H
fi
diff --git a/auto/types/uintptr_t b/auto/types/uintptr_t
index a1bb78a89..e7d8d5ca0 100644
--- a/auto/types/uintptr_t
+++ b/auto/types/uintptr_t
@@ -2,7 +2,7 @@
# Copyright (C) Igor Sysoev
-echo $ngx_n "checking for uintptr_t ... " $ngx_c
+echo $ngx_n "checking for uintptr_t ...$ngx_c"
echo >> $NGX_ERR
echo "checking for uintptr_t" >> $NGX_ERR
diff --git a/auto/unix b/auto/unix
index 4ba7d605f..ec0e3952d 100755
--- a/auto/unix
+++ b/auto/unix
@@ -2,7 +2,7 @@
# Copyright (C) Igor Sysoev
-CC_WARN=$CC
+CC_WARN=
ngx_fmt_collect=yes
# C types
@@ -23,7 +23,7 @@ eval ngx_formats=\${ngx_${ngx_ptr_size}_fmt}; . auto/fmt/ptrfmt
# POSIX types
-NGX_AUTO_CONFIG="#include \"../$NGX_AUTO_CONFIG_H\""
+NGX_INCLUDE_AUTO_CONFIG_H="#include \"../$NGX_AUTO_CONFIG_H\""
ngx_type="uint64_t"; ngx_types="u_int64_t"; . auto/types/typedef
@@ -72,75 +72,98 @@ eval ngx_formats=\${ngx_${ngx_size}_fmt}; . auto/fmt/fmt
# syscalls, libc calls and some features
-ngx_feature_libs=
-ngx_func_libs=
-
-
-ngx_func="pread()"
-ngx_func_inc=
-ngx_func_test="char buf[1]; ssize_t n; n = pread(0, buf, 1, 0)"
-. auto/func
+ngx_feature="pread()"
+ngx_feature_name="pread"
+ngx_feature_run=no
+ngx_feature_incs=
+ngx_feature_libs=
+ngx_feature_test="char buf[1]; ssize_t n; n = pread(0, buf, 1, 0)"
+. auto/feature
-ngx_func="pwrite()"
-ngx_func_inc=
-ngx_func_test="char buf[1]; ssize_t n; n = pwrite(1, buf, 1, 0)"
-. auto/func
+ngx_feature="pwrite()"
+ngx_feature_name="pwrite"
+ngx_feature_run=no
+ngx_feature_incs=
+ngx_feature_libs=
+ngx_feature_test="char buf[1]; ssize_t n; n = pwrite(1, buf, 1, 0)"
+. auto/feature
-#ngx_func="strsignal()"
-#ngx_func_inc="#include <string.h>"
-#ngx_func_test="char *s = strsignal(1)"
-#. auto/func
+ngx_feature="strerror_r()"
+ngx_feature_name="strerror_r"
+ngx_feature_run=no
+ngx_feature_incs="#include <string.h>"
+ngx_feature_libs=
+ngx_feature_test="char buf[20]; int n; n = strerror_r(1, buf, 20)"
+. auto/feature
-ngx_func="strerror_r()"
-ngx_func_inc="#include <string.h>"
-ngx_func_test="char buf[20]; int n; n = strerror_r(1, buf, 20)"
-. auto/func
+ngx_feature="gnu_strerror_r()"
+ngx_feature_name="gnu_strerror_r"
+ngx_feature_run=no
+ngx_feature_incs="#include <string.h>"
+ngx_feature_libs=
+ngx_feature_test="char buf[20], *str; str = strerror_r(1, buf, 20)"
+. auto/feature
-ngx_func="gnu_strerror_r()"
-ngx_func_inc="#include <string.h>"
-ngx_func_test="char buf[20], *str; str = strerror_r(1, buf, 20)"
-. auto/func
+ngx_feature="localtime_r()"
+ngx_feature_name="localtime_r"
+ngx_feature_run=no
+ngx_feature_incs="#include <time.h>"
+ngx_feature_libs=
+ngx_feature_test="struct tm t; time_t c=0; localtime_r(&c, &t)"
+. auto/feature
-ngx_func="localtime_r()"
-ngx_func_inc="#include <time.h>"
-ngx_func_test="struct tm t; time_t c=0; localtime_r(&c, &t)"
-. auto/func
+ngx_feature="posix_memalign()"
+ngx_feature_name="posix_memalign"
+ngx_feature_run=no
+ngx_feature_incs="#include <stdlib.h>"
+ngx_feature_libs=
+ngx_feature_test="void *p; int n; n = posix_memalign(&p, 4096, 4096)"
+. auto/feature
-ngx_func="posix_memalign()"
-ngx_func_inc="#include <stdlib.h>"
-ngx_func_test="void *p; int n; n = posix_memalign(&p, 4096, 4096)"
-. auto/func
+ngx_feature="memalign()"
+ngx_feature_name="memalign"
+ngx_feature_run=no
+ngx_feature_incs="#include <stdlib.h>"
+ngx_feature_libs=
+ngx_feature_test="void *p; p = memalign(4096, 4096)"
+. auto/feature
-ngx_func="memalign()"
-ngx_func_inc="#include <stdlib.h>"
-ngx_func_test="void *p; p = memalign(4096, 4096)"
-. auto/func
+ngx_feature="sched_yield()"
+ngx_feature_name="HAVE_SCHED_YIELD"
+ngx_feature_run=no
+ngx_feature_incs="#include <sched.h>"
+ngx_feature_libs=
+ngx_feature_test="sched_yield()"
+. auto/feature
ngx_feature="mmap(MAP_ANON|MAP_SHARED)"
ngx_feature_name="MAP_ANON"
-ngx_feature_inc="#include <sys/mman.h>"
+ngx_feature_run=yes
+ngx_feature_incs="#include <sys/mman.h>"
+ngx_feature_libs=
ngx_feature_test="void *p;
p = mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_ANON|MAP_SHARED, -1, 0);
if (p == MAP_FAILED) return 1;"
-ngx_feature_run=yes
. auto/feature
ngx_feature='mmap("/dev/zero", MAP_SHARED)'
ngx_feature_name="MAP_DEVZERO"
-ngx_feature_inc="#include <sys/mman.h>
+ngx_feature_run=yes
+ngx_feature_incs="#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>"
+ngx_feature_libs=
ngx_feature_test='void *p; int fd;
fd = open("/dev/zero", O_RDWR);
p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
@@ -150,8 +173,10 @@ ngx_feature_test='void *p; int fd;
ngx_feature="System V shared memory"
ngx_feature_name="SYSVSHM"
-ngx_feature_inc="#include <sys/ipc.h>
+ngx_feature_run=yes
+ngx_feature_incs="#include <sys/ipc.h>
#include <sys/shm.h>"
+ngx_feature_libs=
ngx_feature_test="int id;
id = shmget(IPC_PRIVATE, 4096, (SHM_R|SHM_W|IPC_CREAT));
if (id == -1) return 1;
@@ -159,41 +184,39 @@ ngx_feature_test="int id;
. auto/feature
-
ngx_feature="struct sockaddr_in.sin_len"
ngx_feature_name="sin_len"
-ngx_feature_inc="#include <sys/socket.h>
+ngx_feature_run=no
+ngx_feature_incs="#include <sys/socket.h>
#include <netinet/in.h>"
+ngx_feature_libs=
ngx_feature_test="struct sockaddr_in sa; sa.sin_len = 5"
-ngx_feature_run=no
. auto/feature
ngx_feature="struct msghdr.msg_control"
ngx_feature_name="msghdr_msg_control"
-ngx_feature_inc="#include <sys/socket.h>"
+ngx_feature_run=no
+ngx_feature_incs="#include <sys/socket.h>"
+ngx_feature_libs=
ngx_feature_test="struct msghdr msg; msg.msg_control = NULL"
. auto/feature
-case $PLATFORM in
- Linux:*)
- ngx_feature_inc="#include <sys/ioctl.h>"
- ;;
-
- *)
- ngx_feature_inc="#include <sys/filio.h>"
- ;;
-esac
-
ngx_feature="ioctl(FIONBIO)"
ngx_feature_name="FIONBIO"
+ngx_feature_run=no
+ngx_feature_incs="#include <sys/ioctl.h>
+$NGX_INCLUDE_SYS_FILIO_H"
+ngx_feature_libs=
ngx_feature_test="int i; i = FIONBIO"
. auto/feature
ngx_feature="struct tm.tm_gmtoff"
ngx_feature_name="gmtoff"
-ngx_feature_inc="#include <time.h>"
+ngx_feature_run=no
+ngx_feature_incs="#include <time.h>"
+ngx_feature_libs=
ngx_feature_test="struct tm tm; tm.tm_gmtoff = 0"
. auto/feature
diff --git a/conf/nginx.conf b/conf/nginx.conf
index 00025101a..b4248b8d2 100644
--- a/conf/nginx.conf
+++ b/conf/nginx.conf
@@ -1,5 +1,5 @@
-user nobody;
+#user nobody;
worker_processes 3;
#error_log logs/error.log;
diff --git a/configure b/configure
index 6a81555d1..eb2fed051 100755
--- a/configure
+++ b/configure
@@ -8,24 +8,22 @@
. auto/sources
test -d $OBJS || mkdir $OBJS
+
+echo > $NGX_AUTO_HEADERS_H
echo > $NGX_AUTO_CONFIG_H
if [ $DEBUG = YES ]; then
have=NGX_DEBUG . auto/have
fi
-have=NGX_USE_HTTP_FILE_CACHE_UNIQ . auto/have
-have=NGX_SUPPRESS_WARN . auto/have
-
if [ "$PLATFORM" != win32 ]; then
. auto/headers
fi
+. auto/cc/conf
. auto/os/conf
. auto/modules
-
-. auto/cc
. auto/lib/conf
if [ "$PLATFORM" != win32 ]; then
@@ -40,7 +38,8 @@ if [ "$PLATFORM" != win32 ]; then
. auto/unix
fi
-have=NGX_SMP . auto/have
+# STUB
+. auto/stubs
have=NGX_PREFIX value="\"$PREFIX/\"" . auto/define
have=NGX_SBIN_PATH value="\"$SBIN_PATH\"" . auto/define
@@ -51,4 +50,7 @@ if [ ".$ERROR_LOG_PATH" != "." ]; then
fi
have=NGX_HTTP_LOG_PATH value="\"$HTTP_LOG_PATH\"" . auto/define
+have=NGX_USER value="\"$NGX_USER\"" . auto/define
+have=NGX_GROUP value="\"$NGX_GROUP\"" . auto/define
+
. auto/summary
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 9d9108094..ab85b2373 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -104,7 +104,7 @@ int main(int argc, char *const *argv, char *const *envp)
ngx_cycle_t *cycle, init_cycle;
ngx_core_conf_t *ccf;
-#if defined __FreeBSD__
+#if (NGX_FREEBSD)
ngx_debug_init();
#endif
@@ -112,7 +112,7 @@ int main(int argc, char *const *argv, char *const *envp)
ngx_time_init();
-#if (HAVE_PCRE)
+#if (NGX_PCRE)
ngx_regex_init();
#endif
@@ -136,11 +136,11 @@ int main(int argc, char *const *argv, char *const *envp)
return 1;
}
- if (ngx_getopt(&init_cycle, argc, argv) == NGX_ERROR) {
+ if (ngx_save_argv(&init_cycle, argc, argv) == NGX_ERROR) {
return 1;
}
- if (ngx_save_argv(&init_cycle, argc, argv) == NGX_ERROR) {
+ if (ngx_getopt(&init_cycle, argc, ngx_argv) == NGX_ERROR) {
return 1;
}
@@ -175,7 +175,7 @@ int main(int argc, char *const *argv, char *const *envp)
if (ngx_test_config) {
ngx_log_error(NGX_LOG_INFO, log, 0,
"the configuration file %s was tested successfully",
- init_cycle.conf_file.data);
+ cycle->conf_file.data);
return 0;
}
@@ -387,7 +387,7 @@ static ngx_int_t ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv)
ngx_argc = argc;
-#if __FreeBSD__
+#if (NGX_FREEBSD)
ngx_argv = (char **) argv;
@@ -462,28 +462,26 @@ static char *ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
#if !(WIN32)
-#if 0
if (ccf->user == (uid_t) NGX_CONF_UNSET) {
- pwd = getpwnam("nobody");
+ pwd = getpwnam(NGX_USER);
if (pwd == NULL) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
- "getpwnam(\"nobody\") failed");
+ "getpwnam(\"" NGX_USER "\") failed");
return NGX_CONF_ERROR;
}
ccf->user = pwd->pw_uid;
- grp = getgrnam("nobody");
+ grp = getgrnam(NGX_GROUP);
if (grp == NULL) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
- "getgrnam(\"nobody\") failed");
+ "getgrnam(\"" NGX_GROUP "\") failed");
return NGX_CONF_ERROR;
}
ccf->group = grp->gr_gid;
}
-#endif
if (ccf->pid.len == 0) {
ccf->pid.len = sizeof(NGX_PID_PATH) - 1;
@@ -522,6 +520,7 @@ static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_core_conf_t *ccf = conf;
+ char *group;
struct passwd *pwd;
struct group *grp;
ngx_str_t *value;
@@ -530,6 +529,14 @@ static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return "is duplicate";
}
+ if (geteuid() != 0) {
+ ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
+ "the \"user\" directive makes sense only "
+ "if the master process runs "
+ "with super-user privileges, ignored");
+ return NGX_CONF_OK;
+ }
+
value = (ngx_str_t *) cf->args->elts;
pwd = getpwnam((const char *) value[1].data);
@@ -541,14 +548,12 @@ static char *ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ccf->user = pwd->pw_uid;
- if (cf->args->nelts == 2) {
- return NGX_CONF_OK;
- }
+ group = (char *) ((cf->args->nelts == 2) ? value[1].data : value[2].data);
- grp = getgrnam((const char *) value[2].data);
+ grp = getgrnam(group);
if (grp == NULL) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
- "getgrnam(\"%s\") failed", value[2].data);
+ "getgrnam(\"%s\") failed", group);
return NGX_CONF_ERROR;
}
diff --git a/src/core/nginx.h b/src/core/nginx.h
index 82545e5c7..bac01fcc1 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
#define _NGINX_H_INCLUDED_
-#define NGINX_VER "nginx/0.1.1"
+#define NGINX_VER "nginx/0.1.2"
#define NGINX_VAR "NGINX"
#define NGX_NEWPID_EXT ".newbin"
diff --git a/src/core/ngx_buf.c b/src/core/ngx_buf.c
index a536c04de..7d379890f 100644
--- a/src/core/ngx_buf.c
+++ b/src/core/ngx_buf.c
@@ -126,12 +126,11 @@ void ngx_chain_update_chains(ngx_chain_t **free, ngx_chain_t **busy,
*busy = *out;
} else {
- for (tl = *busy; /* void */ ; tl = tl->next) {
- if (tl->next == NULL) {
- tl->next = *out;
- break;
- }
+ for (tl = *busy; tl->next; tl = tl->next) {
+ /* void */;
}
+
+ tl->next = *out;
}
*out = NULL;
diff --git a/src/core/ngx_buf.h b/src/core/ngx_buf.h
index 3e014d17a..e2d07190a 100644
--- a/src/core/ngx_buf.h
+++ b/src/core/ngx_buf.h
@@ -22,7 +22,6 @@ struct ngx_buf_s {
off_t file_pos;
off_t file_last;
- int type;
u_char *start; /* start of buffer */
u_char *end; /* end of buffer */
ngx_buf_tag_t tag;
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index 90a09d231..fb629a439 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -579,8 +579,18 @@ ngx_int_t ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name)
name->len = cycle->root.len + old.len;
- if (!(name->data = ngx_palloc(cycle->pool, name->len + 1))) {
- return NGX_ERROR;
+ if (cycle->connections) {
+ if (!(name->data = ngx_palloc(cycle->pool, name->len + 1))) {
+ return NGX_ERROR;
+ }
+
+ } else {
+
+ /* the init_cycle */
+
+ if (!(name->data = ngx_alloc(name->len + 1, cycle->log))) {
+ return NGX_ERROR;
+ }
}
p = ngx_cpymem(name->data, cycle->root.data, cycle->root.len),
diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h
index 7e3e6828c..3590fae7a 100644
--- a/src/core/ngx_config.h
+++ b/src/core/ngx_config.h
@@ -8,30 +8,32 @@
#define _NGX_CONFIG_H_INCLUDED_
+#include <ngx_auto_headers.h>
+
+
#if defined __DragonFly__ && !defined __FreeBSD__
#define __FreeBSD__ 4
#define __FreeBSD_version 480101
#endif
-#if defined __FreeBSD__
+#if (NGX_FREEBSD)
#include <ngx_freebsd_config.h>
-#elif defined __linux__
+#elif (NGX_LINUX)
#include <ngx_linux_config.h>
- /* Solaris */
-#elif defined sun && (defined __svr4__ || defined __SVR4)
+#elif (NGX_SOLARIS)
#include <ngx_solaris_config.h>
-#elif defined _WIN32
+#elif (NGX_WIN32)
#include <ngx_win32_config.h>
-#else /* posix */
+#else /* POSIX */
#include <ngx_posix_config.h>
#endif
@@ -89,8 +91,10 @@ typedef long ngx_flag_t;
#define NGX_INT64_LEN sizeof("-9223372036854775808") - 1
#define NGX_OFF_T_LEN sizeof("-9223372036854775808") - 1
+#define NGX_MAX_INT_LEN (sizeof("-9223372036854775808") - 1)
+
-#if (SOLARIS)
+#if (NGX_SOLARIS)
/* TODO: auto_conf */
#define NGX_ALIGN (_MAX_ALIGNMENT - 1) /* platform word */
diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h
index 57c7a3375..8e2ba3970 100644
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -40,7 +40,7 @@ typedef struct {
time_t post_accept_timeout; /* should be here because
of the deferred accept */
- unsigned new:1;
+ unsigned open:1;
unsigned remain:1;
unsigned ignore:1;
diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h
index 02a4a17b9..79fb009bd 100644
--- a/src/core/ngx_core.h
+++ b/src/core/ngx_core.h
@@ -54,7 +54,7 @@ typedef void (*ngx_event_handler_pt)(ngx_event_t *ev);
#include <ngx_file.h>
#include <ngx_files.h>
#include <ngx_crc.h>
-#if (HAVE_PCRE)
+#if (NGX_PCRE)
#include <ngx_regex.h>
#endif
#include <ngx_rbtree.h>
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index 38f4ad505..a1402f123 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -158,6 +158,9 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
conf.module_type = NGX_CORE_MODULE;
conf.cmd_type = NGX_MAIN_CONF;
+#if 0
+ log->log_level = NGX_LOG_DEBUG_ALL;
+#endif
if (ngx_conf_parse(&conf, &cycle->conf_file) != NGX_CONF_OK) {
ngx_destroy_pool(pool);
@@ -223,9 +226,6 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
NGX_FILE_RDWR,
NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
-#if 0
- log->log_level = NGX_LOG_DEBUG_ALL;
-#endif
ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,
"log: %0X %d \"%s\"",
&file[i], file[i].fd, file[i].name.data);
@@ -310,14 +310,14 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
}
if (nls[n].fd == -1) {
- nls[n].new = 1;
+ nls[n].open = 1;
}
}
} else {
ls = cycle->listening.elts;
for (i = 0; i < cycle->listening.nelts; i++) {
- ls[i].new = 1;
+ ls[i].open = 1;
}
}
@@ -366,7 +366,7 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
ls = cycle->listening.elts;
for (i = 0; i < cycle->listening.nelts; i++) {
- if (ls[i].fd == -1 || !ls[i].new) {
+ if (ls[i].fd == -1 || !ls[i].open) {
continue;
}
diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c
index 9cf1d5605..f1c0e97f3 100644
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -57,7 +57,7 @@ static const char *debug_levels[] = {
};
-#if (HAVE_VARIADIC_MACROS)
+#if (NGX_HAVE_VARIADIC_MACROS)
void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
const char *fmt, ...)
#else
@@ -67,7 +67,7 @@ void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
{
char errstr[MAX_ERROR_STR];
size_t len, max;
-#if (HAVE_VARIADIC_MACROS)
+#if (NGX_HAVE_VARIADIC_MACROS)
va_list args;
#endif
@@ -97,7 +97,7 @@ void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
"*%u ", *(u_int *) log->data);
}
-#if (HAVE_VARIADIC_MACROS)
+#if (NGX_HAVE_VARIADIC_MACROS)
va_start(args, fmt);
len += ngx_vsnprintf(errstr + len, max - len, fmt, args);
@@ -187,7 +187,7 @@ static void ngx_log_write(ngx_log_t *log, char *errstr, size_t len)
}
-#if !(HAVE_VARIADIC_MACROS)
+#if !(NGX_HAVE_VARIADIC_MACROS)
void ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
const char *fmt, ...)
@@ -253,7 +253,7 @@ ngx_log_t *ngx_log_init_stderr()
#endif
ngx_log.file = &ngx_stderr;
- ngx_log.log_level = NGX_LOG_ERR;
+ ngx_log.log_level = NGX_LOG_NOTICE;
return &ngx_log;
}
diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h
index e82995e75..5ddd8fc65 100644
--- a/src/core/ngx_log.h
+++ b/src/core/ngx_log.h
@@ -55,9 +55,9 @@ struct ngx_log_s {
/*********************************/
-#if (HAVE_GCC_VARIADIC_MACROS)
+#if (NGX_HAVE_GCC_VARIADIC_MACROS)
-#define HAVE_VARIADIC_MACROS 1
+#define NGX_HAVE_VARIADIC_MACROS 1
#define ngx_log_error(level, log, args...) \
if (log->log_level >= level) ngx_log_error_core(level, log, args)
@@ -67,9 +67,9 @@ void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
/*********************************/
-#elif (HAVE_C99_VARIADIC_MACROS)
+#elif (NGX_HAVE_C99_VARIADIC_MACROS)
-#define HAVE_VARIADIC_MACROS 1
+#define NGX_HAVE_VARIADIC_MACROS 1
#define ngx_log_error(level, log, ...) \
if (log->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__)
@@ -81,7 +81,7 @@ void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
#else /* NO VARIADIC MACROS */
-#define HAVE_VARIADIC_MACROS 0
+#define NGX_HAVE_VARIADIC_MACROS 0
void ngx_log_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
const char *fmt, ...);
@@ -98,7 +98,7 @@ void ngx_assert_core(ngx_log_t *log, const char *fmt, ...);
#if (NGX_DEBUG)
-#if (HAVE_VARIADIC_MACROS)
+#if (NGX_HAVE_VARIADIC_MACROS)
#define ngx_log_debug0(level, log, err, fmt) \
if (log->log_level & level) \
diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c
index 74e38e184..23b7846b9 100644
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -24,13 +24,13 @@ ngx_int_t ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
size_t size, bsize;
ngx_chain_t *cl, *out, **last_out;
- /*
- * the short path for the case when the ctx->in chain is empty
- * and the incoming chain is empty too or it has the single buf
- * that does not require the copy
- */
+ if (ctx->in == NULL && ctx->busy == NULL) {
- if (ctx->in == NULL) {
+ /*
+ * the short path for the case when the ctx->in and ctx->busy chains
+ * are empty, the incoming chain is empty too or has the single buf
+ * that does not require the copy
+ */
if (in == NULL) {
return ctx->output_filter(ctx->filter_ctx, in);
@@ -192,6 +192,7 @@ ngx_inline static ngx_int_t
}
if (!ctx->sendfile) {
+
if (!ngx_buf_in_memory(buf)) {
return 1;
}
@@ -228,12 +229,19 @@ static ngx_int_t ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src,
src->pos += size;
dst->last += size;
- if (src->in_file && sendfile) {
- dst->in_file = 1;
- dst->file = src->file;
- dst->file_pos = src->file_pos;
+ if (src->in_file) {
+
+ if (sendfile) {
+ dst->in_file = 1;
+ dst->file = src->file;
+ dst->file_pos = src->file_pos;
+ dst->file_last = src->file_pos + size;
+
+ } else {
+ dst->in_file = 0;
+ }
+
src->file_pos += size;
- dst->file_last = src->file_pos;
} else {
dst->in_file = 0;
@@ -271,14 +279,14 @@ static ngx_int_t ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src,
dst->in_file = 1;
dst->file = src->file;
dst->file_pos = src->file_pos;
- src->file_pos += size;
- dst->file_last = src->file_pos;
+ dst->file_last = src->file_pos + n;
} else {
dst->in_file = 0;
- src->file_pos += n;
}
+ src->file_pos += n;
+
if (src->last_buf && src->file_pos == src->file_last) {
dst->last_buf = 1;
}
diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c
index 32a4079a0..8e4e09a3a 100644
--- a/src/core/ngx_string.c
+++ b/src/core/ngx_string.c
@@ -28,6 +28,238 @@ u_char *ngx_cpystrn(u_char *dst, u_char *src, size_t n)
}
+/*
+ * supported formats:
+ * %[0][width]O off_t
+ * %[0][width]T time_t
+ * %[0][width]S ssize_t
+ * %[0][width]uS size_t
+ * %[0][width]uxS size_t in hex
+ * %[0][width]l long
+ * %[0][width]d int
+ * %[0][width]i ngx_int_t
+ * %[0][width]ui ngx_uint_t
+ * %[0][width]uxi ngx_uint_t in hex
+ * %s null-terminated string
+ * %% %
+ *
+ */
+
+u_char *ngx_sprintf(u_char *buf, char *fmt, ...)
+{
+ u_char *p, c, temp[NGX_MAX_INT_LEN];
+ int d;
+ long l;
+ off_t offset;
+ size_t size, len;
+ ssize_t ssize;
+ time_t sec;
+ va_list arg;
+ ngx_int_t i;
+ ngx_uint_t ui, zero, width, sign, hexadecimal;
+ static u_char hex[] = "0123456789abcdef";
+
+ va_start(arg, fmt);
+
+ while (*fmt) {
+ if (*fmt == '%') {
+
+ zero = (*++fmt == '0') ? 1 : 0;
+ width = 0;
+ sign = 1;
+ hexadecimal = 0;
+
+ p = temp + NGX_MAX_INT_LEN;
+
+ while (*fmt >= '0' && *fmt <= '9') {
+ width = width * 10 + *fmt++ - '0';
+ }
+
+
+ for ( ;; ) {
+ switch (*fmt) {
+
+ case 'u':
+ sign = 0;
+ fmt++;
+ continue;
+
+ case 'x':
+ hexadecimal = 1;
+ fmt++;
+ continue;
+
+ default:
+ break;
+ }
+
+ break;
+ }
+
+
+ switch (*fmt) {
+
+ case 'O':
+ offset = va_arg(arg, off_t);
+
+ if (offset < 0) {
+ *buf++ = '-';
+ offset = -offset;
+ }
+
+ do {
+ *--p = (u_char) (offset % 10 + '0');
+ } while (offset /= 10);
+
+ break;
+
+ case 'T':
+ sec = va_arg(arg, time_t);
+
+ if (sec < 0) {
+ *buf++ = '-';
+ sec = -sec;
+ }
+
+ do {
+ *--p = (u_char) (sec % 10 + '0');
+ } while (sec /= 10);
+
+ break;
+
+ case 'S':
+ if (sign) {
+ ssize = va_arg(arg, ssize_t);
+
+ if (ssize < 0) {
+ *buf++ = '-';
+ size = (size_t) -ssize;
+
+ } else {
+ size = (size_t) ssize;
+ }
+
+ } else {
+ size = va_arg(arg, size_t);
+ }
+
+ if (hexadecimal) {
+ do {
+ *--p = hex[size & 0xf];
+ } while (size >>= 4);
+
+ } else {
+ do {
+ *--p = (u_char) (size % 10 + '0');
+ } while (size /= 10);
+ }
+
+ break;
+
+ case 'l':
+ l = va_arg(arg, long);
+
+ if (l < 0) {
+ *buf++ = '-';
+ l = -l;
+ }
+
+ do {
+ *--p = (u_char) (l % 10 + '0');
+ } while (l /= 10);
+
+ break;
+
+ case 'd':
+ d = va_arg(arg, int);
+
+ if (d < 0) {
+ *buf++ = '-';
+ d = -d;
+ }
+
+ do {
+ *--p = (u_char) (d % 10 + '0');
+ } while (d /= 10);
+
+ break;
+
+ case 'i':
+ if (sign) {
+ i = va_arg(arg, ngx_int_t);
+
+ if (i < 0) {
+ *buf++ = '-';
+ ui = (ngx_uint_t) -i;
+
+ } else {
+ ui = (ngx_uint_t) i;
+ }
+
+ } else {
+ ui = va_arg(arg, ngx_uint_t);
+ }
+
+ if (hexadecimal) {
+ do {
+ *--p = hex[ui & 0xf];
+ } while (ui >>= 4);
+
+ } else {
+ do {
+ *--p = (u_char) (ui % 10 + '0');
+ } while (ui /= 10);
+ }
+
+ break;
+
+ case 's':
+ p = va_arg(arg, u_char *);
+
+ while (*p) {
+ *buf++ = *p++;
+ }
+ fmt++;
+
+ continue;
+
+ case '%':
+ *buf++ = '%';
+ fmt++;
+
+ continue;
+
+ default:
+ *buf++ = *fmt++;
+
+ continue;
+ }
+
+ len = (temp + NGX_MAX_INT_LEN) - p;
+
+ c = (u_char) (zero ? '0' : ' ');
+
+ while (len++ < width) {
+ *buf++ = c;
+ }
+
+ buf = ngx_cpymem(buf, p, ((temp + NGX_MAX_INT_LEN) - p));
+
+ fmt++;
+
+ } else {
+ *buf++ = *fmt++;
+ }
+ }
+
+ va_end(arg);
+
+ *buf = '\0';
+
+ return buf;
+}
+
+
ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n)
{
if (n == 0) {
@@ -50,6 +282,40 @@ ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n)
}
+ngx_int_t ngx_rstrncasecmp(u_char *s1, u_char *s2, size_t n)
+{
+ u_char c1, c2;
+
+ if (n == 0) {
+ return 0;
+ }
+
+ n--;
+
+ for ( ;; ) {
+ c1 = s1[n];
+ if (c1 >= 'a' && c1 <= 'z') {
+ c1 -= 'a' - 'A';
+ }
+
+ c2 = s2[n];
+ if (c2 >= 'a' && c2 <= 'z') {
+ c2 -= 'a' - 'A';
+ }
+
+ if (c1 != c2) {
+ return c1 - c2;
+ }
+
+ if (n == 0) {
+ return 0;
+ }
+
+ n--;
+ }
+}
+
+
ngx_int_t ngx_atoi(u_char *line, size_t n)
{
ngx_int_t value;
diff --git a/src/core/ngx_string.h b/src/core/ngx_string.h
index e8e69c0c0..d7caaaf3d 100644
--- a/src/core/ngx_string.h
+++ b/src/core/ngx_string.h
@@ -70,7 +70,10 @@ typedef struct {
#define ngx_memcmp memcmp
u_char *ngx_cpystrn(u_char *dst, u_char *src, size_t n);
+u_char *ngx_sprintf(u_char *buf, char *fmt, ...);
+
ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n);
+ngx_int_t ngx_rstrncasecmp(u_char *s1, u_char *s2, size_t n);
ngx_int_t ngx_atoi(u_char *line, size_t n);
ngx_int_t ngx_hextoi(u_char *line, size_t n);
diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c
index 2ca31acc4..40dbbdbaf 100644
--- a/src/core/ngx_times.c
+++ b/src/core/ngx_times.c
@@ -212,12 +212,25 @@ void ngx_time_update(time_t s)
}
+u_char *ngx_http_time(u_char *buf, time_t t)
+#if 0
size_t ngx_http_time(u_char *buf, time_t t)
+#endif
{
ngx_tm_t tm;
ngx_gmtime(t, &tm);
+ return ngx_sprintf(buf, "%s, %02d %s %4d %02d:%02d:%02d GMT",
+ week[tm.ngx_tm_wday],
+ tm.ngx_tm_mday,
+ months[tm.ngx_tm_mon - 1],
+ tm.ngx_tm_year,
+ tm.ngx_tm_hour,
+ tm.ngx_tm_min,
+ tm.ngx_tm_sec);
+
+#if 0
return ngx_snprintf((char *) buf, sizeof("Mon, 28 Sep 1970 06:00:00 GMT"),
"%s, %02d %s %4d %02d:%02d:%02d GMT",
week[tm.ngx_tm_wday],
@@ -227,10 +240,14 @@ size_t ngx_http_time(u_char *buf, time_t t)
tm.ngx_tm_hour,
tm.ngx_tm_min,
tm.ngx_tm_sec);
+#endif
}
+u_char *ngx_http_cookie_time(u_char *buf, time_t t)
+#if 0
size_t ngx_http_cookie_time(u_char *buf, time_t t)
+#endif
{
ngx_tm_t tm;
@@ -241,6 +258,20 @@ size_t ngx_http_cookie_time(u_char *buf, time_t t)
* 2-digit years more than "37"
*/
+ return ngx_sprintf(buf,
+ (tm.ngx_tm_year > 2037) ?
+ "%s, %02d-%s-%d %02d:%02d:%02d GMT":
+ "%s, %02d-%s-%02d %02d:%02d:%02d GMT",
+ week[tm.ngx_tm_wday],
+ tm.ngx_tm_mday,
+ months[tm.ngx_tm_mon - 1],
+ (tm.ngx_tm_year > 2037) ? tm.ngx_tm_year:
+ tm.ngx_tm_year % 100,
+ tm.ngx_tm_hour,
+ tm.ngx_tm_min,
+ tm.ngx_tm_sec);
+
+#if 0
if (tm.ngx_tm_year > 2037) {
return ngx_snprintf((char *) buf,
sizeof("Mon, 28-Sep-1970 06:00:00 GMT"),
@@ -264,6 +295,7 @@ size_t ngx_http_cookie_time(u_char *buf, time_t t)
tm.ngx_tm_min,
tm.ngx_tm_sec);
}
+#endif
}
diff --git a/src/core/ngx_times.h b/src/core/ngx_times.h
index e1d1515ee..5eabac536 100644
--- a/src/core/ngx_times.h
+++ b/src/core/ngx_times.h
@@ -14,8 +14,8 @@
void ngx_time_init();
void ngx_time_update(time_t s);
-size_t ngx_http_time(u_char *buf, time_t t);
-size_t ngx_http_cookie_time(u_char *buf, time_t t);
+u_char *ngx_http_time(u_char *buf, time_t t);
+u_char *ngx_http_cookie_time(u_char *buf, time_t t);
void ngx_gmtime(time_t t, ngx_tm_t *tp);
#if (NGX_THREADS)
diff --git a/src/event/modules/ngx_epoll_module.c b/src/event/modules/ngx_epoll_module.c
index 4067fd886..45791e9c7 100644
--- a/src/event/modules/ngx_epoll_module.c
+++ b/src/event/modules/ngx_epoll_module.c
@@ -173,7 +173,7 @@ static int ngx_epoll_init(ngx_cycle_t *cycle)
#else
ngx_event_flags = NGX_USE_LEVEL_EVENT
#endif
- |NGX_HAVE_GREEDY_EVENT
+ |NGX_USE_GREEDY_EVENT
|NGX_USE_EPOLL_EVENT;
return NGX_OK;
diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c
index db5b75683..e6bebb559 100644
--- a/src/event/modules/ngx_kqueue_module.c
+++ b/src/event/modules/ngx_kqueue_module.c
@@ -194,10 +194,10 @@ static ngx_int_t ngx_kqueue_init(ngx_cycle_t *cycle)
#else
|NGX_USE_LEVEL_EVENT
#endif
-#if (HAVE_LOWAT_EVENT)
- |NGX_HAVE_LOWAT_EVENT
+#if (NGX_HAVE_LOWAT_EVENT)
+ |NGX_USE_LOWAT_EVENT
#endif
- |NGX_HAVE_KQUEUE_EVENT;
+ |NGX_USE_KQUEUE_EVENT;
return NGX_OK;
}
@@ -245,6 +245,8 @@ static ngx_int_t ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
return NGX_ERROR;
}
+#if 1
+
if (nchanges > 0
&& ev->index < (u_int) nchanges
&& ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1)
@@ -262,7 +264,8 @@ static ngx_int_t ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
ngx_event_ident(ev->data), event);
if (ev->index < (u_int) --nchanges) {
- e = (ngx_event_t *) change_list[nchanges].udata;
+ e = (ngx_event_t *)
+ ((uintptr_t) change_list[nchanges].udata & (uintptr_t) ~1);
change_list[ev->index] = change_list[nchanges];
e->index = ev->index;
}
@@ -282,6 +285,8 @@ static ngx_int_t ngx_kqueue_add_event(ngx_event_t *ev, int event, u_int flags)
return NGX_ERROR;
}
+#endif
+
rc = ngx_kqueue_set_event(ev, event, EV_ADD|EV_ENABLE|flags);
ngx_mutex_unlock(list_mutex);
@@ -302,6 +307,8 @@ static ngx_int_t ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
return NGX_ERROR;
}
+#if 1
+
if (nchanges > 0
&& ev->index < (u_int) nchanges
&& ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1)
@@ -314,7 +321,8 @@ static ngx_int_t ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
/* if the event is still not passed to a kernel we will not pass it */
if (ev->index < (u_int) --nchanges) {
- e = (ngx_event_t *) change_list[nchanges].udata;
+ e = (ngx_event_t *)
+ ((uintptr_t) change_list[nchanges].udata & (uintptr_t) ~1);
change_list[ev->index] = change_list[nchanges];
e->index = ev->index;
}
@@ -324,6 +332,8 @@ static ngx_int_t ngx_kqueue_del_event(ngx_event_t *ev, int event, u_int flags)
return NGX_OK;
}
+#endif
+
/*
* when the file descriptor is closed the kqueue automatically deletes
* its filters so we do not need to delete explicity the event
@@ -393,7 +403,7 @@ static ngx_int_t ngx_kqueue_set_event(ngx_event_t *ev, int filter, u_int flags)
kev->data = 0;
} else {
-#if (HAVE_LOWAT_EVENT)
+#if (NGX_HAVE_LOWAT_EVENT)
if (flags & NGX_LOWAT_EVENT) {
kev->fflags = NOTE_LOWAT;
kev->data = ev->available;
diff --git a/src/event/modules/ngx_rtsig_module.c b/src/event/modules/ngx_rtsig_module.c
index 72c5b7c2d..4f2f48097 100644
--- a/src/event/modules/ngx_rtsig_module.c
+++ b/src/event/modules/ngx_rtsig_module.c
@@ -158,7 +158,7 @@ static ngx_int_t ngx_rtsig_init(ngx_cycle_t *cycle)
ngx_event_actions = ngx_rtsig_module_ctx.actions;
- ngx_event_flags = NGX_USE_RTSIG_EVENT|NGX_HAVE_GREEDY_EVENT;
+ ngx_event_flags = NGX_USE_RTSIG_EVENT|NGX_USE_GREEDY_EVENT;
return NGX_OK;
}
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index 4718dcd20..f006c6ba5 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -465,9 +465,9 @@ ngx_int_t ngx_send_lowat(ngx_connection_t *c, size_t lowat)
{
int sndlowat;
-#if (HAVE_LOWAT_EVENT)
+#if (NGX_HAVE_LOWAT_EVENT)
- if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
c->write->available = lowat;
return NGX_OK;
}
diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h
index c173adc05..f341a14c6 100644
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -240,19 +240,19 @@ extern ngx_event_actions_t ngx_event_actions;
* The event filter has kqueue features - the eof flag, errno,
* available data, etc.
*/
-#define NGX_HAVE_KQUEUE_EVENT 0x00000008
+#define NGX_USE_KQUEUE_EVENT 0x00000008
/*
* The event filter supports low water mark - kqueue's NOTE_LOWAT.
* kqueue in FreeBSD 4.1-4.2 has no NOTE_LOWAT so we need a separate flag.
*/
-#define NGX_HAVE_LOWAT_EVENT 0x00000010
+#define NGX_USE_LOWAT_EVENT 0x00000010
/*
* The event filter requires to do i/o operation until EAGAIN -
* epoll, rt signals.
*/
-#define NGX_HAVE_GREEDY_EVENT 0x00000020
+#define NGX_USE_GREEDY_EVENT 0x00000020
/*
* The event filter is epoll,
@@ -571,7 +571,7 @@ ngx_inline static int ngx_handle_write_event(ngx_event_t *wev, size_t lowat)
ngx_connection_t *c;
if (lowat) {
- c = wev->data;
+ c = (ngx_connection_t *) wev->data;
if (ngx_send_lowat(c, lowat) == NGX_ERROR) {
return NGX_ERROR;
diff --git a/src/event/ngx_event_accept.c b/src/event/ngx_event_accept.c
index 5a5e0e170..9ae5ccd11 100644
--- a/src/event/ngx_event_accept.c
+++ b/src/event/ngx_event_accept.c
@@ -39,7 +39,7 @@ void ngx_event_accept(ngx_event_t *ev)
if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
ev->available = 1;
- } else if (!(ngx_event_flags & NGX_HAVE_KQUEUE_EVENT)) {
+ } else if (!(ngx_event_flags & NGX_USE_KQUEUE_EVENT)) {
ev->available = ecf->multi_accept;
}
@@ -118,7 +118,7 @@ void ngx_event_accept(ngx_event_t *ev)
ls->listening->addr_text.data);
if (err == NGX_ECONNABORTED) {
- if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
ev->available--;
}
@@ -342,7 +342,7 @@ void ngx_event_accept(ngx_event_t *ev)
ls->listening->handler(c);
- if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
ev->available--;
}
diff --git a/src/event/ngx_event_connect.c b/src/event/ngx_event_connect.c
index c1e6c1935..b41eca771 100644
--- a/src/event/ngx_event_connect.c
+++ b/src/event/ngx_event_connect.c
@@ -296,6 +296,9 @@ int ngx_event_connect_peer(ngx_peer_connection_t *pc)
if (ngx_event_flags & NGX_USE_AIO_EVENT) {
+ ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, ngx_socket_errno,
+ "connect(): %d", rc);
+
/* aio, iocp */
if (ngx_blocking(s) == -1) {
@@ -311,8 +314,7 @@ int ngx_event_connect_peer(ngx_peer_connection_t *pc)
}
/*
- * aio allows to post operation on non-connected socket
- * at least in FreeBSD.
+ * FreeBSD aio allows to post operation on non-connected socket.
* NT does not support it.
*
* TODO: check in Win32, etc. As workaround we can use NGX_ONESHOT_EVENT
diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c
index 151cc429f..7a7038d4f 100644
--- a/src/event/ngx_event_openssl.c
+++ b/src/event/ngx_event_openssl.c
@@ -86,6 +86,7 @@ ngx_int_t ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size)
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL_get_error: %d", sslerr);
if (sslerr == SSL_ERROR_WANT_READ) {
+ c->read->ready = 0;
return NGX_AGAIN;
}
diff --git a/src/http/modules/ngx_http_charset_filter.c b/src/http/modules/ngx_http_charset_filter.c
index d22a86b5b..f2e85e530 100644
--- a/src/http/modules/ngx_http_charset_filter.c
+++ b/src/http/modules/ngx_http_charset_filter.c
@@ -12,7 +12,7 @@
typedef struct {
char **tables;
ngx_str_t name;
- unsigned server;
+ ngx_uint_t server; /* unsigned server:1; */
} ngx_http_charset_t;
@@ -45,7 +45,7 @@ typedef struct {
} ngx_http_charset_ctx_t;
-static void ngx_charset_recode(ngx_buf_t *b, char *table);
+static ngx_uint_t ngx_charset_recode(ngx_buf_t *b, char *table);
static char *ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
@@ -232,14 +232,31 @@ static ngx_int_t ngx_http_charset_body_filter(ngx_http_request_t *r,
}
-static void ngx_charset_recode(ngx_buf_t *b, char *table)
+static ngx_uint_t ngx_charset_recode(ngx_buf_t *b, char *table)
{
- u_char *p, c;
+ u_char *p;
+ ngx_uint_t change;
+
+ change = 0;
for (p = b->pos; p < b->last; p++) {
- c = *p;
- *p = table[c];
+ if (*p != table[*p]) {
+ change = 1;
+ break;
+ }
}
+
+ if (change) {
+
+ while (p < b->last) {
+ *p = table[*p];
+ p++;
+ }
+
+ b->in_file = 0;
+ }
+
+ return change;
}
@@ -419,7 +436,9 @@ static ngx_int_t ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name)
return NGX_ERROR;
}
+ c->tables = NULL;
c->name = *name;
+ c->server = 0;
return i;
}
diff --git a/src/http/modules/ngx_http_chunked_filter.c b/src/http/modules/ngx_http_chunked_filter.c
index 211246149..7881248cc 100644
--- a/src/http/modules/ngx_http_chunked_filter.c
+++ b/src/http/modules/ngx_http_chunked_filter.c
@@ -63,7 +63,7 @@ static ngx_int_t ngx_http_chunked_body_filter(ngx_http_request_t *r,
ngx_chain_t *in)
{
u_char *chunk;
- size_t size, len;
+ size_t size;
ngx_buf_t *b;
ngx_chain_t out, tail, *cl, *tl, **ll;
@@ -98,6 +98,20 @@ static ngx_int_t ngx_http_chunked_body_filter(ngx_http_request_t *r,
}
if (size) {
+ if (!(b = ngx_calloc_buf(r->pool))) {
+ return NGX_ERROR;
+ }
+
+ if (!(chunk = ngx_palloc(r->pool, 11))) {
+ return NGX_ERROR;
+ }
+
+ b->temporary = 1;
+ b->pos = chunk;
+ b->last = ngx_sprintf(chunk, "%uxS" CRLF, size);
+
+ out.buf = b;
+#if 0
ngx_test_null(chunk, ngx_palloc(r->pool, 11), NGX_ERROR);
len = ngx_snprintf((char *) chunk, 11, SIZE_T_X_FMT CRLF, size);
@@ -107,6 +121,7 @@ static ngx_int_t ngx_http_chunked_body_filter(ngx_http_request_t *r,
b->last = chunk + len;
out.buf = b;
+#endif
}
if (cl->buf->last_buf) {
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c
index 4089ffbdc..bb3a1f0c6 100644
--- a/src/http/modules/ngx_http_gzip_filter.c
+++ b/src/http/modules/ngx_http_gzip_filter.c
@@ -837,26 +837,30 @@ static u_char *ngx_http_gzip_log_ratio(ngx_http_request_t *r, u_char *buf,
return buf + 1;
}
-#if 0
- return buf + ngx_snprintf((char *) buf, NGX_INT32_LEN + 4, "%.2f",
- (float) ctx->zin / ctx->zout);
-#endif
-
/* we prefer do not use the FPU */
zint = (ngx_uint_t) (ctx->zin / ctx->zout);
zfrac = (ngx_uint_t) ((ctx->zin * 100 / ctx->zout) % 100);
- if ((ctx->zin * 1000 / ctx->zout) %10 > 4) {
- if (++zfrac > 99) {
+ if ((ctx->zin * 1000 / ctx->zout) % 10 > 4) {
+
+ /* the rounding, e.g., 2.125 to 2.13 */
+
+ zfrac++;
+
+ if (zfrac > 99) {
zint++;
zfrac = 0;
}
}
+ return ngx_sprintf(buf, "%ui.%02ui", zint, zfrac);
+
+#if 0
return buf + ngx_snprintf((char *) buf, NGX_INT32_LEN + 4,
"%" NGX_UINT_T_FMT ".%02" NGX_UINT_T_FMT,
zint, zfrac);
+#endif
}
diff --git a/src/http/modules/ngx_http_headers_filter.c b/src/http/modules/ngx_http_headers_filter.c
index f7fe52c8e..faf81920a 100644
--- a/src/http/modules/ngx_http_headers_filter.c
+++ b/src/http/modules/ngx_http_headers_filter.c
@@ -134,10 +134,16 @@ static ngx_int_t ngx_http_headers_filter(ngx_http_request_t *r)
return NGX_ERROR;
}
+ cc->value.len = ngx_sprintf(cc->value.data, "max-age=%T",
+ conf->expires)
+ - cc->value.data;
+
+#if 0
cc->value.len = ngx_snprintf((char *) cc->value.data,
sizeof("max-age=") + TIME_T_LEN,
"max-age=" TIME_T_FMT,
conf->expires);
+#endif
}
}
}
diff --git a/src/http/modules/ngx_http_range_filter.c b/src/http/modules/ngx_http_range_filter.c
index a08e25f7a..082fd3c4a 100644
--- a/src/http/modules/ngx_http_range_filter.c
+++ b/src/http/modules/ngx_http_range_filter.c
@@ -264,9 +264,14 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
}
r->headers_out.content_range->value.len =
+ ngx_sprintf(r->headers_out.content_range->value.data,
+ "bytes */%O", r->headers_out.content_length_n)
+ - r->headers_out.content_range->value.data;
+#if 0
ngx_snprintf((char *) r->headers_out.content_range->value.data,
8 + 20 + 1, "bytes */" OFF_T_FMT,
r->headers_out.content_length_n);
+#endif
r->headers_out.content_length_n = -1;
if (r->headers_out.content_length) {
@@ -297,12 +302,20 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
/* "Content-Range: bytes SSSS-EEEE/TTTT" header */
r->headers_out.content_range->value.len =
+ ngx_sprintf(r->headers_out.content_range->value.data,
+ "bytes %O-%O/%O",
+ range->start, range->end - 1,
+ r->headers_out.content_length_n)
+ - r->headers_out.content_range->value.data;
+
+#if 0
ngx_snprintf((char *)
r->headers_out.content_range->value.data,
6 + 20 + 1 + 20 + 1 + 20 + 1,
"bytes " OFF_T_FMT "-" OFF_T_FMT "/" OFF_T_FMT,
range->start, range->end - 1,
r->headers_out.content_length_n);
+#endif
r->headers_out.content_length_n = range->end - range->start;
@@ -343,6 +356,15 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
if (r->headers_out.charset.len) {
ctx->boundary_header.len =
+ ngx_sprintf(ctx->boundary_header.data,
+ CRLF "--%010ui" CRLF
+ "Content-Type: %s; charset=%s" CRLF
+ "Content-Range: bytes ",
+ boundary,
+ r->headers_out.content_type->value.data,
+ r->headers_out.charset.data)
+ - ctx->boundary_header.data;
+#if 0
ngx_snprintf((char *) ctx->boundary_header.data, len,
CRLF "--%010" NGX_UINT_T_FMT CRLF
"Content-Type: %s; charset=%s" CRLF
@@ -350,17 +372,29 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
boundary,
r->headers_out.content_type->value.data,
r->headers_out.charset.data);
+#endif
r->headers_out.charset.len = 0;
} else {
ctx->boundary_header.len =
+ ngx_sprintf(ctx->boundary_header.data,
+ CRLF "--%010ui" CRLF
+ "Content-Type: %s" CRLF
+ "Content-Range: bytes ",
+ boundary,
+ r->headers_out.content_type->value.data)
+ - ctx->boundary_header.data;
+
+#if 0
ngx_snprintf((char *) ctx->boundary_header.data, len,
CRLF "--%010" NGX_UINT_T_FMT CRLF
"Content-Type: %s" CRLF
"Content-Range: bytes ",
boundary,
r->headers_out.content_type->value.data);
+
+#endif
}
ngx_test_null(r->headers_out.content_type->value.data,
@@ -370,12 +404,18 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
/* "Content-Type: multipart/byteranges; boundary=0123456789" */
r->headers_out.content_type->value.len =
+ ngx_sprintf(r->headers_out.content_type->value.data,
+ "multipart/byteranges; boundary=%010ui",
+ boundary)
+ - r->headers_out.content_type->value.data;
+#if 0
ngx_snprintf((char *)
r->headers_out.content_type->value.data,
31 + 10 + 1,
"multipart/byteranges; boundary=%010"
NGX_UINT_T_FMT,
boundary);
+#endif
/* the size of the last boundary CRLF "--0123456789--" CRLF */
len = 4 + 10 + 4;
@@ -389,11 +429,18 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
/* the size of the range: "SSSS-EEEE/TTTT" CRLF CRLF */
range[i].content_range.len =
+ ngx_sprintf(range[i].content_range.data,
+ "%O-%O/%O" CRLF CRLF,
+ range[i].start, range[i].end - 1,
+ r->headers_out.content_length_n)
+ - range[i].content_range.data;
+#if 0
ngx_snprintf((char *) range[i].content_range.data,
20 + 1 + 20 + 1 + 20 + 5,
OFF_T_FMT "-" OFF_T_FMT "/" OFF_T_FMT CRLF CRLF,
range[i].start, range[i].end - 1,
r->headers_out.content_length_n);
+#endif
len += ctx->boundary_header.len + range[i].content_range.len
+ (size_t) (range[i].end - range[i].start);
diff --git a/src/http/modules/ngx_http_userid_filter.c b/src/http/modules/ngx_http_userid_filter.c
index 5f8e452ac..bafdea884 100644
--- a/src/http/modules/ngx_http_userid_filter.c
+++ b/src/http/modules/ngx_http_userid_filter.c
@@ -367,7 +367,7 @@ static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r,
} else if (conf->expires) {
p = ngx_cpymem(p, expires, sizeof("; expires=") - 1);
- p += ngx_http_cookie_time(p, ngx_time() + conf->expires);
+ p = ngx_http_cookie_time(p, ngx_time() + conf->expires);
}
if (conf->domain.len > 1) {
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index f0794f36e..5d61167e2 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -289,6 +289,8 @@ ngx_http_header_t ngx_http_proxy_headers_in[] = {
offsetof(ngx_http_proxy_headers_in_t, content_type) },
{ ngx_string("Content-Length"),
offsetof(ngx_http_proxy_headers_in_t, content_length) },
+ { ngx_string("Content-Encoding"),
+ offsetof(ngx_http_proxy_headers_in_t, content_encoding) },
{ ngx_string("Last-Modified"),
offsetof(ngx_http_proxy_headers_in_t, last_modified) },
{ ngx_string("Location"),
@@ -400,7 +402,7 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *ev)
#if (HAVE_KQUEUE)
- if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
if (!ev->pending_eof) {
return;
@@ -1310,10 +1312,10 @@ static char *ngx_http_proxy_parse_upstream(ngx_str_t *url,
static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data)
{
-#if __FreeBSD__
-
ssize_t *np = data;
+#if (NGX_FREEBSD)
+
if (*np >= ngx_freebsd_net_inet_tcp_sendspace) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"proxy_send_lowat\" must be less than %d "
@@ -1323,15 +1325,12 @@ static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data)
return NGX_CONF_ERROR;
}
+#elif !(HAVE_SO_SNDLOWAT)
-#else
-
-#if 0
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
"\"proxy_send_lowat\" is not supported, ignored");
*np = 0;
-#endif
#endif
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h
index 728259c45..3e721bae1 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.h
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.h
@@ -130,6 +130,7 @@ typedef struct {
ngx_table_elt_t *connection;
ngx_table_elt_t *content_type;
ngx_table_elt_t *content_length;
+ ngx_table_elt_t *content_encoding;
ngx_table_elt_t *last_modified;
ngx_table_elt_t *location;
ngx_table_elt_t *accept_ranges;
diff --git a/src/http/modules/proxy/ngx_http_proxy_header.c b/src/http/modules/proxy/ngx_http_proxy_header.c
index 07722fc89..cd5deeb9e 100644
--- a/src/http/modules/proxy/ngx_http_proxy_header.c
+++ b/src/http/modules/proxy/ngx_http_proxy_header.c
@@ -113,6 +113,11 @@ int ngx_http_proxy_copy_header(ngx_http_proxy_ctx_t *p,
continue;
}
+ if (&h[i] == headers_in->content_encoding) {
+ r->headers_out.content_encoding = ho;
+ continue;
+ }
+
if (&h[i] == headers_in->last_modified) {
r->headers_out.last_modified = ho;
/* TODO: update r->headers_out.last_modified_time */
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c
index be5d69a22..88479daf5 100644
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -692,12 +692,14 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p)
/* rc == NGX_OK */
-#if 1 /* test only, see below about "post aio operation" */
+#if 0 /* test only, see below about "post aio operation" */
if (c->read->ready) {
/* post aio operation */
ngx_http_proxy_process_upstream_status_line(c->read);
+#if 0
return;
+#endif
}
#endif
@@ -718,7 +720,7 @@ static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p)
#if (HAVE_KQUEUE)
- if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT)
+ if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT)
&& !p->request_sent
&& c->write->pending_eof)
{
@@ -776,7 +778,7 @@ static void ngx_http_proxy_send_request(ngx_http_proxy_ctx_t *p)
ngx_add_timer(c->read, p->lcf->read_timeout);
-#if 0
+#if 1
if (c->read->ready) {
/* post aio operation */
diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c
index a37ffc6eb..90bbbe2f5 100644
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -11,6 +11,14 @@
static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+static ngx_int_t ngx_http_add_address(ngx_conf_t *cf,
+ ngx_http_in_port_t *in_port,
+ ngx_http_listen_t *lscf,
+ ngx_http_core_srv_conf_t *cscf);
+static ngx_int_t ngx_http_add_names(ngx_conf_t *cf,
+ ngx_http_in_addr_t *in_addr,
+ ngx_http_core_srv_conf_t *cscf);
+
static char *ngx_http_merge_locations(ngx_conf_t *cf,
ngx_array_t *locations,
void **loc_conf,
@@ -79,6 +87,11 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_iocp_conf_t *iocpcf;
#endif
+#if (NGX_SUPPRESS_WARN)
+ /* MSVC thinks 'in_ports' may be used without having been initialized */
+ ngx_memzero(&in_ports, sizeof(ngx_array_t));
+#endif
+
/* the main http context */
ngx_test_null(ctx,
ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)),
@@ -274,18 +287,23 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
/*
- * create the lists of the ports, the addresses and the server names
- * to allow quickly find the server core module configuration at run-time
+ * create the lists of ports, addresses and server names
+ * to quickly find the server core module configuration at run-time
*/
- ngx_init_array(in_ports, cf->pool, 10, sizeof(ngx_http_in_port_t),
- NGX_CONF_ERROR);
+ if (ngx_array_init(&in_ports, cf->pool, 10, sizeof(ngx_http_in_port_t))
+ == NGX_ERROR)
+ {
+ return NGX_CONF_ERROR;
+ }
/* "server" directives */
+
cscfp = cmcf->servers.elts;
for (s = 0; s < cmcf->servers.nelts; s++) {
/* "listen" directives */
+
lscf = cscfp[s]->listen.elts;
for (l = 0; l < cscfp[s]->listen.nelts; l++) {
@@ -308,38 +326,26 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
if (lscf[l].addr == in_addr[a].addr) {
- /* the address is already bound to this port */
-
- /* "server_name" directives */
- s_name = cscfp[s]->server_names.elts;
- for (n = 0; n < cscfp[s]->server_names.nelts; n++) {
-
- /*
- * add the server name and server core module
- * configuration to the address:port
- */
-
- /* TODO: duplicate names can be checked here */
+ /* the address is already in the address list */
- ngx_test_null(name,
- ngx_push_array(&in_addr[a].names),
- NGX_CONF_ERROR);
-
- name->name = s_name[n].name;
- name->core_srv_conf = s_name[n].core_srv_conf;
+ if (ngx_http_add_names(cf, &in_addr[a], cscfp[s])
+ == NGX_ERROR)
+ {
+ return NGX_CONF_ERROR;
}
/*
- * check duplicate "default" server that
- * serves this address:port
+ * check the duplicate "default" server
+ * for this address:port
*/
if (lscf[l].default_server) {
+
if (in_addr[a].default_server) {
ngx_log_error(NGX_LOG_ERR, cf->log, 0,
- "duplicate default server in %s:%d",
- lscf[l].file_name.data,
- lscf[l].line);
+ "the duplicate default server in %s:%d",
+ lscf[l].file_name.data,
+ lscf[l].line);
return NGX_CONF_ERROR;
}
@@ -354,31 +360,31 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
} else if (in_addr[a].addr == INADDR_ANY) {
+ /* the INADDR_ANY is always the last address */
+
+ if (!(inaddr = ngx_array_push(&in_port[p].addrs))) {
+ return NGX_CONF_ERROR;
+ }
+
/*
- * "*:port" must be the last resort so move it
- * to the end of the address list and add
- * the new address at its place
+ * the INADDR_ANY must be the last resort
+ * so we move it to the end of the address list
+ * and put the new address in its place
*/
- ngx_test_null(inaddr,
- ngx_push_array(&in_port[p].addrs),
- NGX_CONF_ERROR);
-
ngx_memcpy(inaddr, &in_addr[a],
sizeof(ngx_http_in_addr_t));
in_addr[a].addr = lscf[l].addr;
+ in_addr[a].names.elts = NULL;
in_addr[a].default_server = lscf[l].default_server;
in_addr[a].core_srv_conf = cscfp[s];
- /*
- * create the empty list of the server names that
- * can be served on this address:port
- */
-
- ngx_init_array(inaddr->names, cf->pool, 10,
- sizeof(ngx_http_server_name_t),
- NGX_CONF_ERROR);
+ if (ngx_http_add_names(cf, &in_addr[a], cscfp[s])
+ == NGX_ERROR)
+ {
+ return NGX_CONF_ERROR;
+ }
addr_found = 1;
@@ -393,22 +399,11 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
* bound to this port
*/
- ngx_test_null(inaddr,
- ngx_push_array(&in_port[p].addrs),
- NGX_CONF_ERROR);
-
- inaddr->addr = lscf[l].addr;
- inaddr->default_server = lscf[l].default_server;
- inaddr->core_srv_conf = cscfp[s];
-
- /*
- * create the empty list of the server names that
- * can be served on this address:port
- */
-
- ngx_init_array(inaddr->names, cf->pool, 10,
- sizeof(ngx_http_server_name_t),
- NGX_CONF_ERROR);
+ if (ngx_http_add_address(cf, &in_port[p], &lscf[l],
+ cscfp[s]) == NGX_ERROR)
+ {
+ return NGX_CONF_ERROR;
+ }
}
}
}
@@ -417,54 +412,42 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
/* add the port to the in_port list */
- ngx_test_null(in_port,
- ngx_push_array(&in_ports),
- NGX_CONF_ERROR);
+ if (!(in_port = ngx_array_push(&in_ports))) {
+ return NGX_CONF_ERROR;
+ }
in_port->port = lscf[l].port;
+ in_port->addrs.elts = NULL;
- ngx_test_null(in_port->port_text.data, ngx_palloc(cf->pool, 7),
- NGX_CONF_ERROR);
- in_port->port_text.len = ngx_snprintf((char *)
- in_port->port_text.data,
- 7, ":%d",
- in_port->port);
-
- /* create list of the addresses that bound to this port ... */
-
- ngx_init_array(in_port->addrs, cf->pool, 10,
- sizeof(ngx_http_in_addr_t),
- NGX_CONF_ERROR);
-
- ngx_test_null(inaddr, ngx_push_array(&in_port->addrs),
- NGX_CONF_ERROR);
-
- /* ... and add the address to this list */
-
- inaddr->addr = lscf[l].addr;
- inaddr->default_server = lscf[l].default_server;
- inaddr->core_srv_conf = cscfp[s];
+ if (!(in_port->port_text.data = ngx_palloc(cf->pool, 7))) {
+ return NGX_CONF_ERROR;
+ }
- /*
- * create the empty list of the server names that
- * can be served on this address:port
- */
+ in_port->port_text.len = ngx_sprintf(in_port->port_text.data,
+ ":%d", in_port->port)
+ - in_port->port_text.data;
- ngx_init_array(inaddr->names, cf->pool, 10,
- sizeof(ngx_http_server_name_t),
- NGX_CONF_ERROR);
+ if (ngx_http_add_address(cf, in_port, &lscf[l], cscfp[s])
+ == NGX_ERROR)
+ {
+ return NGX_CONF_ERROR;
+ }
}
}
}
- /* optimize the lists of the ports, the addresses and the server names */
+
+ /* optimize the lists of ports, addresses and server names */
/* AF_INET only */
in_port = in_ports.elts;
for (p = 0; p < in_ports.nelts; p++) {
- /* check whether the all server names point to the same server */
+ /*
+ * check whether all name-based servers have the same configuraiton
+ * as the default server, or some servers restrict the host names
+ */
in_addr = in_port[p].addrs.elts;
for (a = 0; a < in_port[p].addrs.nelts; a++) {
@@ -473,15 +456,19 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
name = in_addr[a].names.elts;
for (n = 0; n < in_addr[a].names.nelts; n++) {
- if (in_addr[a].core_srv_conf != name[n].core_srv_conf) {
+ if (in_addr[a].core_srv_conf != name[n].core_srv_conf
+ || name[n].core_srv_conf->restrict_host_names
+ != NGX_HTTP_RESTRICT_HOST_OFF)
+ {
virtual_names = 1;
break;
}
}
/*
- * if the all server names point to the same server
- * then we do not need to check them at run-time
+ * if all name-based servers have the same configuration
+ * as the default server, and no servers restrict the host names
+ * then we do not need to check them at run-time at all
*/
if (!virtual_names) {
@@ -588,30 +575,117 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
#if (NGX_DEBUG)
+ {
+ u_char address[20];
+ ngx_uint_t p, a, n;
+
in_port = in_ports.elts;
for (p = 0; p < in_ports.nelts; p++) {
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0,
"port: %d %08x", in_port[p].port, &in_port[p]);
in_addr = in_port[p].addrs.elts;
for (a = 0; a < in_port[p].addrs.nelts; a++) {
- u_char ip[20];
- ngx_inet_ntop(AF_INET, &in_addr[a].addr, ip, 20);
- ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0,
- "%s %08x", ip, in_addr[a].core_srv_conf);
+ ngx_inet_ntop(AF_INET, &in_addr[a].addr, address, 20);
+ ngx_log_debug3(NGX_LOG_DEBUG_HTTP, cf->log, 0,
+ "%s:%d %08x",
+ address, in_port[p].port, in_addr[a].core_srv_conf);
s_name = in_addr[a].names.elts;
for (n = 0; n < in_addr[a].names.nelts; n++) {
- ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0,
- "%s %08x", s_name[n].name.data,
+ ngx_log_debug4(NGX_LOG_DEBUG_HTTP, cf->log, 0,
+ "%s:%d %s %08x",
+ address, in_port[p].port, s_name[n].name.data,
s_name[n].core_srv_conf);
}
}
}
+ }
#endif
return NGX_CONF_OK;
}
+/*
+ * add the server address, the server names and the server core module
+ * configurations to the port (in_port)
+ */
+
+static ngx_int_t ngx_http_add_address(ngx_conf_t *cf,
+ ngx_http_in_port_t *in_port,
+ ngx_http_listen_t *lscf,
+ ngx_http_core_srv_conf_t *cscf)
+{
+ ngx_http_in_addr_t *in_addr;
+
+ if (in_port->addrs.elts == NULL) {
+ if (ngx_array_init(&in_port->addrs, cf->pool, 10,
+ sizeof(ngx_http_in_addr_t)) == NGX_ERROR)
+ {
+ return NGX_ERROR;
+ }
+ }
+
+ if (!(in_addr = ngx_array_push(&in_port->addrs))) {
+ return NGX_ERROR;
+ }
+
+ in_addr->addr = lscf->addr;
+ in_addr->names.elts = NULL;
+ in_addr->default_server = lscf->default_server;
+ in_addr->core_srv_conf = cscf;
+
+#if (NGX_DEBUG)
+ {
+ u_char text[20];
+ ngx_inet_ntop(AF_INET, &in_addr->addr, text, 20);
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, cf->log, 0, "address: %s:%d",
+ text, in_port->port);
+ }
+#endif
+
+ return ngx_http_add_names(cf, in_addr, cscf);
+}
+
+
+/*
+ * add the server names and the server core module
+ * configurations to the address:port (in_addr)
+ */
+
+static ngx_int_t ngx_http_add_names(ngx_conf_t *cf,
+ ngx_http_in_addr_t *in_addr,
+ ngx_http_core_srv_conf_t *cscf)
+{
+ ngx_uint_t i;
+ ngx_http_server_name_t *server_names, *name;
+
+ if (in_addr->names.elts == NULL) {
+ if (ngx_array_init(&in_addr->names, cf->pool, 10,
+ sizeof(ngx_http_server_name_t)) == NGX_ERROR)
+ {
+ return NGX_ERROR;
+ }
+ }
+
+ server_names = cscf->server_names.elts;
+ for (i = 0; i < cscf->server_names.nelts; i++) {
+
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, cf->log, 0,
+ "name: %s", server_names[i].name.data);
+
+ /* TODO: duplicate names can be checked here */
+
+ if (!(name = ngx_array_push(&in_addr->names))) {
+ return NGX_ERROR;
+ }
+
+ *name = server_names[i];
+ }
+
+ return NGX_OK;
+}
+
+
static char *ngx_http_merge_locations(ngx_conf_t *cf,
ngx_array_t *locations,
void **loc_conf,
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 58021e80a..8544e25c0 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -36,7 +36,7 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd,
void *dummy);
static char *ngx_types_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static char *ngx_set_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf);
-static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+static char *ngx_http_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
static char *ngx_set_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
@@ -126,9 +126,9 @@ static ngx_command_t ngx_http_core_commands[] = {
#if 0
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
#else
- NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
+ NGX_HTTP_SRV_CONF|NGX_CONF_TAKE12,
#endif
- ngx_set_listen,
+ ngx_http_listen,
NGX_HTTP_SRV_CONF_OFFSET,
0,
NULL },
@@ -576,7 +576,7 @@ static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
clcfp = locations->elts;
for (i = 0; i < locations->nelts; i++) {
-#if (HAVE_PCRE)
+#if (NGX_PCRE)
if (clcfp[i]->regex) {
break;
}
@@ -638,7 +638,7 @@ static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
}
}
-#if (HAVE_PCRE)
+#if (NGX_PCRE)
/* regex matches */
@@ -673,7 +673,7 @@ static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
return NGX_HTTP_LOCATION_REGEX;
}
-#endif /* HAVE_PCRE */
+#endif /* NGX_PCRE */
return NGX_OK;
}
@@ -991,7 +991,7 @@ static int ngx_cmp_locations(const void *one, const void *two)
first = *(ngx_http_core_loc_conf_t **) one;
second = *(ngx_http_core_loc_conf_t **) two;
-#if (HAVE_PCRE)
+#if (NGX_PCRE)
if (first->regex && !second->regex) {
/* shift the regex matches to the end */
@@ -1026,7 +1026,7 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
ngx_http_conf_ctx_t *ctx, *pctx;
ngx_http_core_srv_conf_t *cscf;
ngx_http_core_loc_conf_t *clcf, *pclcf, **clcfp;
-#if (HAVE_PCRE)
+#if (NGX_PCRE)
ngx_str_t err;
u_char errstr[NGX_MAX_CONF_ERRSTR];
#endif
@@ -1076,7 +1076,7 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
&& value[1].data[0] == '~'
&& value[1].data[1] == '*'))
{
-#if (HAVE_PCRE)
+#if (NGX_PCRE)
err.len = NGX_MAX_CONF_ERRSTR;
err.data = errstr;
@@ -1129,7 +1129,7 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
return NGX_CONF_ERROR;
}
-#if (HAVE_PCRE)
+#if (NGX_PCRE)
if (clcf->regex == NULL
&& ngx_strncmp(clcf->name.data, pclcf->name.data, pclcf->name.len)
!= 0)
@@ -1323,12 +1323,8 @@ static char *ngx_http_core_merge_srv_conf(ngx_conf_t *cf,
n->name.len = ngx_strlen(n->name.data);
n->core_srv_conf = conf;
+ n->wildcard = 0;
-#if 0
- ctx = (ngx_http_conf_ctx_t *)
- cf->cycle->conf_ctx[ngx_http_module.index];
- cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
-#endif
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
if (cmcf->max_server_name_len < n->name.len) {
@@ -1512,7 +1508,7 @@ static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
}
-static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+static char *ngx_http_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_http_core_srv_conf_t *scf = conf;
@@ -1607,13 +1603,8 @@ static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_http_server_name_t *sn;
ngx_http_core_main_conf_t *cmcf;
- /* TODO: several names */
/* TODO: warn about duplicate 'server_name' directives */
-#if 0
- ctx = (ngx_http_conf_ctx_t *) cf->cycle->conf_ctx[ngx_http_module.index];
- cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
-#endif
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
value = cf->args->elts;
@@ -1627,12 +1618,23 @@ static char *ngx_set_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR;
}
- ngx_test_null(sn, ngx_push_array(&scf->server_names), NGX_CONF_ERROR);
+ if (!(sn = ngx_array_push(&scf->server_names))) {
+ return NGX_CONF_ERROR;
+ }
sn->name.len = value[i].len;
sn->name.data = value[i].data;
sn->core_srv_conf = scf;
+ if (sn->name.data[0] == '*') {
+ sn->name.len--;
+ sn->name.data++;
+ sn->wildcard = 1;
+
+ } else {
+ sn->wildcard = 0;
+ }
+
if (cmcf->max_server_name_len < sn->name.len) {
cmcf->max_server_name_len = sn->name.len;
}
@@ -1806,7 +1808,7 @@ static char *ngx_http_lowat_check(ngx_conf_t *cf, void *post, void *data)
{
ssize_t *np = data;
-#if __FreeBSD__
+#if (NGX_FREEBSD)
if (*np >= ngx_freebsd_net_inet_tcp_sendspace) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 787f8b8fb..9a17130b8 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -96,13 +96,15 @@ typedef struct {
ngx_http_core_srv_conf_t *core_srv_conf; /* default server conf
for this address:port */
- unsigned default_server:1;
+ ngx_uint_t default_server; /* unsigned default_server:1; */
} ngx_http_in_addr_t;
typedef struct {
ngx_str_t name;
ngx_http_core_srv_conf_t *core_srv_conf; /* virtual name server conf */
+
+ ngx_uint_t wildcard; /*unsigned wildcard:1; */
} ngx_http_server_name_t;
@@ -135,7 +137,7 @@ typedef struct ngx_http_core_loc_conf_s ngx_http_core_loc_conf_t;
struct ngx_http_core_loc_conf_s {
ngx_str_t name; /* location name */
-#if (HAVE_PCRE)
+#if (NGX_PCRE)
ngx_regex_t *regex;
#endif
diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c
index 5b7f3eb27..a083b45f8 100644
--- a/src/http/ngx_http_header_filter.c
+++ b/src/http/ngx_http_header_filter.c
@@ -317,10 +317,15 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
if (r->headers_out.content_length == NULL) {
if (r->headers_out.content_length_n >= 0) {
+ b->last = ngx_sprintf(b->last, "Content-Length: %O" CRLF,
+ r->headers_out.content_length_n);
+
+#if 0
b->last += ngx_snprintf((char *) b->last,
sizeof("Content-Length: ") + NGX_OFF_T_LEN + 2,
"Content-Length: " OFF_T_FMT CRLF,
r->headers_out.content_length_n);
+#endif
}
}
@@ -372,7 +377,7 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
{
b->last = ngx_cpymem(b->last, "Last-Modified: ",
sizeof("Last-Modified: ") - 1);
- b->last += ngx_http_time(b->last, r->headers_out.last_modified_time);
+ b->last = ngx_http_time(b->last, r->headers_out.last_modified_time);
*(b->last++) = CR; *(b->last++) = LF;
}
@@ -389,10 +394,14 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
if (clcf->keepalive_header
&& (r->headers_in.gecko || r->headers_in.konqueror))
{
+ b->last = ngx_sprintf(b->last, "Keep-Alive: timeout=%T" CRLF,
+ clcf->keepalive_header);
+#if 0
b->last += ngx_snprintf((char *) b->last,
sizeof("Keep-Alive: timeout=") + TIME_T_LEN + 2,
"Keep-Alive: timeout=" TIME_T_FMT CRLF,
clcf->keepalive_header);
+#endif
}
} else {
diff --git a/src/http/ngx_http_log_handler.c b/src/http/ngx_http_log_handler.c
index 51166cf0c..9a1389d13 100644
--- a/src/http/ngx_http_log_handler.c
+++ b/src/http/ngx_http_log_handler.c
@@ -210,9 +210,13 @@ static u_char *ngx_http_log_addr(ngx_http_request_t *r, u_char *buf,
static u_char *ngx_http_log_connection(ngx_http_request_t *r, u_char *buf,
uintptr_t data)
{
+ return ngx_sprintf(buf, "%ui", r->connection->number);
+
+#if 0
return buf + ngx_snprintf((char *) buf, NGX_INT_T_LEN + 1,
"%" NGX_UINT_T_FMT,
r->connection->number);
+#endif
}
@@ -244,8 +248,12 @@ static u_char *ngx_http_log_msec(ngx_http_request_t *r, u_char *buf,
ngx_gettimeofday(&tv);
+ return ngx_sprintf(buf, "%l.%03l", tv.tv_sec, tv.tv_usec / 1000);
+
+#if 0
return buf + ngx_snprintf((char *) buf, TIME_T_LEN + 5, "%ld.%03ld",
tv.tv_sec, tv.tv_usec / 1000);
+#endif
}
@@ -264,24 +272,36 @@ static u_char *ngx_http_log_request(ngx_http_request_t *r, u_char *buf,
static u_char *ngx_http_log_status(ngx_http_request_t *r, u_char *buf,
uintptr_t data)
{
+ return ngx_sprintf(buf, "%ui",
+ r->err_status ? r->err_status : r->headers_out.status);
+
+#if 0
return buf + ngx_snprintf((char *) buf, 4, "%" NGX_UINT_T_FMT,
r->err_status ? r->err_status : r->headers_out.status);
+#endif
}
static u_char *ngx_http_log_length(ngx_http_request_t *r, u_char *buf,
uintptr_t data)
{
+ return ngx_sprintf(buf, "%O", r->connection->sent);
+
+#if 0
return buf + ngx_snprintf((char *) buf, NGX_OFF_T_LEN + 1, OFF_T_FMT,
r->connection->sent);
+#endif
}
static u_char *ngx_http_log_apache_length(ngx_http_request_t *r, u_char *buf,
uintptr_t data)
{
+ return ngx_sprintf(buf, "%O", r->connection->sent - r->header_size);
+#if 0
return buf + ngx_snprintf((char *) buf, NGX_OFF_T_LEN + 1, OFF_T_FMT,
r->connection->sent - r->header_size);
+#endif
}
@@ -467,8 +487,7 @@ static u_char *ngx_http_log_header_out(ngx_http_request_t *r, u_char *buf,
return (u_char *)
sizeof("Mon, 28 Sep 1970 06:00:00 GMT") - 1;
}
- return buf + ngx_http_time(buf,
- r->headers_out.last_modified_time);
+ return ngx_http_time(buf, r->headers_out.last_modified_time);
}
if (buf) {
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 6069847f5..74173d873 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1091,27 +1091,47 @@ static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r)
name = r->virtual_names->elts;
for (i = 0; i < r->virtual_names->nelts; i++) {
- if (r->headers_in.host_name_len != name[i].name.len) {
- continue;
- }
- if (ngx_strncasecmp(r->headers_in.host->value.data,
- name[i].name.data,
- r->headers_in.host_name_len) == 0)
- {
- r->srv_conf = name[i].core_srv_conf->ctx->srv_conf;
- r->loc_conf = name[i].core_srv_conf->ctx->loc_conf;
- r->server_name = &name[i].name;
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "server name: %s", name[i].name.data);
+
+ if (name[i].wildcard) {
+ if (r->headers_in.host_name_len <= name[i].name.len) {
+ continue;
+ }
- clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
- r->connection->log->file = clcf->err_log->file;
- if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION))
+ if (ngx_rstrncasecmp(r->headers_in.host->value.data,
+ name[i].name.data,
+ name[i].name.len) == 0)
{
- r->connection->log->log_level = clcf->err_log->log_level;
+ continue;
}
- break;
+ } else {
+ if (r->headers_in.host_name_len != name[i].name.len) {
+ continue;
+ }
+
+ if (ngx_strncasecmp(r->headers_in.host->value.data,
+ name[i].name.data,
+ name[i].name.len) != 0)
+ {
+ continue;
+ }
}
+
+ r->srv_conf = name[i].core_srv_conf->ctx->srv_conf;
+ r->loc_conf = name[i].core_srv_conf->ctx->loc_conf;
+ r->server_name = &name[i].name;
+
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+ r->connection->log->file = clcf->err_log->file;
+
+ if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
+ r->connection->log->log_level = clcf->err_log->log_level;
+ }
+
+ break;
}
if (i == r->virtual_names->nelts) {
@@ -1562,7 +1582,13 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
if (b != c->buffer) {
- /* move the large header buffers to the free list */
+ /*
+ * If the large header buffers were allocated while the previous
+ * request processing then we do not use c->buffer for
+ * the pipelined request (see ngx_http_init_request()).
+ *
+ * Now we would move the large header buffers to the free list.
+ */
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
@@ -1614,6 +1640,14 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
hc->pipeline = 0;
+ /*
+ * To keep a memory footprint as small as possible for an idle
+ * keepalive connection we try to free the ngx_http_request_t and
+ * c->buffer's memory if they were allocated outside the c->pool.
+ * The large header buffers are always allocated outside the c->pool and
+ * are freed too.
+ */
+
if (ngx_pfree(c->pool, r) == NGX_OK) {
hc->request = NULL;
}
@@ -1621,6 +1655,12 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
b = c->buffer;
if (ngx_pfree(c->pool, b->start) == NGX_OK) {
+
+ /*
+ * the special note for ngx_http_keepalive_handler() that
+ * c->buffer's memory was freed
+ */
+
b->pos = NULL;
} else {
@@ -1655,7 +1695,7 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
rev->event_handler = ngx_http_keepalive_handler;
if (wev->active) {
- if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
if (ngx_del_event(wev, NGX_WRITE_EVENT, NGX_DISABLE_EVENT)
== NGX_ERROR)
{
@@ -1702,7 +1742,7 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
}
#if 0
- /* if "keepalive_buffers off" then we need some other place */
+ /* if ngx_http_request_t was freed then we need some other place */
r->http_state = NGX_HTTP_KEEPALIVE_STATE;
#endif
@@ -1734,7 +1774,7 @@ static void ngx_http_keepalive_handler(ngx_event_t *rev)
#if (HAVE_KQUEUE)
- if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
if (rev->pending_eof) {
ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno,
"kevent() reported that client %s closed "
@@ -1751,6 +1791,13 @@ static void ngx_http_keepalive_handler(ngx_event_t *rev)
size = b->end - b->start;
if (b->pos == NULL) {
+
+ /*
+ * The c->buffer's memory was freed by ngx_http_set_keepalive().
+ * However, the c->buffer->start and c->buffer->end were not changed
+ * to keep the buffer size.
+ */
+
if (!(b->pos = ngx_palloc(c->pool, size))) {
ngx_http_close_connection(c);
return;
@@ -1824,7 +1871,7 @@ static void ngx_http_set_lingering_close(ngx_http_request_t *r)
wev->event_handler = ngx_http_empty_handler;
if (wev->active) {
- if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
if (ngx_del_event(wev, NGX_WRITE_EVENT, NGX_DISABLE_EVENT)
== NGX_ERROR)
{
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index 022b8a8cf..8a9c8f24f 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -38,11 +38,11 @@
#define NGX_HTTP_PARSE_HEADER_ERROR 14
#define NGX_HTTP_PARSE_INVALID_HEADER 14
#define NGX_HTTP_PARSE_TOO_LONG_HEADER 15
-#define NGX_HTTP_PARSE_NO_HOST_HEADER 17
-#define NGX_HTTP_PARSE_INVALID_CL_HEADER 18
-#define NGX_HTTP_PARSE_POST_WO_CL_HEADER 19
-#define NGX_HTTP_PARSE_HTTP_TO_HTTPS 20
-#define NGX_HTTP_PARSE_INVALID_HOST 21
+#define NGX_HTTP_PARSE_NO_HOST_HEADER 16
+#define NGX_HTTP_PARSE_INVALID_CL_HEADER 17
+#define NGX_HTTP_PARSE_POST_WO_CL_HEADER 18
+#define NGX_HTTP_PARSE_HTTP_TO_HTTPS 19
+#define NGX_HTTP_PARSE_INVALID_HOST 20
#define NGX_HTTP_OK 200
diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c
index a8c68947f..37e0f3fab 100644
--- a/src/http/ngx_http_write_filter.c
+++ b/src/http/ngx_http_write_filter.c
@@ -125,6 +125,7 @@ ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
if (!last) {
ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
"the http output chain is empty");
+ return NGX_ERROR;
}
return NGX_OK;
}
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c
index 8603ab2d9..f2ba3a451 100644
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -210,59 +210,3 @@ int ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir)
return NGX_OK;
}
-
-
-#if 0
-
-ssize_t ngx_read_file(ngx_file_t *file, char *buf, size_t size, off_t offset)
-{
- if (!file->read->ready) {
-
- ngx_memzero(&file->iocb, sizeof(iocb));
- file->iocb.aio_fildes = file->fd;
- file->iocb.aio_buf = buf;
- file->iocb.aio_nbytes = size;
- file->iocb.aio_offset = offset;
-#if (USE_AIO_KQUEUE)
- file->iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
- file->iocb.aio_sigevent.sigev_notify_kqueue = tid->kq;
- file->iocb.aio_sigevent.sigev_value = (union sigval) file;
-#endif
-#if (USE_AIO_SIGNAL)
- file->iocb.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
- file->iocb.aio_sigevent.sigev_signo = NGX_SIGAIO;
-#ifndef __FreeBSD__
- file->iocb.aio_sigevent.sigev_value.sival_ptr = file;
-#endif
-#endif
-
- if (aio_read(&file->iocb) == -1) {
- ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno,
- "aio_read() failed");
- return NGX_ERROR;
-
- n = aio_error(&file->iocb);
- if (n == EINPROGRESS)
- return NGX_AGAIN;
-
- if (n == -1) {
- ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno,
- "aio_read() failed");
- return NGX_ERROR;
- }
- }
-
- ngx_assert(file->iocb.aio_buf == buf), return NGX_ERROR,
- "ngx_aio_read_file: another buffer is passed");
-
- n = aio_return(&file->iocb);
- if (n == -1) {
- ngx_log_error(NGX_LOG_ERR, file->log, ngx_errno,
- "aio_read() failed");
- return NGX_ERROR;
- }
-
- return n;
-}
-
-#endif
diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h
index 3ba167004..06c22f5d3 100644
--- a/src/os/unix/ngx_files.h
+++ b/src/os/unix/ngx_files.h
@@ -99,7 +99,7 @@ int ngx_open_dir(ngx_str_t *name, ngx_dir_t *dir);
#define ngx_de_name(dir) (dir)->de->d_name
-#ifdef __FreeBSD__
+#if (NGX_FREEBSD)
#define ngx_de_namelen(dir) (dir)->de->d_namlen
#else
#define ngx_de_namelen(dir) ngx_strlen((dir)->de->d_name)
diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h
index 7961a3b6e..4840a9970 100644
--- a/src/os/unix/ngx_freebsd_config.h
+++ b/src/os/unix/ngx_freebsd_config.h
@@ -22,8 +22,8 @@
#include <grp.h>
#include <dirent.h>
-#include <sys/uio.h>
#include <sys/filio.h> /* FIONBIO */
+#include <sys/uio.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -41,12 +41,11 @@
#include <libutil.h> /* setproctitle() before 4.1 */
#include <osreldate.h>
#include <sys/sysctl.h>
+#include <sys/param.h> /* ALIGN() */
#if __FreeBSD_version < 400017
-#include <sys/param.h> /* ALIGN() */
-
/* FreeBSD 3.x has no CMSG_SPACE() at all and has the broken CMSG_DATA() */
#undef CMSG_SPACE
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c
index d29debfbc..8303c0631 100644
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -57,7 +57,7 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
#if (HAVE_KQUEUE)
- if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) && wev->pending_eof) {
+ if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
"kevent() reported about an closed connection");
@@ -131,7 +131,6 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
send += size;
}
- /* get the file buf */
if (cl && cl->buf->in_file && send < limit) {
file = cl->buf;
@@ -164,17 +163,18 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
&& fprev == cl->buf->file_pos);
}
+
if (file) {
+
/* create the tailer iovec and coalesce the neighbouring bufs */
prev = NULL;
iov = NULL;
- for (/* void */;
- cl && header.nelts < IOV_MAX && send < limit;
- cl = cl->next)
- {
+ while (cl && header.nelts < IOV_MAX && send < limit) {
+
if (ngx_buf_special(cl->buf)) {
+ cl = cl->next;
continue;
}
@@ -202,6 +202,7 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
prev = cl->buf->pos + size;
send += size;
+ cl = cl->next;
}
}
@@ -210,7 +211,6 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
if (ngx_freebsd_use_tcp_nopush
&& c->tcp_nopush == NGX_TCP_NOPUSH_UNSET)
{
-
if (ngx_tcp_nopush(c->fd) == NGX_ERROR) {
err = ngx_errno;
@@ -275,6 +275,20 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
}
}
+ if (rc == 0 && sent == 0) {
+
+ /*
+ * rc and sent are equals to zero when someone has truncated
+ * the file, so the offset became beyond the end of the file
+ */
+
+ ngx_log_error(NGX_LOG_ALERT, c->log, 0,
+ "sendfile() reported that \"%s\" was truncated",
+ file->file->name.data);
+
+ return NGX_CHAIN_ERROR;
+ }
+
ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0,
"sendfile: %d, @" OFF_T_FMT " " OFF_T_FMT ":%d",
rc, file->file_pos, sent, fsize + hsize);
diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h
index 11427d329..9a0fee9ba 100644
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -8,11 +8,11 @@
#define _NGX_LINUX_CONFIG_H_INCLUDED_
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* pread(), pwrite(), gethostname() */
+#endif
#define _FILE_OFFSET_BITS 64
-#define _LARGEFILE_SOURCE
-
#include <sys/types.h>
#include <sys/time.h>
@@ -51,11 +51,11 @@
#include <ngx_auto_config.h>
-#if (HAVE_PRCTL)
+#if (NGX_HAVE_SYS_PRCTL_H)
#include <sys/prctl.h>
#endif
-#if (HAVE_SENDFILE64)
+#if (NGX_HAVE_SENDFILE64)
#include <sys/sendfile.h>
#else
extern ssize_t sendfile(int s, int fd, int32_t *offset, size_t size);
diff --git a/src/os/unix/ngx_linux_sendfile_chain.c b/src/os/unix/ngx_linux_sendfile_chain.c
index 38a2a96d2..4de7ac2cd 100644
--- a/src/os/unix/ngx_linux_sendfile_chain.c
+++ b/src/os/unix/ngx_linux_sendfile_chain.c
@@ -37,7 +37,7 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
ngx_event_t *wev;
ngx_chain_t *cl;
struct iovec *iov, headers[NGX_HEADERS];
-#if (HAVE_SENDFILE64)
+#if (NGX_HAVE_SENDFILE64)
off_t offset;
#else
int32_t offset;
@@ -167,7 +167,7 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
}
if (file) {
-#if (HAVE_SENDFILE64)
+#if (NGX_HAVE_SENDFILE64)
offset = file->file_pos;
#else
offset = (int32_t) file->file_pos;
diff --git a/src/os/unix/ngx_os.h b/src/os/unix/ngx_os.h
index b28a73ffb..dc9f7a803 100644
--- a/src/os/unix/ngx_os.h
+++ b/src/os/unix/ngx_os.h
@@ -66,17 +66,15 @@ extern ngx_int_t ngx_inherited_nonblocking;
#define ngx_stderr_fileno STDERR_FILENO
-#ifdef __FreeBSD__
+#if (NGX_FREEBSD)
#include <ngx_freebsd.h>
-#endif
-#ifdef __linux__
+#elif (NGX_LINUX)
#include <ngx_linux.h>
-#endif
-#ifdef SOLARIS
+#elif (NGX_SOLARIS)
#include <ngx_solaris.h>
#endif
diff --git a/src/os/unix/ngx_posix_config.h b/src/os/unix/ngx_posix_config.h
index bf0f5d842..bac02f7dd 100644
--- a/src/os/unix/ngx_posix_config.h
+++ b/src/os/unix/ngx_posix_config.h
@@ -8,9 +8,20 @@
#define _NGX_POSIX_CONFIG_H_INCLUDED_
+#if 0
+#define _XOPEN_SOURCE
+#define _XOPEN_SOURCE_EXTENDED 1
+#endif
+
+
#include <sys/types.h>
#include <sys/time.h>
+#if (NGX_HAVE_UNISTD_H)
#include <unistd.h>
+#endif
+#if (NGX_HAVE_INTTYPES_H)
+#include <inttypes.h>
+#endif
#include <stdarg.h>
#include <stddef.h> /* offsetof() */
#include <stdio.h>
@@ -22,8 +33,12 @@
#include <grp.h>
#include <dirent.h>
-#include <sys/uio.h>
+#if (NGX_HAVE_SYS_FILIO_H)
#include <sys/filio.h> /* FIONBIO */
+#endif
+#include <sys/ioctl.h> /* FIONBIO */
+
+#include <sys/uio.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -34,9 +49,19 @@
#include <sys/socket.h>
#include <netinet/in.h>
+#include <netinet/tcp.h> /* TCP_NODELAY */
#include <arpa/inet.h>
#include <netdb.h>
+#if (NGX_HAVE_LIMITS_H)
+#include <limits.h> /* IOV_MAX */
+#endif
+
+#ifndef IOV_MAX
+#define IOV_MAX 16
+#endif
+
+
#include <ngx_auto_config.h>
@@ -53,6 +78,32 @@
#endif
+#if (HAVE_KQUEUE)
+#include <sys/event.h>
+#endif
+
+
+#if (HAVE_DEVPOLL)
+#include <sys/ioctl.h>
+#include <sys/devpoll.h>
+#endif
+
+
+#if (__FreeBSD__) && (__FreeBSD_version < 400017)
+
+#include <sys/param.h> /* ALIGN() */
+
+/* FreeBSD 3.x has no CMSG_SPACE() at all and has the broken CMSG_DATA() */
+
+#undef CMSG_SPACE
+#define CMSG_SPACE(l) (ALIGN(sizeof(struct cmsghdr)) + ALIGN(l))
+
+#undef CMSG_DATA
+#define CMSG_DATA(cmsg) ((u_char *)(cmsg) + ALIGN(sizeof(struct cmsghdr)))
+
+#endif
+
+
#define ngx_setproctitle(title)
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c
index 134c27691..1c7b1b6c0 100644
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -33,6 +33,12 @@ int ngx_os_init(ngx_log_t *log)
}
+void ngx_os_status(ngx_log_t *log)
+{
+ ngx_posix_status(log);
+}
+
+
#endif
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
index aff242c19..4f7ed6409 100644
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -236,7 +236,7 @@ void ngx_process_get_status()
return;
}
-#if (SOLARIS)
+#if (NGX_SOLARIS)
/*
* Solaris always calls the signal handler for each exited process
diff --git a/src/os/unix/ngx_process.h b/src/os/unix/ngx_process.h
index 0cea30210..9cb0700d6 100644
--- a/src/os/unix/ngx_process.h
+++ b/src/os/unix/ngx_process.h
@@ -54,7 +54,13 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
void ngx_process_get_status(void);
+
+#if (NGX_HAVE_SCHED_YIELD)
#define ngx_sched_yield() sched_yield()
+#else
+#define ngx_sched_yield() usleep(1)
+#endif
+
extern int ngx_argc;
extern char **ngx_argv;
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index c43a7eb00..1da491526 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -175,11 +175,14 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle)
if (ngx_timer) {
ngx_timer = 0;
- ngx_start_worker_processes(cycle, ccf->worker_processes,
- NGX_PROCESS_JUST_RESPAWN);
- live = 1;
- ngx_signal_worker_processes(cycle,
+
+ if (!ngx_noaccepting) {
+ ngx_start_worker_processes(cycle, ccf->worker_processes,
+ NGX_PROCESS_JUST_RESPAWN);
+ live = 1;
+ ngx_signal_worker_processes(cycle,
ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
+ }
}
if (ngx_reconfigure) {
@@ -578,16 +581,14 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
- if (ccf->group != (gid_t) NGX_CONF_UNSET) {
+ if (geteuid() == 0) {
if (setgid(ccf->group) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"setgid(%d) failed", ccf->group);
/* fatal */
exit(2);
}
- }
- if (ccf->user != (uid_t) NGX_CONF_UNSET) {
if (setuid(ccf->user) == -1) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
"setuid(%d) failed", ccf->user);
@@ -596,7 +597,7 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
}
}
-#if (HAVE_PR_SET_DUMPABLE)
+#if (NGX_HAVE_PR_SET_DUMPABLE)
/* allow coredump after setuid() in Linux 2.4.x */
diff --git a/src/os/unix/ngx_readv_chain.c b/src/os/unix/ngx_readv_chain.c
index a529b3d3f..2db998a86 100644
--- a/src/os/unix/ngx_readv_chain.c
+++ b/src/os/unix/ngx_readv_chain.c
@@ -22,7 +22,7 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
rev = c->read;
- if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
"readv: eof:%d, avail:%d, err:%d",
rev->pending_eof, rev->available, rev->kq_errno);
@@ -81,7 +81,7 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
n = readv(c->fd, (struct iovec *) io.elts, io.nelts);
if (n >= 0) {
- if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
rev->available -= n;
/*
@@ -186,7 +186,7 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
} else if (n > 0) {
- if (n < size && !(ngx_event_flags & NGX_HAVE_GREEDY_EVENT)) {
+ if (n < size && !(ngx_event_flags & NGX_USE_GREEDY_EVENT)) {
rev->ready = 0;
}
diff --git a/src/os/unix/ngx_recv.c b/src/os/unix/ngx_recv.c
index 6e5b8c06d..d58ca9e3d 100644
--- a/src/os/unix/ngx_recv.c
+++ b/src/os/unix/ngx_recv.c
@@ -19,7 +19,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
rev = c->read;
- if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
"recv: eof:%d, avail:%d, err:%d",
rev->pending_eof, rev->available, rev->kq_errno);
@@ -60,7 +60,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
"recv: fd:%d %d of %d", c->fd, n, size);
if (n >= 0) {
- if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
rev->available -= n;
/*
@@ -139,7 +139,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
} else if (n > 0) {
if ((size_t) n < size
- && !(ngx_event_flags & NGX_HAVE_GREEDY_EVENT))
+ && !(ngx_event_flags & NGX_USE_GREEDY_EVENT))
{
rev->ready = 0;
}
diff --git a/src/os/unix/ngx_send.c b/src/os/unix/ngx_send.c
index f09dadb50..ff501c30a 100644
--- a/src/os/unix/ngx_send.c
+++ b/src/os/unix/ngx_send.c
@@ -19,7 +19,7 @@ ssize_t ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size)
#if (HAVE_KQUEUE)
- if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) && wev->pending_eof) {
+ if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
"kevent() reported about an closed connection");
diff --git a/src/os/unix/ngx_setproctitle.c b/src/os/unix/ngx_setproctitle.c
index 6ac87077f..2e41108b5 100644
--- a/src/os/unix/ngx_setproctitle.c
+++ b/src/os/unix/ngx_setproctitle.c
@@ -76,7 +76,7 @@ void ngx_setproctitle(char *title)
{
u_char *p;
-#if (SOLARIS)
+#if (NGX_SOLARIS)
ngx_int_t i;
size_t size;
@@ -90,7 +90,7 @@ void ngx_setproctitle(char *title)
p = ngx_cpystrn(p, (u_char *) title, ngx_os_argv_last - (char *) p);
-#if (SOLARIS)
+#if (NGX_SOLARIS)
size = 0;
diff --git a/src/os/unix/ngx_socket.c b/src/os/unix/ngx_socket.c
index 3e188bde6..da936b2fb 100644
--- a/src/os/unix/ngx_socket.c
+++ b/src/os/unix/ngx_socket.c
@@ -44,7 +44,7 @@ int ngx_blocking(ngx_socket_t s)
#endif
-#ifdef __FreeBSD__
+#if (NGX_FREEBSD)
int ngx_tcp_nopush(ngx_socket_t s)
{
@@ -67,7 +67,7 @@ int ngx_tcp_push(ngx_socket_t s)
(const void *) &tcp_nopush, sizeof(int));
}
-#elif __linux__
+#elif (NGX_LINUX)
int ngx_tcp_nopush(ngx_socket_t s)
{
diff --git a/src/os/unix/ngx_socket.h b/src/os/unix/ngx_socket.h
index 67d0d41de..34449d090 100644
--- a/src/os/unix/ngx_socket.h
+++ b/src/os/unix/ngx_socket.h
@@ -37,7 +37,7 @@ int ngx_blocking(ngx_socket_t s);
int ngx_tcp_nopush(ngx_socket_t s);
int ngx_tcp_push(ngx_socket_t s);
-#ifdef __linux__
+#if (NGX_LINUX)
#define ngx_tcp_nopush_n "setsockopt(TCP_CORK)"
#define ngx_tcp_push_n "setsockopt(!TCP_CORK)"
diff --git a/src/os/unix/ngx_solaris_config.h b/src/os/unix/ngx_solaris_config.h
index 96c119cab..5d94cdc98 100644
--- a/src/os/unix/ngx_solaris_config.h
+++ b/src/os/unix/ngx_solaris_config.h
@@ -8,8 +8,6 @@
#define _NGX_SOLARIS_CONFIG_H_INCLUDED_
-#define SOLARIS 1
-
#define _REENTRANT
#define _FILE_OFFSET_BITS 64 /* must be before <sys/types.h> */
@@ -28,8 +26,8 @@
#include <grp.h>
#include <dirent.h>
-#include <sys/uio.h>
#include <sys/filio.h> /* FIONBIO */
+#include <sys/uio.h>
#include <sys/stat.h>
#include <fcntl.h>
diff --git a/src/os/unix/ngx_thread.h b/src/os/unix/ngx_thread.h
index 7b5dc239c..16e216ef0 100644
--- a/src/os/unix/ngx_thread.h
+++ b/src/os/unix/ngx_thread.h
@@ -28,7 +28,7 @@ typedef pthread_t ngx_tid_t;
#define ngx_thread_self() pthread_self()
#define ngx_log_tid (int) ngx_thread_self()
-#if defined(__FreeBSD__) && !defined(NGX_LINUXTHREADS)
+#if (NGX_FREEBSD) && !(NGX_LINUXTHREADS)
#define TID_T_FMT PTR_FMT
#else
#define TID_T_FMT "%d"
diff --git a/src/os/unix/ngx_time.h b/src/os/unix/ngx_time.h
index 793e32e7c..0ead0d837 100644
--- a/src/os/unix/ngx_time.h
+++ b/src/os/unix/ngx_time.h
@@ -42,8 +42,14 @@ typedef struct tm ngx_tm_t;
#endif
-#if (SOLARIS)
+#if (NGX_SOLARIS)
+
#define ngx_timezone(isdst) (- (isdst ? altzone : timezone) / 60)
+
+#else
+
+#define ngx_timezone(isdst) (- (isdst ? timezone + 3600 : timezone) / 60)
+
#endif
diff --git a/src/os/unix/ngx_writev_chain.c b/src/os/unix/ngx_writev_chain.c
index a3595ff0c..e57b59305 100644
--- a/src/os/unix/ngx_writev_chain.c
+++ b/src/os/unix/ngx_writev_chain.c
@@ -32,7 +32,7 @@ ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
#if (HAVE_KQUEUE)
- if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) && wev->pending_eof) {
+ if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
"kevent() reported about an closed connection");