changeset 469:2ff194b74f1e release-0.1.9

nginx-0.1.9-RELEASE import *) Bugfix: the proxied request was sent without arguments if the request contains "//", "/./", "/../" or "%XX". *) Bugfix: the large compressed responses may be transferred not completely. *) Bugfix: the files bigger than 2G was not transferred on Linux that does not support sendfile64(). *) Bugfix: while the build configuration on Linux the --with-poll_module parameter was required; the bug had appeared in 0.1.8.
author Igor Sysoev <igor@sysoev.ru>
date Thu, 25 Nov 2004 16:17:31 +0000
parents 1a67596d0349
children 45b86532d9c8
files auto/cc/bcc auto/cc/conf auto/cc/icc auto/cc/msvc auto/cc/owc auto/configure auto/endianess auto/feature auto/func auto/init auto/install auto/lib/md5/conf auto/lib/md5/make auto/lib/openssl/conf auto/lib/openssl/make auto/lib/pcre/conf auto/lib/pcre/make auto/lib/zlib/conf auto/lib/zlib/make auto/make auto/modules auto/options auto/os/conf auto/os/freebsd auto/os/linux auto/os/solaris auto/os/win32 auto/summary auto/threads auto/unix docs/xml/nginx/changes.xml src/core/nginx.c src/core/nginx.h src/core/ngx_buf.c src/core/ngx_config.h src/core/ngx_connection.h src/core/ngx_output_chain.c src/core/ngx_times.c src/event/modules/ngx_aio_module.c src/event/modules/ngx_devpoll_module.c src/event/modules/ngx_epoll_module.c src/event/modules/ngx_kqueue_module.c src/event/modules/ngx_rtsig_module.c src/event/modules/ngx_select_module.c src/event/ngx_event.c src/event/ngx_event.h src/event/ngx_event_openssl.c src/event/ngx_event_openssl.h src/event/ngx_event_pipe.c src/event/ngx_event_posted.c src/http/modules/ngx_http_gzip_filter.c src/http/modules/ngx_http_index_handler.c src/http/modules/proxy/ngx_http_proxy_cache.c src/http/modules/proxy/ngx_http_proxy_handler.c src/http/modules/proxy/ngx_http_proxy_handler.h src/http/modules/proxy/ngx_http_proxy_upstream.c src/http/ngx_http_cache.c src/http/ngx_http_cache.h src/http/ngx_http_core_module.c src/http/ngx_http_file_cache.c src/http/ngx_http_parse.c src/http/ngx_http_request.c src/http/ngx_http_request.h src/os/unix/ngx_aio_read.c src/os/unix/ngx_aio_write.c src/os/unix/ngx_alloc.c src/os/unix/ngx_alloc.h src/os/unix/ngx_channel.c src/os/unix/ngx_errno.c src/os/unix/ngx_errno.h src/os/unix/ngx_files.c src/os/unix/ngx_freebsd_config.h src/os/unix/ngx_freebsd_init.c src/os/unix/ngx_freebsd_rfork_thread.c src/os/unix/ngx_freebsd_sendfile_chain.c src/os/unix/ngx_linux_config.h src/os/unix/ngx_linux_init.c src/os/unix/ngx_linux_sendfile_chain.c src/os/unix/ngx_os.h src/os/unix/ngx_posix_config.h src/os/unix/ngx_posix_init.c src/os/unix/ngx_process_cycle.c src/os/unix/ngx_readv_chain.c src/os/unix/ngx_recv.c src/os/unix/ngx_send.c src/os/unix/ngx_shared.c src/os/unix/ngx_socket.c src/os/unix/ngx_socket.h src/os/unix/ngx_solaris_config.h src/os/unix/ngx_solaris_init.c src/os/unix/ngx_thread.h src/os/unix/ngx_time.c src/os/unix/ngx_time.h src/os/unix/ngx_writev_chain.c src/os/win32/ngx_os.h src/os/win32/ngx_time.h src/os/win32/ngx_win32_config.h
diffstat 97 files changed, 573 insertions(+), 478 deletions(-) [+]
line wrap: on
line diff
--- a/auto/cc/bcc
+++ b/auto/cc/bcc
@@ -34,10 +34,10 @@ 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"
+CORE_DEPS="$CORE_DEPS $NGX_OBJS/ngx_config.csm"
+NGX_PCH="$NGX_OBJS/ngx_config.csm"
+NGX_BUILD_PCH="-H=$NGX_OBJS/ngx_config.csm"
+NGX_USE_PCH="-Hu -H=$NGX_OBJS/ngx_config.csm"
 
 
 # Win32 GUI mode application
@@ -45,11 +45,11 @@ LINK="\$(CC) -laa"
 
 
 # the resource file
-NGX_RES="$OBJS/nginx.res"
-NGX_RCC="brcc32 -fo$OBJS/nginx.res \$(CORE_INCS) $NGX_WIN32_RC"
+NGX_RES="$NGX_OBJS/nginx.res"
+NGX_RCC="brcc32 -fo$NGX_OBJS/nginx.res \$(CORE_INCS) $NGX_WIN32_RC"
 # the pragma allows to link the resource file using bcc32 and
 # to avoid the direct ilink32 calling and the c0w32.obj's WinMain/main problem
-NGX_PRAGMA="#pragma resource \"$OBJS/nginx.res\""
+NGX_PRAGMA="#pragma resource \"$NGX_OBJS/nginx.res\""
 
 
 ngx_include_opt="-I"
--- a/auto/cc/conf
+++ b/auto/cc/conf
@@ -92,11 +92,11 @@ fi
 CFLAGS="$CFLAGS $NGX_CC_OPT"
 
 
-if [ "$PLATFORM" != win32 ]; then
+if [ "$NGX_PLATFORM" != win32 ]; then
 
     if test -n "$NGX_LD_OPT"; then
         ngx_feature=--with-ld-opt=\"$NGX_LD_OPT\"
-        ngx_feature_name="DUMMY"
+        ngx_feature_name=
         ngx_feature_run=no
         ngx_feature_incs=
         ngx_feature_libs=
@@ -111,7 +111,7 @@ if [ "$PLATFORM" != win32 ]; then
     fi
 
     ngx_feature="gcc variadic macros"
-    ngx_feature_name="HAVE_GCC_VARIADIC_MACROS"
+    ngx_feature_name="NGX_HAVE_GCC_VARIADIC_MACROS"
     ngx_feature_run=yes
     ngx_feature_incs="#include <stdio.h>
 #define var(dummy, args...)  sprintf(args)"
@@ -123,7 +123,7 @@ if [ "$PLATFORM" != win32 ]; then
 
 
     ngx_feature="C99 variadic macros"
-    ngx_feature_name="HAVE_C99_VARIADIC_MACROS"
+    ngx_feature_name="NGX_HAVE_C99_VARIADIC_MACROS"
     ngx_feature_run=yes
     ngx_feature_incs="#include <stdio.h>
 #define var(dummy, ...) sprintf(__VA_ARGS__)"
@@ -135,7 +135,7 @@ if [ "$PLATFORM" != win32 ]; then
 
 
 #    ngx_feature="inline"
-#    ngx_feature_name="DUMMY"
+#    ngx_feature_name=
 #    ngx_feature_run=no
 #    ngx_feature_incs="int inline f(void) { return 1 }"
 #    ngx_feature_libs=
--- a/auto/cc/icc
+++ b/auto/cc/icc
@@ -18,7 +18,7 @@ CFLAGS="$CFLAGS -Ob2"
 IPO="-ipo -ipo_obj"
 CFLAGS="$CFLAGS $IPO"
 CORE_LINK="$CORE_LINK $IPO"
-CORE_LINK="$CORE_LINK -opt_report_file=$OBJS/opt_report_file"
+CORE_LINK="$CORE_LINK -opt_report_file=$NGX_OBJS/opt_report_file"
 
 case $CPU in
     pentium)
--- a/auto/cc/msvc
+++ b/auto/cc/msvc
@@ -77,15 +77,15 @@ CORE_LINK="$CORE_LINK -debug -debugtype:
 
 # precompiled headers
 if [ $NGX_CC_NAME != msvc7 ]; then
-    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"
+    CORE_DEPS="$CORE_DEPS $NGX_OBJS/ngx_config.pch"
+    NGX_PCH="$NGX_OBJS/ngx_config.pch"
+    NGX_BUILD_PCH="-Ycngx_config.h -Fp$NGX_OBJS/ngx_config.pch"
+    NGX_USE_PCH="-Yungx_config.h -Fp$NGX_OBJS/ngx_config.pch"
 fi
 
 
 # the resource file
-NGX_RES="$OBJS/nginx.res"
+NGX_RES="$NGX_OBJS/nginx.res"
 NGX_RCC="rc -fo$NGX_RES \$(CORE_INCS) $NGX_WIN32_RC"
 CORE_LINK="$NGX_RES $CORE_LINK"
 
--- a/auto/cc/owc
+++ b/auto/cc/owc
@@ -63,10 +63,10 @@ CFLAGS="$CFLAGS -zq"
 
 
 # the 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"
+CORE_DEPS="$CORE_DEPS $NGX_OBJS/ngx_config.pch"
+NGX_PCH="$NGX_OBJS/ngx_config.pch"
+NGX_BUILD_PCH="-fhq=$NGX_OBJS/ngx_config.pch"
+NGX_USE_PCH="-fh=$NGX_OBJS/ngx_config.pch"
 
 
 LINK="\$(CC)"
@@ -76,7 +76,8 @@ CORE_LINK="$CORE_LINK -l=nt_win"
 
 
 # the resource file
-NGX_RCC="wrc \$(CORE_INCS) -fo=$OBJS/nginx.res $NGX_WIN32_RC $OBJS/nginx.exe"
+NGX_RCC="wrc \$(CORE_INCS) -fo=$NGX_OBJS/nginx.res "
+NGX_RCC="$NGX_RCC $NGX_WIN32_RC $NGX_OBJS/nginx.exe"
 
 
 ngx_include_opt="-i="
--- a/auto/configure
+++ b/auto/configure
@@ -7,26 +7,26 @@
 . auto/init
 . auto/sources
 
-test -d $OBJS || mkdir $OBJS
+test -d $NGX_OBJS || mkdir $NGX_OBJS
 
 echo > $NGX_AUTO_HEADERS_H
 echo > $NGX_AUTO_CONFIG_H
 echo > $NGX_AUTOCONF_ERR
 
 
-if [ $DEBUG = YES ]; then
+if [ $NGX_DEBUG = YES ]; then
     have=NGX_DEBUG . auto/have
 fi
 
 
-if [ "$PLATFORM" != win32 ]; then
+if [ "$NGX_PLATFORM" != win32 ]; then
     . auto/headers
 fi
 
 . auto/cc/conf
 . auto/os/conf
 
-if [ "$PLATFORM" != win32 ]; then
+if [ "$NGX_PLATFORM" != win32 ]; then
     . auto/threads
 fi
 
@@ -37,21 +37,21 @@ fi
 . auto/lib/make
 . auto/install
 
-if [ "$PLATFORM" != win32 ]; then
+if [ "$NGX_PLATFORM" != win32 ]; then
     . auto/unix
 fi
 
 # STUB
 . auto/stubs
 
-have=NGX_PREFIX value="\"$PREFIX/\"" . auto/define
-have=NGX_SBIN_PATH value="\"$SBIN_PATH\"" . auto/define
-have=NGX_CONF_PATH value="\"$CONF_PATH\"" . auto/define
-have=NGX_PID_PATH value="\"$PID_PATH\"" . auto/define
-if [ ".$ERROR_LOG_PATH" != "." ]; then
-    have=NGX_ERROR_LOG_PATH value="\"$ERROR_LOG_PATH\"" . auto/define
+have=NGX_PREFIX value="\"$NGX_PREFIX/\"" . auto/define
+have=NGX_SBIN_PATH value="\"$NGX_SBIN_PATH\"" . auto/define
+have=NGX_CONF_PATH value="\"$NGX_CONF_PATH\"" . auto/define
+have=NGX_PID_PATH value="\"$NGX_PID_PATH\"" . auto/define
+if test -n "$NGX_ERROR_LOG_PATH"; then
+    have=NGX_ERROR_LOG_PATH value="\"$NGX_ERROR_LOG_PATH\"" . auto/define
 fi
-have=NGX_HTTP_LOG_PATH value="\"$HTTP_LOG_PATH\"" . auto/define
+have=NGX_HTTP_LOG_PATH value="\"$NGX_HTTP_LOG_PATH\"" . auto/define
 
 have=NGX_USER value="\"$NGX_USER\"" . auto/define
 have=NGX_GROUP value="\"$NGX_GROUP\"" . auto/define
--- a/auto/endianess
+++ b/auto/endianess
@@ -25,7 +25,7 @@ eval "${CC} -o $NGX_AUTOTEST $NGX_AUTOTE
 if [ -x $NGX_AUTOTEST ]; then
     if $NGX_AUTOTEST 2>&1 > /dev/null; then
         echo " little endianess"
-        have=HAVE_LITTLE_ENDIAN . auto/have
+        have=NGX_HAVE_LITTLE_ENDIAN . auto/have
     else
         echo " big endianess"
     fi
--- a/auto/feature
+++ b/auto/feature
@@ -14,9 +14,7 @@ END
 ngx_found=no
 
 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]'`
+    ngx_have_feature=`echo $ngx_feature_name | tr '[a-z]' '[A-Z]'`
 fi
 
 cat << END > $NGX_AUTOTEST.c
@@ -51,11 +49,6 @@ if [ -x $NGX_AUTOTEST ]; 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
@@ -68,11 +61,6 @@ if [ -x $NGX_AUTOTEST ]; 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
deleted file mode 100644
--- a/auto/func
+++ /dev/null
@@ -1,43 +0,0 @@
-
-# Copyright (C) Igor Sysoev
-
-
-echo $ngx_n "checking for $ngx_func ..." $ngx_c
-echo >> $NGX_ERR
-echo "checking for $ngx_func" >> $NGX_ERR
-
-ngx_found=no
-
-func=`echo $ngx_func | sed -e 's/()$//' | tr '[a-z]' '[A-Z]'`
-
-cat << END > $NGX_AUTOTEST.c
-
-#include <sys/types.h>
-$NGX_UNISTD_H
-$ngx_func_inc
-
-int main() {
-    $ngx_func_test;
-    return 0;
-}
-
-END
-
-test="$CC_WARN $CC_TEST_FLAGS -o $NGX_AUTOTEST $NGX_AUTOTEST.c $ngx_func_libs"
-eval "$test >> $NGX_ERR 2>&1"
-
-if [ -x $NGX_AUTOTEST ]; then
-    echo " found"
-    have=HAVE_$func . auto/have
-    ngx_found=yes
-
-else
-    echo " not found"
-    echo "---------" >> $NGX_ERR
-    cat $NGX_AUTOTEST.c >> $NGX_ERR
-    echo "---------" >> $NGX_ERR
-    echo $test >> $NGX_ERR
-    echo "---------" >> $NGX_ERR
-fi
-
-rm $NGX_AUTOTEST*
--- a/auto/init
+++ b/auto/init
@@ -12,9 +12,8 @@ NGX_AUTOTEST=$NGX_OBJS/autotest
 NGX_AUTOCONF_ERR=$NGX_OBJS/autoconf.err
 
 # STUBs
-OBJS=$NGX_OBJS
-NGX_ERR=$OBJS/autoconf.err
-MAKEFILE=$OBJS/Makefile
+NGX_ERR=$NGX_OBJS/autoconf.err
+MAKEFILE=$NGX_OBJS/Makefile
 
 
 NGX_PCH=
@@ -54,9 +53,9 @@ clean:
 	rm -rf Makefile $NGX_OBJS
 
 upgrade:
-	$SBIN_PATH -t
-	kill -USR2 \`cat $PID_PATH\`
+	$NGX_SBIN_PATH -t
+	kill -USR2 \`cat $NGX_PID_PATH\`
 	sleep 1
-	test -f $PID_PATH.newbin
-	kill -WINCH \`cat $PID_PATH\`
+	test -f $NGX_PID_PATH.newbin
+	kill -WINCH \`cat $NGX_PID_PATH\`
 END
--- a/auto/install
+++ b/auto/install
@@ -2,40 +2,40 @@
 # Copyright (C) Igor Sysoev
 
 
-cat << END                                                        >> $MAKEFILE
+cat << END                                                    >> $NGX_MAKEFILE
 
 install:
-	test -d $PREFIX || mkdir -p $PREFIX
+	test -d $NGX_PREFIX || mkdir -p $NGX_PREFIX
 
-	test -d `dirname $SBIN_PATH` || mkdir -p `dirname $SBIN_PATH`
-	test ! -f $SBIN_PATH || mv $SBIN_PATH $SBIN_PATH.old
-	cp $OBJS/nginx $SBIN_PATH
+	test -d `dirname $NGX_SBIN_PATH` || mkdir -p `dirname $NGX_SBIN_PATH`
+	test ! -f $NGX_SBIN_PATH || mv $NGX_SBIN_PATH $NGX_SBIN_PATH.old
+	cp $NGX_OBJS/nginx $NGX_SBIN_PATH
 
-	test -d `dirname $CONF_PATH` || mkdir -p `dirname $CONF_PATH`
+	test -d `dirname $NGX_CONF_PATH` || mkdir -p `dirname $NGX_CONF_PATH`
 
-	cp conf/koi-win `dirname $CONF_PATH`
+	cp conf/koi-win `dirname $NGX_CONF_PATH`
 
-	test -f `dirname $CONF_PATH`/mime.types || \
-		cp conf/mime.types `dirname $CONF_PATH`/mime.types
-	cp conf/mime.types `dirname $CONF_PATH`/mime.types.default
+	test -f `dirname $NGX_CONF_PATH`/mime.types || \
+		cp conf/mime.types `dirname $NGX_CONF_PATH`/mime.types
+	cp conf/mime.types `dirname $NGX_CONF_PATH`/mime.types.default
 
-	test -f $CONF_PATH || cp conf/nginx.conf $CONF_PATH
-	cp conf/nginx.conf `dirname $CONF_PATH`/nginx.conf.default
+	test -f $NGX_CONF_PATH || cp conf/nginx.conf $NGX_CONF_PATH
+	cp conf/nginx.conf `dirname $NGX_CONF_PATH`/nginx.conf.default
 
-	test -d `dirname $PID_PATH` || mkdir -p `dirname $PID_PATH`
-
-	test -d `dirname $HTTP_LOG_PATH` || mkdir -p `dirname $HTTP_LOG_PATH`
+	test -d `dirname $NGX_PID_PATH` || mkdir -p `dirname $NGX_PID_PATH`
 
-	test -d $PREFIX/html || cp -r html $PREFIX
+	test -d `dirname $NGX_HTTP_LOG_PATH` || \
+		mkdir -p `dirname $NGX_HTTP_LOG_PATH`
 
-	#test -d $PREFIX/temp || mkdir -p $PREFIX/temp
+	test -d $NGX_PREFIX/html || cp -r html $NGX_PREFIX
 END
 
 
-if [ ".$ERROR_LOG_PATH" != "." ]; then
-    cat << END                                                    >> $MAKEFILE
+if test -n "$NGX_ERROR_LOG_PATH"; then
+    cat << END                                                >> $NGX_MAKEFILE
 
-	test -d `dirname $ERROR_LOG_PATH` || mkdir -p `dirname $ERROR_LOG_PATH`
+	test -d `dirname $NGX_ERROR_LOG_PATH` || \
+		mkdir -p `dirname $NGX_ERROR_LOG_PATH`
 END
 
 fi
--- a/auto/lib/md5/conf
+++ b/auto/lib/md5/conf
@@ -7,7 +7,7 @@ if [ $MD5 != NONE ]; then
     if grep MD5_Init $MD5/md5.h >/dev/null; then
         # OpenSSL md5
         OPENSSL_MD5=YES
-        have=HAVE_OPENSSL_MD5 . auto/have
+        have=NGX_HAVE_OPENSSL_MD5 . auto/have
     else
         # rsaref md5
         OPENSSL_MD5=NO
@@ -43,13 +43,13 @@ if [ $MD5 != NONE ]; then
 
 else
 
-    if [ $PLATFORM != win32 ]; then
+    if [ $NGX_PLATFORM != win32 ]; then
         MD5=NO
 
         # Solaris 8/9
 
         ngx_feature="rsaref md5 library"
-        ngx_feature_name="rsaref_md5"
+        ngx_feature_name=
         ngx_feature_run=no
         ngx_feature_incs="#include <md5.h>"
         ngx_feature_libs="-lmd5"
@@ -66,7 +66,7 @@ else
             # FreeBSD
 
             ngx_feature="rsaref md library"
-            ngx_feature_name="rsaref_md5"
+            ngx_feature_name=
             ngx_feature_run=no
             ngx_feature_incs="#include <md5.h>"
             ngx_feature_libs="-lmd"
@@ -87,7 +87,7 @@ else
                # OpenSSL crypto library
 
                ngx_feature="OpenSSL md5 crypto library"
-               ngx_feature_name="OpenSSL_md5"
+               ngx_feature_name="NGX_OPENSSL_MD5"
                ngx_feature_run=no
                ngx_feature_incs="#include <openssl/md5.h>"
                ngx_feature_libs="-lcrypto"
@@ -98,7 +98,7 @@ else
 
 
         if [ $ngx_found = yes ]; then
-            have=HAVE_OPENSSL_MD5_H . auto/have
+            have=NGX_HAVE_OPENSSL_MD5_H . auto/have
             CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
             MD5=YES
             MD5_LIB=crypto
--- a/auto/lib/md5/make
+++ b/auto/lib/md5/make
@@ -25,7 +25,7 @@ esac
 done=NO
 
 
-case $PLATFORM in
+case $NGX_PLATFORM in
 
     win32)
         cp auto/lib/md5/$ngx_makefile $MD5
--- a/auto/lib/openssl/conf
+++ b/auto/lib/openssl/conf
@@ -18,11 +18,11 @@ if [ $OPENSSL != NONE ]; then
 
 else
 
-    if [ $PLATFORM != win32 ]; then
+    if [ $NGX_PLATFORM != win32 ]; then
         OPENSSL=NO
 
         ngx_feature="OpenSSL library"
-        ngx_feature_name="OpenSSL"
+        ngx_feature_name="NGX_OPENSSL"
         ngx_feature_run=no
         ngx_feature_incs="#include <openssl/ssl.h>"
         ngx_feature_libs="-lssl -lcrypto"
@@ -30,7 +30,6 @@ else
         . 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_feature_libs"
--- a/auto/lib/openssl/make
+++ b/auto/lib/openssl/make
@@ -2,7 +2,7 @@
 # Copyright (C) Igor Sysoev
 
 
-case $PLATFORM in
+case $NGX_PLATFORM in
     *)
         echo "$OPENSSL/libssl.a:"                                 >> $MAKEFILE
         echo "	cd $OPENSSL \\"                                   >> $MAKEFILE
--- a/auto/lib/pcre/conf
+++ b/auto/lib/pcre/conf
@@ -42,14 +42,14 @@ if [ $PCRE != NONE ]; then
 
 else
 
-    if [ $PLATFORM != win32 ]; then
+    if [ $NGX_PLATFORM != win32 ]; then
         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_name="NGX_PCRE"
         ngx_feature_run=no
         ngx_feature_incs="#include <pcre.h>"
         ngx_feature_libs="-lpcre"
--- a/auto/lib/pcre/make
+++ b/auto/lib/pcre/make
@@ -22,7 +22,7 @@ case "$NGX_CC_NAME" in
 esac
 
 
-case $PLATFORM in
+case $NGX_PLATFORM in
 
     win32)
         cp auto/lib/pcre/patch.pcre.in $PCRE
--- a/auto/lib/zlib/conf
+++ b/auto/lib/zlib/conf
@@ -37,13 +37,13 @@ if [ $ZLIB != NONE ]; then
 
 else
 
-    if [ $PLATFORM != win32 ]; then
+    if [ $NGX_PLATFORM != win32 ]; then
         ZLIB=NO
 
         # FreeBSD, Solaris, Linux
 
         ngx_feature="zlib library"
-        ngx_feature_name="zlib"
+        ngx_feature_name=
         ngx_feature_run=no
         ngx_feature_incs="#include <zlib.h>"
         ngx_feature_libs="-lz"
--- a/auto/lib/zlib/make
+++ b/auto/lib/zlib/make
@@ -26,7 +26,7 @@ esac
 done=NO
 
 
-case $PLATFORM in
+case $NGX_PLATFORM in
 
     win32)
         cp auto/lib/zlib/$ngx_makefile $ZLIB
--- a/auto/make
+++ b/auto/make
@@ -2,10 +2,11 @@
 # Copyright (C) Igor Sysoev
 
 
-mkdir -p $OBJS/src/core $OBJS/src/event $OBJS/src/event/modules \
-         $OBJS/src/os/unix $OBJS/src/os/win32 \
-         $OBJS/src/http $OBJS/src/http/modules $OBJS/src/http/modules/proxy \
-         $OBJS/src/imap
+mkdir -p $NGX_OBJS/src/core $NGX_OBJS/src/event $NGX_OBJS/src/event/modules \
+         $NGX_OBJS/src/os/unix $NGX_OBJS/src/os/win32 \
+         $NGX_OBJS/src/http $NGX_OBJS/src/http/modules \
+	 $NGX_OBJS/src/http/modules/proxy \
+         $NGX_OBJS/src/imap
 
 
 ngx_objs_dir=$NGX_OBJS$ngx_regex_dirsep
@@ -33,7 +34,7 @@ fi
 
 # ALL_INCS, required by OpenWatcom C precompiled headers
 
-ngx_incs=`echo $CORE_INCS $OBJS $HTTP_INCS $IMAP_INCS\
+ngx_incs=`echo $CORE_INCS $NGX_OBJS $HTTP_INCS $IMAP_INCS\
     | sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
           -e "s/\//$ngx_regex_dirsep/g"`
 
@@ -53,7 +54,7 @@ ngx_deps=`echo $CORE_DEPS $NGX_AUTO_CONF
     | sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont\1/g" \
           -e "s/\//$ngx_regex_dirsep/g"`
 
-ngx_incs=`echo $CORE_INCS $OBJS \
+ngx_incs=`echo $CORE_INCS $NGX_OBJS \
     | sed -e "s/  *\([^ ][^ ]*\)/$ngx_regex_cont$ngx_include_opt\1/g" \
           -e "s/\//$ngx_regex_dirsep/g"`
 
@@ -287,13 +288,13 @@ fi
 # the precompiled headers
 
 if test -n "$NGX_PCH"; then
-    echo "#include <ngx_config.h>" > $OBJS/ngx_pch.c
+    echo "#include <ngx_config.h>" > $NGX_OBJS/ngx_pch.c
 
-    ngx_pch="src/core/ngx_config.h $OS_CONFIG $OBJS/ngx_auto_config.h"
+    ngx_pch="src/core/ngx_config.h $OS_CONFIG $NGX_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="$ngx_src $ngx_objout$NGX_OBJS/ngx_pch.obj $NGX_OBJS/ngx_pch.c"
     ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
 
     cat << END                                                >> $NGX_MAKEFILE
--- a/auto/modules
+++ b/auto/modules
@@ -7,7 +7,7 @@ if [ $EVENT_SELECT = NO -a $EVENT_FOUND 
 fi
 
 if [ $EVENT_SELECT = YES ]; then
-    have=HAVE_SELECT . auto/have
+    have=NGX_HAVE_SELECT . auto/have
     CORE_SRCS="$CORE_SRCS $SELECT_SRCS"
     EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE"
 fi
@@ -18,29 +18,29 @@ if [ $EVENT_POLL = NO -a $EVENT_FOUND = 
 fi
 
 if [ $EVENT_POLL = YES ]; then
-    have=HAVE_POLL . auto/have
+    have=NGX_HAVE_POLL . auto/have
     CORE_SRCS="$CORE_SRCS $POLL_SRCS"
     EVENT_MODULES="$EVENT_MODULES $POLL_MODULE"
 fi
 
 
-if [ $TEST_BUILD_DEVPOLL = YES ]; then
-    have=HAVE_DEVPOLL . auto/have
-    have=TEST_BUILD_DEVPOLL . auto/have
+if [ $NGX_TEST_BUILD_DEVPOLL = YES ]; then
+    have=NGX_HAVE_DEVPOLL . auto/have
+    have=NGX_TEST_BUILD_DEVPOLL . auto/have
     EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE"
     CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS"
 fi
 
-if [ $TEST_BUILD_EPOLL = YES ]; then
-    have=HAVE_EPOLL . auto/have
-    have=TEST_BUILD_EPOLL . auto/have
+if [ $NGX_TEST_BUILD_EPOLL = YES ]; then
+    have=NGX_HAVE_EPOLL . auto/have
+    have=NGX_TEST_BUILD_EPOLL . auto/have
     EVENT_MODULES="$EVENT_MODULES $EPOLL_MODULE"
     CORE_SRCS="$CORE_SRCS $EPOLL_SRCS"
 fi
 
-if [ $TEST_BUILD_RTSIG = YES ]; then
-    have=HAVE_RTSIG . auto/have
-    have=TEST_BUILD_RTSIG . auto/have
+if [ $NGX_TEST_BUILD_RTSIG = YES ]; then
+    have=NGX_HAVE_RTSIG . auto/have
+    have=NGX_TEST_BUILD_RTSIG . auto/have
     EVENT_MODULES="$EVENT_MODULES $RTSIG_MODULE"
     CORE_SRCS="$CORE_SRCS $RTSIG_SRCS"
 fi
@@ -135,8 +135,11 @@ if [ $HTTP_PROXY = YES ]; then
     HTTP_SRCS="$HTTP_SRCS $HTTP_PROXY_SRCS"
 fi
 
-if [ -r $OBJS/auto ]; then
-    . $OBJS/auto
+# STUB
+#HTTP_SRCS="$HTTP_SRCS $HTPP_FILE_CACHE_SRCS"
+
+if [ -r $NGX_OBJS/auto ]; then
+    . $NGX_OBJS/auto
 fi
 
 modules="$CORE_MODULES $EVENT_MODULES"
--- a/auto/options
+++ b/auto/options
@@ -4,29 +4,29 @@
 
 help=no
 
-PREFIX=
-SBIN_PATH=
-CONF_PATH=
-ERROR_LOG_PATH=
-PID_PATH=
+NGX_PREFIX=
+NGX_SBIN_PATH=
+NGX_CONF_PATH=
+NGX_ERROR_LOG_PATH=
+NGX_PID_PATH=
 NGX_USER=
 NGX_GROUP=
-HTTP_LOG_PATH=
+NGX_HTTP_LOG_PATH=
 
 CC=${CC:-gcc}
 CPP=
 NGX_OBJS=objs
 
-DEBUG=NO
+NGX_DEBUG=NO
 NGX_CC_OPT=
 NGX_LD_OPT=
 CPU=NO
 
-TEST_BUILD_DEVPOLL=NO
-TEST_BUILD_EPOLL=NO
-TEST_BUILD_RTSIG=NO
+NGX_TEST_BUILD_DEVPOLL=NO
+NGX_TEST_BUILD_EPOLL=NO
+NGX_TEST_BUILD_RTSIG=NO
 
-PLATFORM=
+NGX_PLATFORM=
 NGX_WINE=
 
 EVENT_FOUND=NO
@@ -52,7 +52,7 @@ HTTP_PROXY=YES
 
 IMAP=NO
 
-MODULES=
+NGX_MODULES=
 
 USE_PCRE=NO
 PCRE=NONE
@@ -82,15 +82,15 @@ do
     case "$option" in
         --help)                          help=yes                   ;;
 
-        --prefix=*)                      PREFIX="$value"            ;;
-        --sbin-path=*)                   SBIN_PATH="$value"         ;;
-        --conf-path=*)                   CONF_PATH="$value"         ;;
-        --error-log-path=*)              ERROR_LOG_PATH="$value"    ;;
-        --pid-path=*)                    PID_PATH="$value"          ;;
+        --prefix=*)                      NGX_PREFIX="$value"        ;;
+        --sbin-path=*)                   NGX_SBIN_PATH="$value"     ;;
+        --conf-path=*)                   NGX_CONF_PATH="$value"     ;;
+        --error-log-path=*)              NGX_ERROR_LOG_PATH="$value";;
+        --pid-path=*)                    NGX_PID_PATH="$value"      ;;
         --user=*)                        NGX_USER="$value"          ;;
         --group=*)                       NGX_GROUP="$value"         ;;
 
-        --crossbuild=*)                  PLATFORM="$value"          ;;
+        --crossbuild=*)                  NGX_PLATFORM="$value"      ;;
 
         --builddir=*)                    NGX_OBJS="$value"          ;;
 
@@ -105,7 +105,7 @@ do
         --with-threads)                  USE_THREADS="pthreads"     ;;
 
         --without-http)                  HTTP=NO                    ;;
-        --http-log-path=*)               HTTP_LOG_PATH="$value"     ;;
+        --http-log-path=*)               NGX_HTTP_LOG_PATH="$value" ;;
 
         --with-http_ssl_module)          HTTP_SSL=YES               ;;
         --without-http_charset_module)   HTTP_CHARSET=NO            ;;
@@ -127,7 +127,7 @@ do
         --with-cc-opt=*)                 NGX_CC_OPT="$value"        ;;
         --with-ld-opt=*)                 NGX_LD_OPT="$value"        ;;
         --with-cpu-opt=*)                CPU="$value"               ;;
-        --with-debug)                    DEBUG=YES                  ;;
+        --with-debug)                    NGX_DEBUG=YES              ;;
 
         --without-pcre)                  USE_PCRE=DISABLED          ;;
         --with-pcre=*)                   PCRE="$value"              ;;
@@ -143,9 +143,9 @@ do
         --with-zlib-opt=*)               ZLIB_OPT="$value"          ;;
         --with-zlib-asm=*)               ZLIB_ASM="$value"          ;;
 
-        --test-build-devpoll)            TEST_BUILD_DEVPOLL=YES     ;;
-        --test-build-epoll)              TEST_BUILD_EPOLL=YES       ;;
-        --test-build-rtsig)              TEST_BUILD_RTSIG=YES       ;;
+        --test-build-devpoll)            NGX_TEST_BUILD_DEVPOLL=YES ;;
+        --test-build-epoll)              NGX_TEST_BUILD_EPOLL=YES   ;;
+        --test-build-rtsig)              NGX_TEST_BUILD_RTSIG=YES   ;;
 
         *)
             echo "$0: error: invalid option \"$option\""
@@ -202,13 +202,13 @@ if [ $HTTP = NO ]; then
 fi
 
 
-if [ ".$PLATFORM" = ".win32" ]; then
+if [ ".$NGX_PLATFORM" = ".win32" ]; then
     NGX_WINE=$WINE
 fi
 
 
-if test -z "$PREFIX"; then
-    PREFIX=/usr/local/nginx
+if test -z "$NGX_PREFIX"; then
+    NGX_PREFIX=/usr/local/nginx
 fi
 
 
@@ -217,75 +217,75 @@ if test -z "$NGX_GROUP"; then
 fi
 
 
-case ".$SBIN_PATH" in
+case ".$NGX_SBIN_PATH" in
     ./*)
     ;;
 
     .)
-        SBIN_PATH=$PREFIX/sbin/nginx
+        NGX_SBIN_PATH=$NGX_PREFIX/sbin/nginx
     ;;
 
     *)
-        SBIN_PATH=$PREFIX/$SBIN_PATH
+        NGX_SBIN_PATH=$NGX_PREFIX/$NGX_SBIN_PATH
     ;;
 esac
 
 
-case ".$CONF_PATH" in
+case ".$NGX_CONF_PATH" in
     ./*)
     ;;
 
     .)
-        CONF_PATH=$PREFIX/conf/nginx.conf
+        NGX_CONF_PATH=$NGX_PREFIX/conf/nginx.conf
     ;;
 
     *)
-        CONF_PATH=$PREFIX/$CONF_PATH
+        NGX_CONF_PATH=$NGX_PREFIX/$NGX_CONF_PATH
     ;;
 esac
 
 
-case ".$PID_PATH" in
+case ".$NGX_PID_PATH" in
     ./*)
     ;;
 
     .)
-        PID_PATH=$PREFIX/logs/nginx.pid
+        NGX_PID_PATH=$NGX_PREFIX/logs/nginx.pid
     ;;
 
     *)
-        PID_PATH=$PREFIX/$PID_PATH
+        NGX_PID_PATH=$NGX_PREFIX/$NGX_PID_PATH
     ;;
 esac
 
 
-case ".$ERROR_LOG_PATH" in
+case ".$NGX_ERROR_LOG_PATH" in
     ./*)
     ;;
 
     .)
-        ERROR_LOG_PATH=$PREFIX/logs/error.log
+        NGX_ERROR_LOG_PATH=$NGX_PREFIX/logs/error.log
     ;;
 
     .stderr)
-        ERROR_LOG_PATH=
+        NGX_ERROR_LOG_PATH=
     ;;
 
     *)
-        ERROR_LOG_PATH=$PREFIX/$ERROR_LOG_PATH
+        NGX_ERROR_LOG_PATH=$NGX_PREFIX/$NGX_ERROR_LOG_PATH
     ;;
 esac
 
 
-case ".$HTTP_LOG_PATH" in
+case ".$NGX_HTTP_LOG_PATH" in
     ./*)
     ;;
 
     .)
-        HTTP_LOG_PATH=$PREFIX/logs/access.log
+        NGX_HTTP_LOG_PATH=$NGX_PREFIX/logs/access.log
     ;;
 
     *)
-        HTTP_LOG_PATH=$PREFIX/$HTTP_LOG_PATH
+        NGX_HTTP_LOG_PATH=$NGX_PREFIX/$NGX_HTTP_LOG_PATH
     ;;
 esac
--- a/auto/os/conf
+++ b/auto/os/conf
@@ -2,7 +2,7 @@
 # Copyright (C) Igor Sysoev
 
 
-if [ ".$PLATFORM" = "." ]; then
+if test -z "$NGX_PLATFORM"; then
     echo "checking for OS"
 
     SYSTEM=`uname -s 2>/dev/null`
@@ -11,12 +11,12 @@ if [ ".$PLATFORM" = "." ]; then
 
     echo " + $SYSTEM $RELEASE $MACHINE"
 
-    PLATFORM="$SYSTEM:$RELEASE:$MACHINE";
+    NGX_PLATFORM="$SYSTEM:$RELEASE:$MACHINE";
 else
-    echo "building for $PLATFORM"
+    echo "building for $NGX_PLATFORM"
 fi
 
-case $PLATFORM in
+case $NGX_PLATFORM in
 
     FreeBSD:* | DragonFly:*)
         . auto/os/freebsd
@@ -43,7 +43,7 @@ case $PLATFORM in
 esac
 
 
-if [ $PLATFORM != win32 ]; then
+if [ $NGX_PLATFORM != win32 ]; then
 
     if test -z "$NGX_USER"; then
         NGX_USER=nobody
@@ -52,7 +52,7 @@ if [ $PLATFORM != win32 ]; then
 
 
     ngx_feature="/dev/poll"
-    ngx_feature_name="devpoll"
+    ngx_feature_name="NGX_HAVE_DEVPOLL"
     ngx_feature_run=no
     ngx_feature_incs="#include <sys/devpoll.h>"
     ngx_feature_libs=
@@ -65,7 +65,6 @@ if [ $PLATFORM != win32 ]; then
     . 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
@@ -74,7 +73,7 @@ if [ $PLATFORM != win32 ]; then
 
     if test -z "$NGX_KQUEUE_CHECKED"; then
         ngx_feature="kqueue"
-        ngx_feature_name="kqueue"
+        ngx_feature_name="NGX_HAVE_KQUEUE"
         ngx_feature_run=no
         ngx_feature_incs="#include <sys/event.h>"
         ngx_feature_libs=
@@ -83,14 +82,13 @@ if [ $PLATFORM != win32 ]; then
 
         if [ $ngx_found = yes ]; then
 
-            have=HAVE_KQUEUE . auto/have
-            have=HAVE_CLEAR_EVENT . auto/have
+            have=NGX_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_name="NGX_HAVE_LOWAT_EVENT"
             ngx_feature_run=no
             ngx_feature_incs="#include <sys/event.h>"
             ngx_feature_libs=
--- a/auto/os/freebsd
+++ b/auto/os/freebsd
@@ -45,7 +45,7 @@ fi
 if [ $osreldate -gt 300007 ]; then
     echo " + using sendfile()"
 
-    have=HAVE_SENDFILE . auto/have
+    have=NGX_HAVE_SENDFILE . auto/have
     CORE_SRCS="$CORE_SRCS $FREEBSD_SENDFILE_SRCS"
 fi
 
@@ -57,8 +57,8 @@ if [ \( $osreldate -lt 500000 -a $osreld
 then
     echo " + using kqueue"
 
-    have=HAVE_KQUEUE . auto/have
-    have=HAVE_CLEAR_EVENT . auto/have
+    have=NGX_HAVE_KQUEUE . auto/have
+    have=NGX_HAVE_CLEAR_EVENT . auto/have
     EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
     CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
     EVENT_FOUND=YES
@@ -73,7 +73,7 @@ if [ \( $version -lt 500000 -a $version 
      -o $version -ge 500018 ]
 then
     echo " + using kqueue's NOTE_LOWAT"
-    have=HAVE_LOWAT_EVENT . auto/have
+    have=NGX_HAVE_LOWAT_EVENT . auto/have
 fi
 
 
@@ -85,7 +85,7 @@ if [ $USE_THREADS = "rfork" ]; then
 #
 #    if [ $version -gt 460101 ]; then
 #        echo " + kqueue's EVFILT_SIGNAL is safe"
-#        have=HAVE_SAFE_EVFILT_SIGNAL . auto/have
+#        have=NGX_HAVE_SAFE_EVFILT_SIGNAL . auto/have
 #    else
 #        echo "$0: error: the kqueue's EVFILT_SIGNAL is unsafe on this"
 #        echo "FreeBSD version, so --with-threads=rfork could not be used"
@@ -100,7 +100,7 @@ if [ $EVENT_AIO = YES ]; then
     if [ \( $version -lt 500000 -a $version -ge 430000 \) \
          -o $version -ge 500014 ]
     then
-        have=HAVE_AIO . auto/have
+        have=NGX_HAVE_AIO . auto/have
         EVENT_MODULES="$EVENT_MODULES $AIO_MODULE"
         CORE_SRCS="$CORE_SRCS $AIO_SRCS"
     else
--- a/auto/os/linux
+++ b/auto/os/linux
@@ -37,7 +37,8 @@ version=`grep "#define LINUX_VERSION_COD
 
 if [ $version -ge 131609 -o $EVENT_RTSIG = YES ]; then
     echo " + using rt signals"
-    have=HAVE_RTSIG . auto/have
+    have=NGX_HAVE_RTSIG . auto/have
+    have=NGX_HAVE_POLL . auto/have
     EVENT_MODULES="$EVENT_MODULES $RTSIG_MODULE"
     CORE_SRCS="$CORE_SRCS $RTSIG_SRCS"
     EVENT_FOUND=YES
@@ -47,7 +48,7 @@ fi
 # epoll, EPOLLET version
 
 ngx_feature="epoll"
-ngx_feature_name="epoll"
+ngx_feature_name="NGX_HAVE_EPOLL"
 ngx_feature_run=no
 ngx_feature_incs="#include <sys/epoll.h>"
 ngx_feature_libs=
@@ -60,8 +61,7 @@ ngx_feature_test="int efd = 0, fd = 1, n
 . auto/feature
 
 if [ $ngx_found = yes ]; then
-    have=HAVE_EPOLL . auto/have
-    have=HAVE_CLEAR_EVENT . auto/have
+    have=NGX_HAVE_CLEAR_EVENT . auto/have
     CORE_SRCS="$CORE_SRCS $EPOLL_SRCS"
     EVENT_MODULES="$EVENT_MODULES $EPOLL_MODULE"
     EVENT_FOUND=YES
@@ -72,7 +72,7 @@ fi
 
 CC_AUX_FLAGS="-D_GNU_SOURCE"
 ngx_feature="sendfile()"
-ngx_feature_name="sendfile"
+ngx_feature_name="NGX_HAVE_SENDFILE"
 ngx_feature_run=no
 ngx_feature_incs="#include <sys/sendfile.h>"
 ngx_feature_libs=
@@ -90,7 +90,7 @@ fi
 
 CC_AUX_FLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
 ngx_feature="sendfile64()"
-ngx_feature_name="HAVE_SENDFILE64"
+ngx_feature_name="NGX_HAVE_SENDFILE64"
 ngx_feature_run=no
 ngx_feature_incs="#include <sys/sendfile.h>"
 ngx_feature_libs=
@@ -105,7 +105,7 @@ ngx_include="sys/prctl.h"; . auto/includ
 # prctl(PR_SET_DUMPABLE)
 
 ngx_feature="prctl(PR_SET_DUMPABLE)"
-ngx_feature_name="HAVE_PR_SET_DUMPABLE"
+ngx_feature_name="NGX_HAVE_PR_SET_DUMPABLE"
 ngx_feature_run=yes
 ngx_feature_incs="#include <sys/prctl.h>"
 ngx_feature_libs=
--- a/auto/os/solaris
+++ b/auto/os/solaris
@@ -23,7 +23,7 @@ ngx_spacer=
 CC_AUX_FLAGS="-D_FILE_OFFSET_BITS=64 -lrt"
 
 
-case $PLATFORM in
+case $NGX_PLATFORM in
 
     *:sun4u)
         # "-mcpu=v9" enables the "casa" assembler instruction
@@ -43,7 +43,7 @@ fi
 
 
 ngx_feature="sendfilev()"
-ngx_feature_name="sendfile"
+ngx_feature_name="NGX_HAVE_SENDFILE"
 ngx_feature_run=no
 ngx_feature_incs="#include <sys/sendfile.h>"
 ngx_feature_libs="-lsendfile"
@@ -54,7 +54,6 @@ ngx_feature_test="int fd = 1; sendfileve
 
 
 if [ $ngx_found = yes ]; then
-    have=HAVE_SENDFILE . auto/have
     CORE_SRCS="$CORE_SRCS $SOLARIS_SENDFILEV_SRCS"
     CORE_LIBS="$CORE_LIBS -lsendfile"
 fi
--- a/auto/os/win32
+++ b/auto/os/win32
@@ -26,5 +26,5 @@ if [ $EVENT_SELECT = NO ]; then
     EVENT_MODULES="$EVENT_MODULES $SELECT_MODULE"
 fi
 
-have=HAVE_AIO . auto/have
-have=HAVE_IOCP . auto/have
+have=NGX_HAVE_AIO . auto/have
+have=NGX_HAVE_IOCP . auto/have
--- a/auto/summary
+++ b/auto/summary
@@ -95,14 +95,14 @@ END
 fi
 
 
-echo "  nginx path prefix: $PREFIX"
-echo "  nginx binary file: $SBIN_PATH"
-echo "  nginx configuration file: $CONF_PATH"
-echo "  nginx pid file: $PID_PATH"
-if [ ".$ERROR_LOG_PATH" != "." ]; then
-    echo "  nginx error log file: $ERROR_LOG_PATH"
+echo "  nginx path prefix: $NGX_PREFIX"
+echo "  nginx binary file: $NGX_SBIN_PATH"
+echo "  nginx configuration file: $NGX_CONF_PATH"
+echo "  nginx pid file: $NGX_PID_PATH"
+if test -n "$NGX_ERROR_LOG_PATH"; then
+    echo "  nginx error log file: $NGX_ERROR_LOG_PATH"
 else
     echo "  nginx logs errors to stderr"
 fi
-echo "  nginx http access log file: $HTTP_LOG_PATH"
+echo "  nginx http access log file: $NGX_HTTP_LOG_PATH"
 echo
--- a/auto/threads
+++ b/auto/threads
@@ -9,7 +9,7 @@ case $USE_THREADS in
         CORE_DEPS="$CORE_DEPS $FREEBSD_RFORK_DEPS"
         CORE_SRCS="$CORE_SRCS $FREEBSD_RFORK_SRCS"
 
-        case $PLATFORM in
+        case $NGX_PLATFORM in
             *:i386)
                 if [ \( $version -gt 500000 -a $version -lt 501000 \) \
                      -o $version -lt 491000 ]
@@ -42,7 +42,7 @@ case $USE_THREADS in
     ;;
 
     libc_r)
-        case $PLATFORM in
+        case $NGX_PLATFORM in
             FreeBSD:[34]*)
                 have=NGX_THREADS . auto/have
                 CFLAGS="$CFLAGS -pthread"
--- a/auto/unix
+++ b/auto/unix
@@ -74,7 +74,7 @@ ngx_param=TIME_T_LEN; ngx_value=$ngx_max
 
 
 ngx_feature="setproctitle()"
-ngx_feature_name="HAVE_SETPROCTITLE"
+ngx_feature_name="NGX_HAVE_SETPROCTITLE"
 ngx_feature_run=no
 ngx_feature_incs=
 ngx_feature_libs=
@@ -83,7 +83,7 @@ ngx_feature_test="setproctitle(\"test\")
 
 
 ngx_feature="pread()"
-ngx_feature_name="pread"
+ngx_feature_name="NGX_HAVE_PREAD"
 ngx_feature_run=no
 ngx_feature_incs=
 ngx_feature_libs=
@@ -92,7 +92,7 @@ ngx_feature_test="char buf[1]; ssize_t n
 
 
 ngx_feature="pwrite()"
-ngx_feature_name="pwrite"
+ngx_feature_name="NGX_HAVE_PWRITE"
 ngx_feature_run=no
 ngx_feature_incs=
 ngx_feature_libs=
@@ -101,7 +101,7 @@ ngx_feature_test="char buf[1]; ssize_t n
 
 
 ngx_feature="strerror_r()"
-ngx_feature_name="strerror_r"
+ngx_feature_name="NGX_HAVE_STRERROR_R"
 ngx_feature_run=yes
 ngx_feature_incs="#include <string.h>"
 ngx_feature_libs=
@@ -113,7 +113,7 @@ ngx_feature_test="char buf[32]; int n; n
 # GNU style strerror_r() returns not length, but pointer
 
 ngx_feature="gnu style strerror_r()"
-ngx_feature_name="gnu_strerror_r"
+ngx_feature_name="NGX_HAVE_GNU_STRERROR_R"
 ngx_feature_run=yes
 ngx_feature_incs="#include <string.h>"
 ngx_feature_libs=
@@ -123,7 +123,7 @@ ngx_feature_test="char buf[32]; int n; n
 
 
 ngx_feature="localtime_r()"
-ngx_feature_name="localtime_r"
+ngx_feature_name="NGX_HAVE_LOCALTIME_R"
 ngx_feature_run=no
 ngx_feature_incs="#include <time.h>"
 ngx_feature_libs=
@@ -132,7 +132,7 @@ ngx_feature_test="struct tm t; time_t c=
 
 
 ngx_feature="posix_memalign()"
-ngx_feature_name="posix_memalign"
+ngx_feature_name="NGX_HAVE_POSIX_MEMALIGN"
 ngx_feature_run=no
 ngx_feature_incs="#include <stdlib.h>"
 ngx_feature_libs=
@@ -141,7 +141,7 @@ ngx_feature_test="void *p; int n; n = po
 
 
 ngx_feature="memalign()"
-ngx_feature_name="memalign"
+ngx_feature_name="NGX_HAVE_MEMALIGN"
 ngx_feature_run=no
 ngx_feature_incs="#include <stdlib.h>"
 ngx_feature_libs=
@@ -150,7 +150,7 @@ ngx_feature_test="void *p; p = memalign(
 
 
 ngx_feature="sched_yield()"
-ngx_feature_name="HAVE_SCHED_YIELD"
+ngx_feature_name="NGX_HAVE_SCHED_YIELD"
 ngx_feature_run=no
 ngx_feature_incs="#include <sched.h>"
 ngx_feature_libs=
@@ -159,7 +159,7 @@ ngx_feature_test="sched_yield()"
 
 
 ngx_feature="mmap(MAP_ANON|MAP_SHARED)"
-ngx_feature_name="MAP_ANON"
+ngx_feature_name="NGX_HAVE_MAP_ANON"
 ngx_feature_run=yes
 ngx_feature_incs="#include <sys/mman.h>"
 ngx_feature_libs=
@@ -171,7 +171,7 @@ ngx_feature_test="void *p;
 
 
 ngx_feature='mmap("/dev/zero", MAP_SHARED)'
-ngx_feature_name="MAP_DEVZERO"
+ngx_feature_name="NGX_HAVE_MAP_DEVZERO"
 ngx_feature_run=yes
 ngx_feature_incs="#include <sys/mman.h>
 #include <sys/stat.h>
@@ -185,7 +185,7 @@ ngx_feature_test='void *p; int  fd;
 
 
 ngx_feature="System V shared memory"
-ngx_feature_name="SYSVSHM"
+ngx_feature_name="NGX_HAVE_SYSVSHM"
 ngx_feature_run=yes
 ngx_feature_incs="#include <sys/ipc.h>
 #include <sys/shm.h>"
@@ -198,7 +198,7 @@ ngx_feature_test="int  id;
 
 
 ngx_feature="struct msghdr.msg_control"
-ngx_feature_name="msghdr_msg_control"
+ngx_feature_name="NGX_HAVE_MSGHDR_MSG_CONTROL"
 ngx_feature_run=no
 ngx_feature_incs="#include <sys/socket.h>"
 ngx_feature_libs=
@@ -207,7 +207,7 @@ ngx_feature_test="struct msghdr  msg; ms
 
 
 ngx_feature="ioctl(FIONBIO)"
-ngx_feature_name="FIONBIO"
+ngx_feature_name="NGX_HAVE_FIONBIO"
 ngx_feature_run=no
 ngx_feature_incs="#include <sys/ioctl.h>
 $NGX_INCLUDE_SYS_FILIO_H"
@@ -217,7 +217,7 @@ ngx_feature_test="int i; i = FIONBIO"
 
 
 ngx_feature="struct tm.tm_gmtoff"
-ngx_feature_name="gmtoff"
+ngx_feature_name="NGX_HAVE_GMTOFF"
 ngx_feature_run=no
 ngx_feature_incs="#include <time.h>"
 ngx_feature_libs=
--- a/docs/xml/nginx/changes.xml
+++ b/docs/xml/nginx/changes.xml
@@ -6,6 +6,54 @@
             title="nginx">
 
 
+<changes ver="0.1.9" date="25.11.2004">
+
+<change type="bugfix">
+<para lang="ru">
+ÅÓÌÉ × ÚÁÐÒÏÓÅ ÅÓÔØ "//", "/./", "/../" ÉÌÉ "%XX", ÔÏ ÐÒÏËÓÉÒÕÅÍÙÊ
+ÚÁÐÒÏÓ ÐÅÒÅÄÁ×ÁÌÓÑ ÂÅÚ ÁÒÇÕÍÅÎÔÏ×.
+</para>
+<para lang="en">
+the proxied request was sent without arguments if the request contains
+"//", "/./", "/../" or "%XX".
+</para>
+</change>
+
+<change type="bugfix">
+<para lang="ru">
+ÐÒÉ ÓÖÁÔÉÉ ÂÏÌØÛÉÈ ÏÔ×ÅÔÏ× ÉÎÏÇÄÁ ÏÎÉ ÐÅÒÅÄÁ×ÁÌÉÓØ ÎÅ ÐÏÌÎÏÓÔØÀ.
+</para>
+<para lang="en">
+the large compressed responses may be transferred not completely.
+</para>
+</change>
+
+<change type="bugfix">
+<para lang="ru">
+ÎÅ ÐÅÒÅÄÁ×ÁÌÉÓØ ÆÁÊÌÙ ÂÏÌØÛÅ 2G ÎÁ Linux, ÎÅÐÏÄÄÅÒÖÉ×ÁÀÝÅÍ sendfile64().
+</para>
+<para lang="en">
+the files bigger than 2G was not transferred on Linux that does not support
+sendfile64().
+</para>
+</change>
+
+<change type="bugfix">
+<para lang="ru">
+ÎÁ Linux ÐÒÉ ËÏÎÆÉÇÕÒÁÃÉÉ ÓÂÏÒËÉ ÎÕÖÎÏ ÂÙÌÏ ÏÂÑÚÁÔÅÌØÎÏ ÉÓÐÏÌØÚÏ×ÁÔØ
+ÐÁÒÁÍÅÔÒ --with-poll_module;
+ÏÛÉÂËÁ ÐÏÑ×ÉÌÁÓØ × 0.1.8.
+</para>
+<para lang="en">
+while the build configuration on Linux the --with-poll_module parameter
+was required;
+bug appeared in 0.1.8.
+</para>
+</change>
+
+</changes>
+
+
 <changes ver="0.1.8" date="20.11.2004">
 
 <change type="bugfix">
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -112,7 +112,7 @@ ngx_uint_t  ngx_max_module;
 
 
 
-int main(int argc, char *const *argv, char *const *envp)
+int main(int argc, char *const *argv)
 {
     ngx_int_t         i;
     ngx_log_t        *log;
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define NGINX_VER          "nginx/0.1.8"
+#define NGINX_VER          "nginx/0.1.9"
 
 #define NGINX_VAR          "NGINX"
 #define NGX_NEWPID_EXT     ".newbin"
--- a/src/core/ngx_buf.c
+++ b/src/core/ngx_buf.c
@@ -140,7 +140,7 @@ void ngx_chain_update_chains(ngx_chain_t
             break;
         }
 
-#if (HAVE_WRITE_ZEROCOPY)
+#if (NGX_HAVE_WRITE_ZEROCOPY)
         if ((*busy)->buf->zerocopy_busy) {
             break;
         }
--- a/src/core/ngx_config.h
+++ b/src/core/ngx_config.h
@@ -11,6 +11,13 @@
 #include <ngx_auto_headers.h>
 
 
+#if ((__GNU__ == 2) && (__GNUC_MINOR__ < 8))
+#define NGX_MAX_UINT32_VALUE  0xffffffffLL
+#else
+#define NGX_MAX_UINT32_VALUE  0xffffffff
+#endif
+
+
 #if defined __DragonFly__ && !defined __FreeBSD__
 #define __FreeBSD__        4
 #define __FreeBSD_version  480101
@@ -127,12 +134,5 @@ typedef long               ngx_flag_t;
 #define NGX_MAXHOSTNAMELEN MAXHOSTNAMELEN
 */
 
-#if ((__GNU__ == 2) && (__GNUC_MINOR__ < 8))
-#define NGX_MAX_UINT32_VALUE  0xffffffffLL
-#else
-#define NGX_MAX_UINT32_VALUE  0xffffffff
-#endif
-
-
 
 #endif /* _NGX_CONFIG_H_INCLUDED_ */
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -48,7 +48,7 @@ typedef struct {
     unsigned          nonblocking_accept:1;
     unsigned          nonblocking:1;
     unsigned          shared:1;    /* shared between threads or processes */
-#if (HAVE_DEFERRED_ACCEPT)
+#if (NGX_HAVE_DEFERRED_ACCEPT)
     unsigned          deferred_accept:1;
 #endif
 
@@ -101,7 +101,7 @@ struct ngx_connection_s {
     ngx_ssl_t          *ssl;
 #endif
 
-#if (HAVE_IOCP)
+#if (NGX_HAVE_IOCP)
     struct sockaddr    *local_sockaddr;
     socklen_t           local_socklen;
 #endif
@@ -122,7 +122,7 @@ struct ngx_connection_s {
     unsigned            tcp_nodelay:1;
     signed              tcp_nopush:2;
 
-#if (HAVE_IOCP)
+#if (NGX_HAVE_IOCP)
     unsigned            accept_context_updated:1;
 #endif
 
--- a/src/core/ngx_output_chain.c
+++ b/src/core/ngx_output_chain.c
@@ -9,11 +9,18 @@
 #include <ngx_event.h>
 
 
-#define NGX_NONE      1
+#if 0
+#define NGX_SENDFILE_LIMIT  4096
+#endif
+
+
+#define NGX_NONE            1
 
 
 static ngx_inline ngx_int_t
     ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf);
+static ngx_int_t ngx_output_chain_add_copy(ngx_pool_t *pool,
+                                          ngx_chain_t **chain, ngx_chain_t *in);
 static ngx_int_t ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src,
                                            ngx_uint_t sendfile);
 
@@ -26,17 +33,20 @@ ngx_int_t ngx_output_chain(ngx_output_ch
 
     if (ctx->in == NULL && ctx->busy == 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
-        */
+        /*
+         * 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);
         }
 
         if (in->next == NULL
+#if (NGX_SENDFILE_LIMIT)
+            && !(in->buf->in_file && in->buf->file_last > NGX_SENDFILE_LIMIT)
+#endif
             && (!ngx_output_chain_need_to_copy(ctx, in->buf)))
         {
             return ctx->output_filter(ctx->filter_ctx, in);
@@ -46,7 +56,7 @@ ngx_int_t ngx_output_chain(ngx_output_ch
     /* add the incoming buf to the chain ctx->in */
 
     if (in) {
-        if (ngx_chain_add_copy(ctx->pool, &ctx->in, in) == NGX_ERROR) {
+        if (ngx_output_chain_add_copy(ctx->pool, &ctx->in, in) == NGX_ERROR) {
             return NGX_ERROR;
         }
     }
@@ -191,11 +201,23 @@ ngx_int_t ngx_output_chain(ngx_output_ch
 static ngx_inline ngx_int_t
     ngx_output_chain_need_to_copy(ngx_output_chain_ctx_t *ctx, ngx_buf_t *buf)
 {
+    ngx_uint_t  sendfile;
+
     if (ngx_buf_special(buf)) {
         return 0;
     }
 
-    if (!ctx->sendfile) {
+    sendfile = ctx->sendfile;
+
+#if (NGX_SENDFILE_LIMIT)
+
+    if (buf->in_file && buf->file_pos >= NGX_SENDFILE_LIMIT) {
+        sendfile = 0;
+    }
+
+#endif
+
+    if (!sendfile) {
 
         if (!ngx_buf_in_memory(buf)) {
             return 1;
@@ -216,6 +238,71 @@ static ngx_inline ngx_int_t
 }
 
 
+static ngx_int_t ngx_output_chain_add_copy(ngx_pool_t *pool,
+                                           ngx_chain_t **chain, ngx_chain_t *in)
+{
+    ngx_chain_t  *cl, **ll;
+#if (NGX_SENDFILE_LIMIT)
+    ngx_buf_t    *b, *buf;
+#endif
+
+    ll = chain;
+
+    for (cl = *chain; cl; cl = cl->next) {
+        ll = &cl->next;
+    }
+
+    while (in) {
+
+        if (!(cl = ngx_alloc_chain_link(pool))) {
+            return NGX_ERROR;
+        }
+
+#if (NGX_SENDFILE_LIMIT)
+
+        buf = in->buf;
+
+        if (buf->in_file
+            && buf->file_pos < NGX_SENDFILE_LIMIT
+            && buf->file_last > NGX_SENDFILE_LIMIT)
+        {
+            if (!(b = ngx_calloc_buf(pool))) {
+                return NGX_ERROR;
+            }
+
+            ngx_memcpy(b, buf, sizeof(ngx_buf_t));
+
+            if (ngx_buf_in_memory(buf)) {
+                buf->pos += (ssize_t) (NGX_SENDFILE_LIMIT - buf->file_pos);
+                b->last = buf->pos;
+            }
+
+            buf->file_pos = NGX_SENDFILE_LIMIT;
+            b->file_last = NGX_SENDFILE_LIMIT;
+
+            cl->buf = b;
+
+        } else {
+            cl->buf = buf;
+            in = in->next;
+        }
+
+#else
+        cl->buf = in->buf;
+        in = in->next;
+
+#endif
+
+        *ll = cl;
+        ll = &cl->next;
+    }
+
+    *ll = NULL;
+
+    return NGX_OK;
+}
+
+
 static ngx_int_t ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src,
                                            ngx_uint_t sendfile)
 {
@@ -228,6 +315,14 @@ static ngx_int_t ngx_output_chain_copy_b
         size = dst->end - dst->pos;
     }
 
+#if (NGX_SENDFILE_LIMIT)
+
+    if (src->in_file && src->file_pos >= NGX_SENDFILE_LIMIT) {
+        sendfile = 0;
+    }
+
+#endif
+
     if (ngx_buf_in_memory(src)) {
         ngx_memcpy(dst->pos, src->pos, size);
         src->pos += size;
--- a/src/core/ngx_times.c
+++ b/src/core/ngx_times.c
@@ -162,12 +162,12 @@ void ngx_time_update(time_t s)
     ngx_cached_http_time.data = p;
 
 
-#if (HAVE_GETTIMEZONE)
+#if (NGX_HAVE_GETTIMEZONE)
 
     ngx_gmtoff = ngx_gettimezone();
     ngx_gmtime(s + ngx_gmtoff * 60, &tm);
 
-#elif (HAVE_GMTOFF)
+#elif (NGX_HAVE_GMTOFF)
 
     ngx_localtime(&tm);
     ngx_gmtoff = tm.ngx_tm_gmtoff / 60;
--- a/src/event/modules/ngx_aio_module.c
+++ b/src/event/modules/ngx_aio_module.c
@@ -9,7 +9,7 @@
 #include <ngx_event.h>
 #include <ngx_aio.h>
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 #include <ngx_kqueue_module.h>
 #endif
 
@@ -27,7 +27,7 @@ ngx_os_io_t ngx_os_aio = {
     ngx_aio_read_chain,
     ngx_aio_write,
     ngx_aio_write_chain,
-    NGX_HAVE_ZEROCOPY
+    0
 };
 
 
@@ -64,7 +64,7 @@ ngx_module_t  ngx_aio_module = {
 
 
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
 static int ngx_aio_init(ngx_cycle_t *cycle)
 {
@@ -152,7 +152,7 @@ static int ngx_aio_process_events(ngx_cy
     return ngx_kqueue_module_ctx.actions.process_events(cycle);
 }
 
-#endif /* HAVE_KQUEUE */
+#endif /* NGX_HAVE_KQUEUE */
 
 
 #if 0
--- a/src/event/modules/ngx_devpoll_module.c
+++ b/src/event/modules/ngx_devpoll_module.c
@@ -9,7 +9,7 @@
 #include <ngx_event.h>
 
 
-#if (TEST_BUILD_DEVPOLL)
+#if (NGX_TEST_BUILD_DEVPOLL)
 
 /* Solaris declarations */
 
--- a/src/event/modules/ngx_epoll_module.c
+++ b/src/event/modules/ngx_epoll_module.c
@@ -9,7 +9,7 @@
 #include <ngx_event.h>
 
 
-#if (TEST_BUILD_EPOLL)
+#if (NGX_TEST_BUILD_EPOLL)
 
 /* epoll declarations */
 
@@ -168,7 +168,7 @@ static int ngx_epoll_init(ngx_cycle_t *c
 
     ngx_event_actions = ngx_epoll_module_ctx.actions;
 
-#if (HAVE_CLEAR_EVENT)
+#if (NGX_HAVE_CLEAR_EVENT)
     ngx_event_flags = NGX_USE_CLEAR_EVENT
 #else
     ngx_event_flags = NGX_USE_LEVEL_EVENT
--- a/src/event/modules/ngx_kqueue_module.c
+++ b/src/event/modules/ngx_kqueue_module.c
@@ -189,7 +189,7 @@ static ngx_int_t ngx_kqueue_init(ngx_cyc
     ngx_event_actions = ngx_kqueue_module_ctx.actions;
 
     ngx_event_flags = NGX_USE_ONESHOT_EVENT
-#if (HAVE_CLEAR_EVENT)
+#if (NGX_HAVE_CLEAR_EVENT)
                      |NGX_USE_CLEAR_EVENT
 #else
                      |NGX_USE_LEVEL_EVENT
--- a/src/event/modules/ngx_rtsig_module.c
+++ b/src/event/modules/ngx_rtsig_module.c
@@ -9,7 +9,7 @@
 #include <ngx_event.h>
 
 
-#if (TEST_BUILD_RTSIG)
+#if (NGX_TEST_BUILD_RTSIG)
 
 #define F_SETSIG       10
 #define SIGRTMIN       33
@@ -217,7 +217,7 @@ static ngx_int_t ngx_rtsig_add_connectio
         return NGX_ERROR;
     }
 
-#if (HAVE_ONESIGFD)
+#if (NGX_HAVE_ONESIGFD)
     if (fcntl(c->fd, F_SETAUXFL, O_ONESIGFD) == -1) {
         ngx_log_error(NGX_LOG_ALERT, c->log, ngx_errno,
                       "fcntl(F_SETAUXFL) failed");
--- a/src/event/modules/ngx_select_module.c
+++ b/src/event/modules/ngx_select_module.c
@@ -258,7 +258,7 @@ static ngx_int_t ngx_select_process_even
     ngx_connection_t         *c;
     ngx_epoch_msec_t          delta;
     struct timeval            tv, *tp;
-#if (HAVE_SELECT_CHANGE_TIMEOUT)
+#if (NGX_HAVE_SELECT_CHANGE_TIMEOUT)
     static ngx_epoch_msec_t   deltas = 0;
 #endif
 
@@ -362,7 +362,7 @@ static ngx_int_t ngx_select_process_even
         err = 0;
     }
 
-#if (HAVE_SELECT_CHANGE_TIMEOUT)
+#if (NGX_HAVE_SELECT_CHANGE_TIMEOUT)
 
     if (timer != NGX_TIMER_INFINITE) {
         delta = timer - (tv.tv_sec * 1000 + tv.tv_usec / 1000);
@@ -403,7 +403,7 @@ static ngx_int_t ngx_select_process_even
         }
     }
 
-#else /* !(HAVE_SELECT_CHANGE_TIMEOUT) */
+#else /* !(NGX_HAVE_SELECT_CHANGE_TIMEOUT) */
 
     ngx_gettimeofday(&tv);
     ngx_time_update(tv.tv_sec);
@@ -427,7 +427,7 @@ static ngx_int_t ngx_select_process_even
         }
     }
 
-#endif /* HAVE_SELECT_CHANGE_TIMEOUT */
+#endif /* NGX_HAVE_SELECT_CHANGE_TIMEOUT */
 
     ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
                    "select ready %d", ready);
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -371,7 +371,7 @@ static ngx_int_t ngx_event_process_init(
 
         rev->accept = 1;
 
-#if (HAVE_DEFERRED_ACCEPT)
+#if (NGX_HAVE_DEFERRED_ACCEPT)
         rev->deferred_accept = s[i].deferred_accept;
 #endif
 
@@ -719,7 +719,7 @@ static char *ngx_event_init_conf(ngx_cyc
     rtsig = 0;
     fd = 0;
 
-#if (HAVE_EPOLL) && !(TEST_BUILD_EPOLL)
+#if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL)
 
     fd = epoll_create(100);
 
@@ -735,7 +735,7 @@ static char *ngx_event_init_conf(ngx_cyc
 
 #endif
 
-#if (HAVE_RTSIG)
+#if (NGX_HAVE_RTSIG)
 
     if (module == NULL) {
         connections = DEFAULT_CONNECTIONS;
@@ -745,21 +745,21 @@ static char *ngx_event_init_conf(ngx_cyc
 
 #endif
 
-#if (HAVE_DEVPOLL)
+#if (NGX_HAVE_DEVPOLL)
 
     connections = DEFAULT_CONNECTIONS;
     module = &ngx_devpoll_module;
 
 #endif
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
     connections = DEFAULT_CONNECTIONS;
     module = &ngx_kqueue_module;
 
 #endif
 
-#if (HAVE_SELECT)
+#if (NGX_HAVE_SELECT)
 
     if (module == NULL) {
 
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -15,7 +15,7 @@
 #define NGX_INVALID_INDEX  0xd0d0d0d0
 
 
-#if (HAVE_IOCP)
+#if (NGX_HAVE_IOCP)
 
 typedef struct {
     WSAOVERLAPPED    ovlp;
@@ -86,7 +86,7 @@ struct ngx_event_s {
     unsigned         accept_context_updated:1;
 #endif
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
     unsigned         kq_vnode:1;
 
     /* the pending errno reported by kqueue */
@@ -107,7 +107,7 @@ struct ngx_event_s {
      *   accept:     1 if accept many, 0 otherwise
      */
 
-#if (HAVE_KQUEUE) || (HAVE_IOCP)
+#if (NGX_HAVE_KQUEUE) || (NGX_HAVE_IOCP)
     int              available;
 #else
     unsigned         available:1;
@@ -117,9 +117,9 @@ struct ngx_event_s {
     ngx_event_handler_pt  event_handler;
 
 
-#if (HAVE_AIO)
+#if (NGX_HAVE_AIO)
 
-#if (HAVE_IOCP)
+#if (NGX_HAVE_IOCP)
     ngx_event_ovlp_t ovlp;
 #else
     struct aiocb     aiocb;
@@ -154,12 +154,12 @@ struct ngx_event_s {
     unsigned         posted_timedout:1;
     unsigned         posted_eof:1;
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
     /* the pending errno reported by kqueue */
     int              posted_errno;
 #endif
 
-#if (HAVE_KQUEUE) || (HAVE_IOCP)
+#if (NGX_HAVE_KQUEUE) || (NGX_HAVE_IOCP)
     int              posted_available;
 #else
     unsigned         posted_available:1;
@@ -272,7 +272,7 @@ extern ngx_event_actions_t   ngx_event_a
 
 /*
  * Need to add socket or handle only once - i/o completion port.
- * It also requires HAVE_AIO and NGX_USE_AIO_EVENT to be set.
+ * It also requires NGX_HAVE_AIO and NGX_USE_AIO_EVENT to be set.
  */
 #define NGX_USE_IOCP_EVENT       0x00000200
 
@@ -296,7 +296,7 @@ extern ngx_event_actions_t   ngx_event_a
 #define NGX_VNODE_EVENT    0
 
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
 #define NGX_READ_EVENT     EVFILT_READ
 #define NGX_WRITE_EVENT    EVFILT_WRITE
@@ -325,7 +325,7 @@ extern ngx_event_actions_t   ngx_event_a
 #define NGX_DISABLE_EVENT  EV_DISABLE
 
 
-#elif (HAVE_DEVPOLL)
+#elif (NGX_HAVE_DEVPOLL)
 
 #define NGX_READ_EVENT     POLLIN
 #define NGX_WRITE_EVENT    POLLOUT
@@ -334,7 +334,7 @@ extern ngx_event_actions_t   ngx_event_a
 #define NGX_ONESHOT_EVENT  1
 
 
-#elif (HAVE_EPOLL)
+#elif (NGX_HAVE_EPOLL)
 
 #define NGX_READ_EVENT     EPOLLIN
 #define NGX_WRITE_EVENT    EPOLLOUT
@@ -347,7 +347,7 @@ extern ngx_event_actions_t   ngx_event_a
 #endif
 
 
-#elif (HAVE_POLL)
+#elif (NGX_HAVE_POLL)
 
 #define NGX_READ_EVENT     POLLIN
 #define NGX_WRITE_EVENT    POLLOUT
@@ -364,10 +364,10 @@ extern ngx_event_actions_t   ngx_event_a
 #define NGX_LEVEL_EVENT    0
 #define NGX_ONESHOT_EVENT  1
 
-#endif /* HAVE_KQUEUE */
+#endif /* NGX_HAVE_KQUEUE */
 
 
-#if (HAVE_IOCP)
+#if (NGX_HAVE_IOCP)
 #define NGX_IOCP_ACCEPT      0
 #define NGX_IOCP_IO          1
 #define NGX_IOCP_CONNECT     2
--- a/src/event/ngx_event_openssl.c
+++ b/src/event/ngx_event_openssl.c
@@ -9,7 +9,7 @@
 #include <ngx_event.h>
 
 
-static ngx_int_t ngx_ssl_write(ngx_connection_t *c, u_char *data, size_t size);
+static ssize_t ngx_ssl_write(ngx_connection_t *c, u_char *data, size_t size);
 
 
 ngx_int_t ngx_ssl_init(ngx_log_t *log)
@@ -58,7 +58,7 @@ ngx_int_t ngx_ssl_create_session(ngx_ssl
 }
 
 
-ngx_int_t ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size)
+ssize_t ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size)
 {
     int         n, sslerr;
     ngx_err_t   err;
@@ -239,7 +239,7 @@ ngx_chain_t *ngx_ssl_send_chain(ngx_conn
 }
 
 
-static ngx_int_t ngx_ssl_write(ngx_connection_t *c, u_char *data, size_t size)
+static ssize_t ngx_ssl_write(ngx_connection_t *c, u_char *data, size_t size)
 {
     int         n, sslerr;
     ngx_err_t   err;
--- a/src/event/ngx_event_openssl.h
+++ b/src/event/ngx_event_openssl.h
@@ -41,7 +41,7 @@ ngx_int_t ngx_ssl_create_session(ngx_ssl
 
 #define ngx_ssl_handshake(c)     NGX_OK
 
-ngx_int_t ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size);
+ssize_t ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size);
 ngx_chain_t *ngx_ssl_send_chain(ngx_connection_t *c, ngx_chain_t *in,
                                 off_t limit);
 ngx_int_t ngx_ssl_shutdown(ngx_connection_t *c);
--- a/src/event/ngx_event_pipe.c
+++ b/src/event/ngx_event_pipe.c
@@ -132,7 +132,7 @@ ngx_int_t ngx_event_pipe_read_upstream(n
                 p->upstream_eof = 1;
                 p->read = 1;
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
                 if (p->upstream->read->kq_errno) {
                     p->upstream->read->error = 1;
                     p->upstream_error = 1;
--- a/src/event/ngx_event_posted.c
+++ b/src/event/ngx_event_posted.c
@@ -120,7 +120,7 @@ ngx_int_t ngx_event_thread_process_poste
             ev->ready |= ev->posted_ready;
             ev->timedout |= ev->posted_timedout;
             ev->pending_eof |= ev->posted_eof;
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
             ev->kq_errno |= ev->posted_errno;
 #endif
             if (ev->posted_available) {
@@ -130,7 +130,7 @@ ngx_int_t ngx_event_thread_process_poste
             ev->posted_ready = 0;
             ev->posted_timedout = 0;
             ev->posted_eof = 0;
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
             ev->posted_errno = 0;
 #endif
             ev->posted_available = 0;
--- a/src/http/modules/ngx_http_gzip_filter.c
+++ b/src/http/modules/ngx_http_gzip_filter.c
@@ -237,14 +237,14 @@ static ngx_http_log_op_name_t ngx_http_g
 
 static u_char  gzheader[10] = { 0x1f, 0x8b, Z_DEFLATED, 0, 0, 0, 0, 0, 0, 3 };
 
-#if (HAVE_LITTLE_ENDIAN)
+#if (NGX_HAVE_LITTLE_ENDIAN)
 
 struct gztrailer {
     uint32_t  crc32;
     uint32_t  zlen;
 };
 
-#else /* HAVE_BIG_ENDIAN */
+#else /* NGX_HAVE_BIG_ENDIAN */
 
 struct gztrailer {
     u_char  crc32[4];
@@ -437,7 +437,8 @@ static ngx_int_t ngx_http_gzip_proxied(n
 static ngx_int_t ngx_http_gzip_body_filter(ngx_http_request_t *r,
                                            ngx_chain_t *in)
 {
-    int                    rc, wbits, memlevel, last;
+    int                    rc, wbits, memlevel;
+    ngx_int_t              last;
     struct gztrailer      *trailer;
     ngx_buf_t             *b;
     ngx_chain_t           *cl;
@@ -469,7 +470,7 @@ static ngx_int_t ngx_http_gzip_body_filt
         /*
          * We preallocate a memory for zlib in one buffer (200K-400K), this
          * dicreases a number of malloc() and free() calls and also probably
-         * dicreases a number of syscalls (sbrk() or so).
+         * dicreases a number of syscalls (sbrk() and so on).
          * Besides we free this memory as soon as the gzipping will complete
          * and do not wait while a whole response will be sent to a client.
          *
@@ -512,8 +513,19 @@ static ngx_int_t ngx_http_gzip_body_filt
         }
         cl->buf = b;
         cl->next = NULL;
-        ctx->out = cl;
-        ctx->last_out = &cl->next;
+
+        /*
+         * We pass the gzheader to the next filter now to avoid its linking
+         * to the ctx->busy chain.  zlib does not usually output the compressed
+         * data in the initial iterations, so the gzheader that was linked
+         * to the ctx->busy chain would be flushed by ngx_http_write_filter().
+         */
+
+        if (ngx_http_next_body_filter(r, cl) == NGX_ERROR) {
+            return ngx_http_gzip_error(ctx);
+        }
+
+        ctx->last_out = &ctx->out;
 
         ctx->crc32 = crc32(0L, Z_NULL, 0);
         ctx->flush = Z_NO_FLUSH;
@@ -727,7 +739,7 @@ static ngx_int_t ngx_http_gzip_body_filt
                     b->last += 8;
                 }
 
-#if (HAVE_LITTLE_ENDIAN)
+#if (NGX_HAVE_LITTLE_ENDIAN)
                 trailer->crc32 = ctx->crc32;
                 trailer->zlen = ctx->zin;
 #else
@@ -763,7 +775,7 @@ static ngx_int_t ngx_http_gzip_body_filt
             }
         }
 
-        if (last == NGX_AGAIN) {
+        if (last == NGX_AGAIN && !ctx->done) {
             return NGX_AGAIN;
         }
 
@@ -881,7 +893,9 @@ static int ngx_http_gzip_error(ngx_http_
 {
     deflateEnd(&ctx->zstream);
 
-    ngx_pfree(ctx->request->pool, ctx->preallocated);
+    if (ctx->preallocated) {
+        ngx_pfree(ctx->request->pool, ctx->preallocated);
+    }
 
     ctx->zstream.avail_in = 0;
     ctx->zstream.avail_out = 0;
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -10,19 +10,19 @@
 
 
 typedef struct {
-    ngx_array_t             indices;
-    size_t                  max_index_len;
-    ngx_http_cache_hash_t  *index_cache;
+    ngx_array_t              indices;
+    size_t                   max_index_len;
+    ngx_http_cache_hash_t   *index_cache;
 } ngx_http_index_loc_conf_t;
 
 
 typedef struct {
-    ngx_uint_t         index;
-    u_char            *last;
-    ngx_str_t          path;
-    ngx_str_t          redirect;
-    ngx_http_cache_t  *cache;
-    unsigned           tested:1;
+    ngx_uint_t               index;
+    u_char                  *last;
+    ngx_str_t                path;
+    ngx_str_t                redirect;
+    ngx_http_cache_entry_t  *cache;
+    ngx_uint_t               tested; /* unsigned  tested:1 */
 } ngx_http_index_ctx_t;
 
 
--- a/src/http/modules/proxy/ngx_http_proxy_cache.c
+++ b/src/http/modules/proxy/ngx_http_proxy_cache.c
@@ -297,7 +297,7 @@ void ngx_http_proxy_cache_busy_lock(ngx_
 
     if (rc == NGX_AGAIN) {
 
-        if ((ngx_event_flags & (NGX_USE_CLEAR_EVENT|NGX_HAVE_KQUEUE_EVENT))
+        if ((ngx_event_flags & (NGX_USE_CLEAR_EVENT|NGX_USE_KQUEUE_EVENT))
             && !p->request->connection->write->active)
         {
             /*
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -414,7 +414,7 @@ void ngx_http_proxy_check_broken_connect
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ev->log, 0,
                    "http proxy check client, write event:%d", ev->write);
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
     if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
 
@@ -563,9 +563,9 @@ void ngx_http_proxy_busy_lock_handler(ng
      */
 
 #if 0
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
-    if ((ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) && rev->kq_eof) {
+    if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && rev->kq_eof) {
         ngx_http_busy_unlock(p->lcf->busy_lock, &p->busy_lock);
 
         ngx_del_timer(rev);
@@ -1400,7 +1400,7 @@ static char *ngx_http_proxy_lowat_check(
         return NGX_CONF_ERROR;
     }
 
-#elif !(HAVE_SO_SNDLOWAT)
+#elif !(NGX_HAVE_SO_SNDLOWAT)
 
     ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
                        "\"proxy_send_lowat\" is not supported, ignored");
--- a/src/http/modules/proxy/ngx_http_proxy_handler.h
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.h
@@ -142,7 +142,7 @@ typedef struct {
 
 
 typedef struct {
-    ngx_http_cache_ctx_t             ctx;
+    ngx_http_cache_t                 ctx;
     ngx_uint_t                       status;
     ngx_str_t                        status_line;
 
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -782,7 +782,7 @@ static void ngx_http_proxy_send_request(
     ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
                    "http proxy send request");
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
     if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT)
         && !p->request_sent
@@ -1287,8 +1287,8 @@ static void ngx_http_proxy_send_response
         header->length = r->headers_out.content_length_n;
         p->cache->ctx.length = r->headers_out.content_length_n;
 
-        header->key_len = p->cache->ctx.key.len;
-        ngx_memcpy(&header->key, p->cache->ctx.key.data, header->key_len);
+        header->key_len = p->cache->ctx.key0.len;
+        ngx_memcpy(&header->key, p->cache->ctx.key0.data, header->key_len);
         header->key[header->key_len] = LF;
     }
 
--- a/src/http/ngx_http_cache.c
+++ b/src/http/ngx_http_cache.c
@@ -63,7 +63,7 @@ ngx_http_cache_t *ngx_http_cache_get(ngx
 
             c[i].refs++;
 
-            if ((!(c[i].notify && (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT)))
+            if ((!(c[i].notify && (ngx_event_flags & NGX_USE_KQUEUE_EVENT)))
                 && (ngx_cached_time - c[i].updated >= hash->update))
             {
                 c[i].expired = 1;
--- a/src/http/ngx_http_cache.h
+++ b/src/http/ngx_http_cache.h
@@ -14,11 +14,12 @@
 
 
 /*
- * The 7 uses before an allocation.
+ * The 3 bits allows the 7 uses before the cache entry allocation.
  * We can use maximum 7 bits, i.e up to the 127 uses.
  */
 #define NGX_HTTP_CACHE_LAZY_ALLOCATION_BITS  3
 
+
 typedef struct {
     uint32_t         crc;
     ngx_str_t        key;
@@ -45,7 +46,7 @@ typedef struct {
         off_t        size;
         ngx_str_t    value;
     } data;
-} ngx_http_cache_t;
+} ngx_http_cache_entry_t;
 
 
 typedef struct {
@@ -62,7 +63,7 @@ typedef struct {
 #define NGX_HTTP_CACHE_NELTS  4
 
 typedef struct {
-    ngx_http_cache_t         *elts;
+    ngx_http_cache_entry_t   *elts;
     size_t                    hash;
     size_t                    nelts;
     time_t                    life;
@@ -76,9 +77,9 @@ typedef struct {
 
 typedef struct {
     ngx_http_cache_hash_t    *hash;
-    ngx_http_cache_t         *cache;
+    ngx_http_cache_entry_t   *cache;
     ngx_file_t                file;
-    ngx_str_t                 key;
+    ngx_array_t               key;
     uint32_t                  crc;
     u_char                    md5[16];
     ngx_path_t               *path;
@@ -90,7 +91,10 @@ typedef struct {
     ssize_t                   header_size;
     size_t                    file_start;
     ngx_log_t                *log;
-} ngx_http_cache_ctx_t;
+
+    /* STUB */
+    ngx_str_t                 key0;
+} ngx_http_cache_t;
 
 
 
@@ -99,6 +103,8 @@ typedef struct {
 #define NGX_HTTP_CACHE_THE_SAME  3
 
 
+#if 0
+
 ngx_http_cache_t *ngx_http_cache_get(ngx_http_cache_hash_t *cache,
                                      ngx_http_cleanup_t *cleanup,
                                      ngx_str_t *key, uint32_t *crc);
@@ -127,5 +133,7 @@ int ngx_garbage_collector_http_cache_han
 
 char *ngx_http_set_cache_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
 
+#endif
+
 
 #endif /* _NGX_HTTP_CACHE_H_INCLUDED_ */
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1828,7 +1828,7 @@ static char *ngx_http_lowat_check(ngx_co
         return NGX_CONF_ERROR;
     }
 
-#elif !(HAVE_SO_SNDLOWAT)
+#elif !(NGX_HAVE_SO_SNDLOWAT)
 
     ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
                        "\"send_lowat\" is not supported, ignored");
--- a/src/http/ngx_http_file_cache.c
+++ b/src/http/ngx_http_file_cache.c
@@ -9,19 +9,20 @@
 #include <ngx_http.h>
 
 
-#if (HAVE_OPENSSL_MD5_H)
+#if (NGX_HAVE_OPENSSL_MD5_H)
 #include <openssl/md5.h>
 #else
 #include <md5.h>
 #endif
 
-#if (HAVE_OPENSSL_MD5)
+#if (NGX_OPENSSL_MD5)
 #define  MD5Init    MD5_Init
 #define  MD5Update  MD5_Update
 #define  MD5Final   MD5_Final
 #endif
 
 
+#if 0
 
 int ngx_http_cache_get_file(ngx_http_request_t *r, ngx_http_cache_ctx_t *ctx)
 {
@@ -237,3 +238,5 @@ int ngx_garbage_collector_http_cache_han
 
     return NGX_OK;
 }
+
+#endif
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -686,7 +686,7 @@ ngx_int_t ngx_http_parse_complex_uri(ngx
 
     ch = *p++;
 
-    while (p < r->uri_start + r->uri.len + 1 && r->args_start == NULL) {
+    while (p < r->uri_end && r->args_start == NULL) {
 
         /*
          * we use "ch = *p++" inside the cycle but this operation is safe
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -532,6 +532,7 @@ static void ngx_http_process_request_lin
                 r->uri.len = r->uri_end - r->uri_start;
             }
 
+
             if (r->complex_uri || r->quoted_uri) {
 
                 if (!(r->uri.data = ngx_palloc(r->pool, r->uri.len + 1))) {
@@ -557,6 +558,7 @@ static void ngx_http_process_request_lin
                 r->uri.data = r->uri_start;
             }
 
+
             r->unparsed_uri.len = r->uri_end - r->uri_start;
             r->unparsed_uri.data = r->uri_start;
 
@@ -1751,7 +1753,7 @@ static void ngx_http_keepalive_handler(n
 
     ctx = (ngx_http_log_ctx_t *) rev->log->data;
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
     if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
         if (rev->pending_eof) {
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -220,7 +220,7 @@ struct ngx_http_cleanup_s {
 
         struct {
             ngx_http_cache_hash_t   *hash;
-            ngx_http_cache_t        *cache;
+            ngx_http_cache_entry_t  *cache;
         } cache;
     } data;
 
@@ -254,7 +254,7 @@ struct ngx_http_request_s {
     void                    **srv_conf;
     void                    **loc_conf;
 
-    ngx_http_cache_t         *cache;
+    ngx_http_cache_entry_t   *cache;
 
     ngx_file_t                file;
 
--- a/src/os/unix/ngx_aio_read.c
+++ b/src/os/unix/ngx_aio_read.c
@@ -9,7 +9,7 @@
 #include <ngx_event.h>
 #include <ngx_aio.h>
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 #include <ngx_kqueue_module.h>
 #endif
 
@@ -46,7 +46,7 @@ ssize_t ngx_aio_read(ngx_connection_t *c
         rev->aiocb.aio_buf = buf;
         rev->aiocb.aio_nbytes = size;
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
         rev->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue;
         rev->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
         rev->aiocb.aio_sigevent.sigev_value.sigval_ptr = rev;
--- a/src/os/unix/ngx_aio_write.c
+++ b/src/os/unix/ngx_aio_write.c
@@ -9,7 +9,7 @@
 #include <ngx_event.h>
 #include <ngx_aio.h>
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 #include <ngx_kqueue_module.h>
 #endif
 
@@ -43,7 +43,7 @@ ssize_t ngx_aio_write(ngx_connection_t *
         wev->aiocb.aio_buf = buf;
         wev->aiocb.aio_nbytes = size;
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
         wev->aiocb.aio_sigevent.sigev_notify_kqueue = ngx_kqueue;
         wev->aiocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
         wev->aiocb.aio_sigevent.sigev_value.sigval_ptr = wev;
--- a/src/os/unix/ngx_alloc.c
+++ b/src/os/unix/ngx_alloc.c
@@ -40,7 +40,7 @@ void *ngx_calloc(size_t size, ngx_log_t 
 }
 
 
-#if (HAVE_POSIX_MEMALIGN)
+#if (NGX_HAVE_POSIX_MEMALIGN)
 
 void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
 {
@@ -58,7 +58,7 @@ void *ngx_memalign(size_t alignment, siz
     return p;
 }
 
-#elif (HAVE_MEMALIGN)
+#elif (NGX_HAVE_MEMALIGN)
 
 void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
 {
--- a/src/os/unix/ngx_alloc.h
+++ b/src/os/unix/ngx_alloc.h
@@ -25,7 +25,7 @@ void *ngx_calloc(size_t size, ngx_log_t 
  * allocations bigger than page size at the page boundary.
  */
 
-#if (HAVE_POSIX_MEMALIGN || HAVE_MEMALIGN)
+#if (NGX_HAVE_POSIX_MEMALIGN || NGX_HAVE_MEMALIGN)
 
 void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log);
 
--- a/src/os/unix/ngx_channel.c
+++ b/src/os/unix/ngx_channel.c
@@ -17,7 +17,7 @@ ngx_int_t ngx_write_channel(ngx_socket_t
     struct iovec        iov[1];
     struct msghdr       msg;
 
-#if (HAVE_MSGHDR_MSG_CONTROL)
+#if (NGX_HAVE_MSGHDR_MSG_CONTROL)
 
     union {
         struct cmsghdr  cm;
@@ -83,7 +83,7 @@ ngx_int_t ngx_read_channel(ngx_socket_t 
     struct iovec        iov[1];
     struct msghdr       msg;
 
-#if (HAVE_MSGHDR_MSG_CONTROL)
+#if (NGX_HAVE_MSGHDR_MSG_CONTROL)
     union {
         struct cmsghdr  cm;
         char            space[CMSG_SPACE(sizeof(int))];
@@ -100,7 +100,7 @@ ngx_int_t ngx_read_channel(ngx_socket_t 
     msg.msg_iov = iov;
     msg.msg_iovlen = 1;
 
-#if (HAVE_MSGHDR_MSG_CONTROL)
+#if (NGX_HAVE_MSGHDR_MSG_CONTROL)
     msg.msg_control = (caddr_t) &cmsg;
     msg.msg_controllen = sizeof(cmsg);
 #else
@@ -131,7 +131,7 @@ ngx_int_t ngx_read_channel(ngx_socket_t 
         return NGX_ERROR;
     }
 
-#if (HAVE_MSGHDR_MSG_CONTROL)
+#if (NGX_HAVE_MSGHDR_MSG_CONTROL)
 
     if (ch->command == NGX_CMD_OPEN_CHANNEL) {
 
--- a/src/os/unix/ngx_errno.c
+++ b/src/os/unix/ngx_errno.c
@@ -8,7 +8,7 @@
 #include <ngx_core.h>
 
 
-#if (NGX_STRERROR_R)
+#if (NGX_HAVE_STRERROR_R)
 
 u_char *ngx_strerror_r(int err, u_char *errstr, size_t size)
 {
@@ -28,7 +28,7 @@ u_char *ngx_strerror_r(int err, u_char *
     return errstr;
 }
 
-#elif (NGX_GNU_STRERROR_R)
+#elif (NGX_HAVE_GNU_STRERROR_R)
 
 /* Linux strerror_r() */
 
--- a/src/os/unix/ngx_errno.h
+++ b/src/os/unix/ngx_errno.h
@@ -46,7 +46,7 @@ typedef int               ngx_err_t;
 #define ngx_set_socket_errno(err)  errno = err
 
 
-#if (HAVE_STRERROR_R || HAVE_GNU_STRERROR_R)
+#if (NGX_HAVE_STRERROR_R || NGX_HAVE_GNU_STRERROR_R)
 
 u_char *ngx_strerror_r(int err, u_char *errstr, size_t size);
 
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -15,7 +15,7 @@ ssize_t ngx_read_file(ngx_file_t *file, 
     ngx_log_debug4(NGX_LOG_DEBUG_CORE, file->log, 0,
                    "read: %d, %p, %uz, %O", file->fd, buf, size, offset);
 
-#if (NGX_PREAD)
+#if (NGX_HAVE_PREAD)
 
     n = pread(file->fd, buf, size, offset);
 
@@ -60,7 +60,7 @@ ssize_t ngx_write_file(ngx_file_t *file,
     ngx_log_debug4(NGX_LOG_DEBUG_CORE, file->log, 0,
                    "write: %d, %p, %uz, %O", file->fd, buf, size, offset);
 
-#if (NGX_PWRITE)
+#if (NGX_HAVE_PWRITE)
 
     n = pwrite(file->fd, buf, size, offset);
 
--- a/src/os/unix/ngx_freebsd_config.h
+++ b/src/os/unix/ngx_freebsd_config.h
@@ -60,23 +60,23 @@
 #include <ngx_auto_config.h>
 
 
-#if (HAVE_POLL)
+#if (NGX_HAVE_POLL)
 #include <poll.h>
 #endif
 
 
-#if (HAVE_AIO)
+#if (NGX_HAVE_AIO)
 #include <aio.h>
 #endif
 
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 #include <sys/event.h>
 #endif
 
 
-#if defined SO_ACCEPTFILTER && !defined HAVE_DEFERRED_ACCEPT
-#define HAVE_DEFERRED_ACCEPT  1
+#if defined SO_ACCEPTFILTER && !defined NGX_HAVE_DEFERRED_ACCEPT
+#define NGX_HAVE_DEFERRED_ACCEPT  1
 #endif
 
 
@@ -91,8 +91,8 @@ pid_t rfork_thread(int flags, void *stac
 #endif
 
 
-#ifndef HAVE_INHERITED_NONBLOCK
-#define HAVE_INHERITED_NONBLOCK  1
+#ifndef NGX_HAVE_INHERITED_NONBLOCK
+#define NGX_HAVE_INHERITED_NONBLOCK  1
 #endif
 
 
--- a/src/os/unix/ngx_freebsd_init.c
+++ b/src/os/unix/ngx_freebsd_init.c
@@ -30,7 +30,7 @@ ngx_os_io_t ngx_os_io = {
     ngx_unix_recv,
     ngx_readv_chain,
     ngx_unix_send,
-#if (HAVE_SENDFILE)
+#if (NGX_HAVE_SENDFILE)
     ngx_freebsd_sendfile_chain,
     NGX_IO_SENDFILE
 #else
@@ -128,7 +128,7 @@ ngx_int_t ngx_os_init(ngx_log_t *log)
     version = ngx_freebsd_kern_osreldate;
 
 
-#if (HAVE_SENDFILE)
+#if (NGX_HAVE_SENDFILE)
 
     /*
      * The determination of the sendfile() "nbytes bug" is complex enough.
@@ -161,7 +161,7 @@ ngx_int_t ngx_os_init(ngx_log_t *log)
 
 #endif
 
-#endif /* HAVE_SENDFILE */
+#endif /* NGX_HAVE_SENDFILE */
 
 
     if ((version < 500000 && version >= 440003) || version >= 500017) {
--- a/src/os/unix/ngx_freebsd_rfork_thread.c
+++ b/src/os/unix/ngx_freebsd_rfork_thread.c
@@ -381,7 +381,7 @@ ngx_int_t ngx_mutex_dolock(ngx_mutex_t *
                 return NGX_AGAIN;
             }
 
-            if (ngx_freebsd_hw_ncpu > 1 && tries++ < 1000) {
+            if (ngx_ncpu > 1 && tries++ < 1000) {
 
                 /* the spinlock is used only on the SMP system */
 
@@ -581,7 +581,7 @@ ngx_cond_t *ngx_cond_init(ngx_log_t *log
     }
 
     cv->signo = NGX_CV_SIGNAL;
-    cv->tid = 0;
+    cv->tid = -1;
     cv->log = log;
     cv->kq = -1;
 
@@ -640,6 +640,8 @@ ngx_int_t ngx_cond_wait(ngx_cond_t *cv, 
             ngx_log_error(NGX_LOG_ALERT, cv->log, ngx_errno, "kevent() failed");
             return NGX_ERROR;
         }
+
+        cv->tid = ngx_thread_self();
     }
 
     if (ngx_mutex_unlock(m) == NGX_ERROR) {
@@ -714,6 +716,10 @@ ngx_int_t ngx_cond_signal(ngx_cond_t *cv
                    "cv %p to signal %P %d",
                    cv, cv->tid, cv->signo);
 
+    if (cv->tid == -1) {
+        return NGX_OK;
+    }
+
     if (kill(cv->tid, cv->signo) == -1) {
 
         err = ngx_errno;
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -55,7 +55,7 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(
         return in;
     }
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
     if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
         ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
--- a/src/os/unix/ngx_linux_config.h
+++ b/src/os/unix/ngx_linux_config.h
@@ -56,35 +56,37 @@
 #include <sys/prctl.h>
 #endif
 
+
 #if (NGX_HAVE_SENDFILE64)
 #include <sys/sendfile.h>
 #else
 extern ssize_t sendfile(int s, int fd, int32_t *offset, size_t size);
+#define NGX_SENDFILE_LIMIT  (NGX_MAX_UINT32_VALUE + 1)
 #endif
 
 
-#if (HAVE_POLL)
+#if (NGX_HAVE_POLL)
 #include <poll.h>
 #endif
 
 
-#if (HAVE_EPOLL)
+#if (NGX_HAVE_EPOLL)
 #include <sys/epoll.h>
-#endif /* HAVE_EPOLL */
-
-
-#if defined TCP_DEFER_ACCEPT && !defined HAVE_DEFERRED_ACCEPT
-#define HAVE_DEFERRED_ACCEPT  1
 #endif
 
 
-#ifndef HAVE_INHERITED_NONBLOCK
-#define HAVE_INHERITED_NONBLOCK  0
+#if defined TCP_DEFER_ACCEPT && !defined NGX_HAVE_DEFERRED_ACCEPT
+#define NGX_HAVE_DEFERRED_ACCEPT  1
 #endif
 
 
-#ifndef HAVE_SELECT_CHANGE_TIMEOUT
-#define HAVE_SELECT_CHANGE_TIMEOUT   1
+#ifndef NGX_HAVE_INHERITED_NONBLOCK
+#define NGX_HAVE_INHERITED_NONBLOCK  0
+#endif
+
+
+#ifndef NGX_HAVE_SELECT_CHANGE_TIMEOUT
+#define NGX_HAVE_SELECT_CHANGE_TIMEOUT   1
 #endif
 
 #ifndef NGX_SETPROCTITLE_USES_ENV
--- a/src/os/unix/ngx_linux_init.c
+++ b/src/os/unix/ngx_linux_init.c
@@ -18,7 +18,7 @@ ngx_os_io_t ngx_os_io = {
     ngx_unix_recv,
     ngx_readv_chain,
     ngx_unix_send,
-#if (HAVE_SENDFILE)
+#if (NGX_HAVE_SENDFILE)
     ngx_linux_sendfile_chain,
     NGX_IO_SENDFILE
 #else
--- a/src/os/unix/ngx_linux_sendfile_chain.c
+++ b/src/os/unix/ngx_linux_sendfile_chain.c
@@ -13,7 +13,7 @@
  * On Linux up to 2.4.21 sendfile() (syscall #187) works with 32-bit
  * offsets only and the including <sys/sendfile.h> breaks the compiling
  * if off_t is 64 bit wide.  So we use own sendfile() definition where offset
- * parameter is int32_t and use sendfile() with the file parts below 2G.
+ * parameter is int32_t and use sendfile() for the file parts below 2G only.
  *
  * Linux 2.4.21 has a new sendfile64() syscall #239.
  */
--- a/src/os/unix/ngx_os.h
+++ b/src/os/unix/ngx_os.h
@@ -15,18 +15,6 @@
 #define NGX_IO_SENDFILE    1
 #define NGX_IO_ZEROCOPY    2
 
-#if (HAVE_SENDFILE)
-#define NGX_HAVE_SENDFILE  NGX_IO_SENDFILE
-#else
-#define NGX_HAVE_SENDFILE  0
-#endif
-
-#if (HAVE_ZEROCOPY)
-#define NGX_HAVE_ZEROCOPY  NGX_IO_ZEROCOPY
-#else
-#define NGX_HAVE_ZEROCOPY  0
-#endif
-
 
 typedef ssize_t (*ngx_recv_pt)(ngx_connection_t *c, u_char *buf, size_t size);
 typedef ssize_t (*ngx_recv_chain_pt)(ngx_connection_t *c, ngx_chain_t *in);
--- a/src/os/unix/ngx_posix_config.h
+++ b/src/os/unix/ngx_posix_config.h
@@ -70,17 +70,17 @@
 #include <ngx_auto_config.h>
 
 
-#if (HAVE_POLL)
+#if (NGX_HAVE_POLL)
 #include <poll.h>
 #endif
 
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 #include <sys/event.h>
 #endif
 
 
-#if (HAVE_DEVPOLL)
+#if (NGX_HAVE_DEVPOLL)
 #include <sys/ioctl.h>
 #include <sys/devpoll.h>
 #endif
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -121,7 +121,7 @@ ngx_int_t ngx_posix_init(ngx_log_t *log)
 
     ngx_max_sockets = rlmt.rlim_cur;
 
-#if (HAVE_INHERITED_NONBLOCK)
+#if (NGX_HAVE_INHERITED_NONBLOCK)
     ngx_inherited_nonblocking = 1;
 #else
     ngx_inherited_nonblocking = 0;
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -607,6 +607,10 @@ static void ngx_master_exit(ngx_cycle_t 
 
 static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
 {
+    ngx_int_t          n;
+    ngx_err_t          err;
+    ngx_core_conf_t   *ccf;
+
     ngx_worker_process_init(cycle);
 
     ngx_setproctitle("worker process");
@@ -618,6 +622,8 @@ static void ngx_worker_process_cycle(ngx
         exit(2);
     }
 
+    ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
+
     if (ngx_threads_n) {
         if (ngx_init_threads(ngx_threads_n,
                                    ccf->thread_stack_size, cycle) == NGX_ERROR)
@@ -914,10 +920,9 @@ static void ngx_wakeup_worker_threads(ng
 
         for (i = 0; i < ngx_threads_n; i++) {
             if (ngx_threads[i].state < NGX_THREAD_EXIT) {
-                ngx_cond_signal(ngx_threads[i].cv);
+                if (ngx_cond_signal(ngx_threads[i].cv) == NGX_ERROR) {
+                    ngx_threads[i].state = NGX_THREAD_DONE;
 
-                if (ngx_threads[i].cv->tid == (ngx_tid_t) -1) {
-                    ngx_threads[i].state = NGX_THREAD_DONE;
                 } else {
                     live = 1;
                 }
@@ -955,8 +960,6 @@ static void *ngx_worker_thread_cycle(voi
     ngx_core_tls_t   *tls;
     ngx_cycle_t      *cycle;
 
-    thr->cv->tid = ngx_thread_self();
-
     cycle = (ngx_cycle_t *) ngx_cycle;
 
     sigemptyset(&set);
--- a/src/os/unix/ngx_readv_chain.c
+++ b/src/os/unix/ngx_readv_chain.c
@@ -9,7 +9,7 @@
 #include <ngx_event.h>
 
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
 ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
 {
@@ -136,7 +136,7 @@ ssize_t ngx_readv_chain(ngx_connection_t
     return n;
 }
 
-#else /* ! NAVE_KQUEUE */
+#else /* ! NGX_HAVE_KQUEUE */
 
 ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
 {
@@ -216,4 +216,4 @@ ssize_t ngx_readv_chain(ngx_connection_t
     return n;
 }
 
-#endif /* NAVE_KQUEUE */
+#endif /* NGX_HAVE_KQUEUE */
--- a/src/os/unix/ngx_recv.c
+++ b/src/os/unix/ngx_recv.c
@@ -9,7 +9,7 @@
 #include <ngx_event.h>
 
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
 ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
 {
@@ -115,7 +115,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *
     return n;
 }
 
-#else /* ! NAVE_KQUEUE */
+#else /* ! NGX_HAVE_KQUEUE */
 
 ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
 {
@@ -170,4 +170,4 @@ ssize_t ngx_unix_recv(ngx_connection_t *
     return n;
 }
 
-#endif /* NAVE_KQUEUE */
+#endif /* NGX_HAVE_KQUEUE */
--- a/src/os/unix/ngx_send.c
+++ b/src/os/unix/ngx_send.c
@@ -17,7 +17,7 @@ ssize_t ngx_unix_send(ngx_connection_t *
 
     wev = c->write;
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
     if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
         ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
--- a/src/os/unix/ngx_shared.c
+++ b/src/os/unix/ngx_shared.c
@@ -8,7 +8,7 @@
 #include <ngx_core.h>
 
 
-#if (HAVE_MAP_ANON)
+#if (NGX_HAVE_MAP_ANON)
 
 void *ngx_create_shared_memory(size_t size, ngx_log_t *log)
 {
@@ -25,7 +25,7 @@ void *ngx_create_shared_memory(size_t si
     return p;
 }
 
-#elif (HAVE_MAP_DEVZERO)
+#elif (NGX_HAVE_MAP_DEVZERO)
 
 void *ngx_create_shared_memory(size_t size, ngx_log_t *log)
 {
@@ -56,7 +56,7 @@ void *ngx_create_shared_memory(size_t si
     return p;
 }
 
-#elif (HAVE_SYSVSHM)
+#elif (NGX_HAVE_SYSVSHM)
 
 #include <sys/ipc.h>
 #include <sys/shm.h>
--- a/src/os/unix/ngx_socket.c
+++ b/src/os/unix/ngx_socket.c
@@ -20,7 +20,7 @@
  */
 
 
-#if (HAVE_FIONBIO)
+#if (NGX_HAVE_FIONBIO)
 
 int ngx_nonblocking(ngx_socket_t s)
 {
--- a/src/os/unix/ngx_socket.h
+++ b/src/os/unix/ngx_socket.h
@@ -19,7 +19,7 @@ typedef int  ngx_socket_t;
 #define ngx_socket_n        "socket()"
 
 
-#if (HAVE_FIONBIO)
+#if (NGX_HAVE_FIONBIO)
 
 int ngx_nonblocking(ngx_socket_t s);
 int ngx_blocking(ngx_socket_t s);
--- a/src/os/unix/ngx_solaris_config.h
+++ b/src/os/unix/ngx_solaris_config.h
@@ -49,35 +49,35 @@
 #include <ngx_auto_config.h>
 
 
-#if (HAVE_POLL)
+#if (NGX_HAVE_POLL)
 #include <poll.h>
 #endif
 
 
-#if (HAVE_SENDFILE)
+#if (NGX_HAVE_SENDFILE)
 #include <sys/sendfile.h>
 #endif
 
 
-#if (HAVE_AIO)
+#if (NGX_HAVE_AIO)
 #include <aio.h>
 #endif
 
 
-#if (HAVE_DEVPOLL)
+#if (NGX_HAVE_DEVPOLL)
 #include <sys/ioctl.h>
 #include <sys/devpoll.h>
 #endif
 
 
-#ifndef HAVE_INHERITED_NONBLOCK
-#define HAVE_INHERITED_NONBLOCK  1
+#ifndef NGX_HAVE_INHERITED_NONBLOCK
+#define NGX_HAVE_INHERITED_NONBLOCK  1
 #endif
 
 
-#ifndef HAVE_SO_SNDLOWAT
+#ifndef NGX_HAVE_SO_SNDLOWAT
 /* setsockopt(SO_SNDLOWAT) returns error "Option not supported by protocol" */
-#define HAVE_SO_SNDLOWAT         0
+#define NGX_HAVE_SO_SNDLOWAT         0
 #endif
 
 
--- a/src/os/unix/ngx_solaris_init.c
+++ b/src/os/unix/ngx_solaris_init.c
@@ -17,7 +17,7 @@ ngx_os_io_t ngx_os_io = {
     ngx_unix_recv,
     ngx_readv_chain,
     ngx_unix_send,
-#if (HAVE_SENDFILE)
+#if (NGX_HAVE_SENDFILE)
     ngx_solaris_sendfilev_chain,
     NGX_IO_SENDFILE
 #else
--- a/src/os/unix/ngx_thread.h
+++ b/src/os/unix/ngx_thread.h
@@ -53,7 +53,6 @@ typedef struct {
 
 typedef struct {
     pthread_cond_t    cond;
-    ngx_tid_t         tid;
     ngx_log_t        *log;
 } ngx_cond_t;
 
--- a/src/os/unix/ngx_time.c
+++ b/src/os/unix/ngx_time.c
@@ -10,7 +10,7 @@
 
 void ngx_localtime(ngx_tm_t *tm)
 {
-#if (HAVE_LOCALTIME_R)
+#if (NGX_HAVE_LOCALTIME_R)
     time_t     now;
 
     now = ngx_time();
--- a/src/os/unix/ngx_time.h
+++ b/src/os/unix/ngx_time.h
@@ -36,7 +36,7 @@ typedef struct tm      ngx_tm_t;
 #define ngx_tm_wday_t  int
 
 
-#if (HAVE_GMTOFF)
+#if (NGX_HAVE_GMTOFF)
 #define ngx_tm_gmtoff  tm_gmtoff
 #define ngx_tm_zone    tm_zone
 #endif
--- a/src/os/unix/ngx_writev_chain.c
+++ b/src/os/unix/ngx_writev_chain.c
@@ -30,7 +30,7 @@ ngx_chain_t *ngx_writev_chain(ngx_connec
         return in;
     }
 
-#if (HAVE_KQUEUE)
+#if (NGX_HAVE_KQUEUE)
 
     if ((ngx_event_flags & NGX_USE_KQUEUE_EVENT) && wev->pending_eof) {
         ngx_log_error(NGX_LOG_INFO, c->log, wev->kq_errno,
--- a/src/os/win32/ngx_os.h
+++ b/src/os/win32/ngx_os.h
@@ -15,18 +15,6 @@
 #define NGX_IO_SENDFILE    1
 #define NGX_IO_ZEROCOPY    2
 
-#if (HAVE_SENDFILE)
-#define NGX_HAVE_SENDFILE  NGX_IO_SENDFILE
-#else
-#define NGX_HAVE_SENDFILE  0
-#endif
-
-#if (HAVE_ZEROCOPY)
-#define NGX_HAVE_ZEROCOPY  NGX_IO_ZEROCOPY
-#else
-#define NGX_HAVE_ZEROCOPY  0
-#endif
-
 
 typedef ssize_t (*ngx_recv_pt)(ngx_connection_t *c, u_char *buf, size_t size);
 typedef ssize_t (*ngx_recv_chain_pt)(ngx_connection_t *c, ngx_chain_t *in);
--- a/src/os/win32/ngx_time.h
+++ b/src/os/win32/ngx_time.h
@@ -39,7 +39,7 @@ typedef FILETIME       ngx_mtime_t;
 
 #define ngx_msleep       Sleep
 
-#define HAVE_GETTIMEZONE  1
+#define NGX_HAVE_GETTIMEZONE  1
 
 ngx_int_t ngx_gettimezone(void);
 void ngx_gettimeofday(struct timeval *tp);
--- a/src/os/win32/ngx_win32_config.h
+++ b/src/os/win32/ngx_win32_config.h
@@ -115,37 +115,31 @@ typedef uint32_t          ngx_atomic_t;
 
 
 #define TIME_T_LEN        sizeof("-2147483648") - 1
+#define OFF_T_MAX_VALUE   9223372036854775807
+#define NGX_HAVE_LITTLE_ENDIAN  1
+
+#define NGX_THREADS       1
 
 
 #define NGX_WIN_NT        200000
 
 
-#define NGX_THREADS       1
-
-
-#ifndef HAVE_INHERITED_NONBLOCK
-#define HAVE_INHERITED_NONBLOCK  1
+#ifndef NGX_HAVE_INHERITED_NONBLOCK
+#define NGX_HAVE_INHERITED_NONBLOCK  1
 #endif
 
-#ifndef HAVE_WIN32_TRANSMITPACKETS
-#define HAVE_WIN32_TRANSMITPACKETS  1
-#define HAVE_WIN32_TRANSMITFILE     0
+#ifndef NGX_HAVE_WIN32_TRANSMITPACKETS
+#define NGX_HAVE_WIN32_TRANSMITPACKETS  1
+#define NGX_HAVE_WIN32_TRANSMITFILE     0
 #endif
 
-#ifndef HAVE_WIN32_TRANSMITFILE
-#define HAVE_WIN32_TRANSMITFILE  1
+#ifndef NGX_HAVE_WIN32_TRANSMITFILE
+#define NGX_HAVE_WIN32_TRANSMITFILE  1
 #endif
 
-#if (HAVE_WIN32_TRANSMITPACKETS) || (HAVE_WIN32_TRANSMITFILE)
-#define HAVE_SENDFILE  1
+#if (NGX_HAVE_WIN32_TRANSMITPACKETS) || (NGX_HAVE_WIN32_TRANSMITFILE)
+#define NGX_HAVE_SENDFILE  1
 #endif
 
 
-#define OFF_T_MAX_VALUE  9223372036854775807
-
-
-/* STUB */
-#define HAVE_LITTLE_ENDIAN  1
-
-
 #endif /* _NGX_WIN32_CONFIG_H_INCLUDED_ */