nginx-0.1.21-RELEASE import

    *) Bugfix: the ngx_http_stub_status_module showed incorrect statistics
       if "rtsig" method was used or if several worker process ran on SMP.

    *) Bugfix: nginx could not be built by the icc compiler on Linux or if
       the zlib-1.2.x library was building from sources.

    *) Bugfix: nginx could not be built on NetBSD 2.0.
diff --git a/auto/cc/icc b/auto/cc/icc
index 2195c10..47b91d7 100644
--- a/auto/cc/icc
+++ b/auto/cc/icc
@@ -2,7 +2,7 @@
 # Copyright (C) Igor Sysoev
 
 
-# Intel C++ compiler 7.1, 8.0
+# Intel C++ compiler 7.1, 8.0, 8.1
 
 # optimizations
 
@@ -57,7 +57,7 @@
 CFLAGS="$CFLAGS -w1"
 #CFLAGS="$CFLAGS -w2"
 
-# disable the ICC 8.0 errors:
+# disable the ICC 8.1 errors:
 #    error #181: argument is incompatible with corresponding format
 #                string conversion
 #    error #269: invalid format string conversion
diff --git a/auto/cc/name b/auto/cc/name
index cbed6a7..fb4f49a 100644
--- a/auto/cc/name
+++ b/auto/cc/name
@@ -29,7 +29,7 @@
     echo " using Borland C++ compiler"
 
 else
-if `$CC -v 2>&1 | grep '^gcc version' 2>&1 >/dev/null`; then
+if `$CC -v 2>&1 | grep 'gcc version' 2>&1 >/dev/null`; then
     NGX_CC_NAME=gcc
     echo " using GNU C compiler"
 
diff --git a/auto/install b/auto/install
index 7a26d04..558f646 100644
--- a/auto/install
+++ b/auto/install
@@ -4,38 +4,41 @@
 
 cat << END                                                    >> $NGX_MAKEFILE
 
-install:
-	test -d $NGX_PREFIX || mkdir -p $NGX_PREFIX
+install:	$NGX_OBJS${ngx_dirsep}nginx${ngx_binext}
+	test -d "$NGX_PREFIX" || mkdir -p "$NGX_PREFIX"
 
-	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 \"$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 $NGX_CONF_PATH` || mkdir -p `dirname $NGX_CONF_PATH`
+	test -d "`dirname \"$NGX_CONF_PATH\"`" \
+		|| mkdir -p "`dirname \"$NGX_CONF_PATH\"`"
 
-	cp conf/koi-win `dirname $NGX_CONF_PATH`
+	cp conf/koi-win "`dirname \"$NGX_CONF_PATH\"`"
 
-	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 "`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 $NGX_CONF_PATH || cp conf/nginx.conf $NGX_CONF_PATH
-	cp conf/nginx.conf `dirname $NGX_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 $NGX_PID_PATH` || mkdir -p `dirname $NGX_PID_PATH`
+	test -d "`dirname \"$NGX_PID_PATH\"`" \
+		|| mkdir -p "`dirname \"$NGX_PID_PATH\"`"
 
-	test -d `dirname $NGX_HTTP_LOG_PATH` || \
-		mkdir -p `dirname $NGX_HTTP_LOG_PATH`
+	test -d "`dirname \"$NGX_HTTP_LOG_PATH\"`" || \
+		mkdir -p "`dirname \"$NGX_HTTP_LOG_PATH\"`"
 
-	test -d $NGX_PREFIX/html || cp -r html $NGX_PREFIX
+	test -d "$NGX_PREFIX/html" || cp -r html "$NGX_PREFIX"
 END
 
 
 if test -n "$NGX_ERROR_LOG_PATH"; then
     cat << END                                                >> $NGX_MAKEFILE
 
-	test -d `dirname $NGX_ERROR_LOG_PATH` || \
-		mkdir -p `dirname $NGX_ERROR_LOG_PATH`
+	test -d "`dirname \"$NGX_ERROR_LOG_PATH\"`" || \
+		mkdir -p "`dirname \"$NGX_ERROR_LOG_PATH\"`"
 END
 
 fi
diff --git a/auto/lib/md5/conf b/auto/lib/md5/conf
index 1ca6b43..799d075 100644
--- a/auto/lib/md5/conf
+++ b/auto/lib/md5/conf
@@ -44,7 +44,7 @@
 
 else
 
-    if [ $NGX_PLATFORM != win32 ]; then
+    if [ "$NGX_PLATFORM" != win32 ]; then
         MD5=NO
 
         # Solaris 8/9
diff --git a/auto/lib/md5/make b/auto/lib/md5/make
index b333d4d..8bdca0b 100644
--- a/auto/lib/md5/make
+++ b/auto/lib/md5/make
@@ -25,7 +25,7 @@
 done=NO
 
 
-case $NGX_PLATFORM in
+case "$NGX_PLATFORM" in
 
     win32)
         cp auto/lib/md5/$ngx_makefile $MD5
diff --git a/auto/lib/openssl/conf b/auto/lib/openssl/conf
index 6792e7f..e0da92a 100644
--- a/auto/lib/openssl/conf
+++ b/auto/lib/openssl/conf
@@ -24,7 +24,7 @@
 
 else
 
-    if [ $NGX_PLATFORM != win32 ]; then
+    if [ "$NGX_PLATFORM" != win32 ]; then
         OPENSSL=NO
 
         ngx_feature="OpenSSL library"
diff --git a/auto/lib/openssl/make b/auto/lib/openssl/make
index 4007614..c1aec88 100644
--- a/auto/lib/openssl/make
+++ b/auto/lib/openssl/make
@@ -2,7 +2,7 @@
 # Copyright (C) Igor Sysoev
 
 
-case $NGX_PLATFORM in
+case "$NGX_PLATFORM" in
     *)
         echo "$OPENSSL/libssl.a:"                                 >> $MAKEFILE
         echo "	cd $OPENSSL \\"                                   >> $MAKEFILE
diff --git a/auto/lib/pcre/conf b/auto/lib/pcre/conf
index 168acba..6516327 100644
--- a/auto/lib/pcre/conf
+++ b/auto/lib/pcre/conf
@@ -42,7 +42,7 @@
 
 else
 
-    if [ $NGX_PLATFORM != win32 ]; then
+    if [ "$NGX_PLATFORM" != win32 ]; then
         PCRE=NO
 
         # FreeBSD PCRE port requires --with-cc-opt="-I /usr/local/include"
diff --git a/auto/lib/pcre/make b/auto/lib/pcre/make
index 27d774b..6b52357 100644
--- a/auto/lib/pcre/make
+++ b/auto/lib/pcre/make
@@ -22,7 +22,7 @@
 esac
 
 
-case $NGX_PLATFORM in
+case "$NGX_PLATFORM" in
 
     win32)
         cp auto/lib/pcre/patch.pcre.in $PCRE
diff --git a/auto/lib/zlib/conf b/auto/lib/zlib/conf
index 8edd3f3..3123c66 100644
--- a/auto/lib/zlib/conf
+++ b/auto/lib/zlib/conf
@@ -21,6 +21,7 @@
             CORE_LIBS="$CORE_LIBS $ZLIB/deflate.o"
             CORE_LIBS="$CORE_LIBS $ZLIB/trees.o"
             CORE_LIBS="$CORE_LIBS $ZLIB/zutil.o"
+            CORE_LIBS="$CORE_LIBS $ZLIB/compress.o"
 
             if [ $ZLIB_ASM != NO ]; then
                 CORE_LIBS="$CORE_LIBS $ZLIB/match.o"
@@ -37,7 +38,7 @@
 
 else
 
-    if [ $NGX_PLATFORM != win32 ]; then
+    if [ "$NGX_PLATFORM" != win32 ]; then
         ZLIB=NO
 
         # FreeBSD, Solaris, Linux
diff --git a/auto/lib/zlib/make b/auto/lib/zlib/make
index 8c1abdc..1859a34 100644
--- a/auto/lib/zlib/make
+++ b/auto/lib/zlib/make
@@ -26,7 +26,7 @@
 done=NO
 
 
-case $NGX_PLATFORM in
+case "$NGX_PLATFORM" in
 
     win32)
         cp auto/lib/zlib/$ngx_makefile $ZLIB
diff --git a/auto/lib/zlib/makefile.bcc b/auto/lib/zlib/makefile.bcc
index 95e8800..2c76424 100644
--- a/auto/lib/zlib/makefile.bcc
+++ b/auto/lib/zlib/makefile.bcc
@@ -5,7 +5,8 @@
 CFLAGS = -q -O2 -tWM $(CPU_OPT)
 
 zlib.lib:
-	bcc32 -c $(CFLAGS) adler32.c crc32.c deflate.c trees.c zutil.c
+	bcc32 -c $(CFLAGS) adler32.c crc32.c deflate.c trees.c zutil.c \
+		compress.c
 
 	tlib zlib.lib +adler32.obj +crc32.obj +deflate.obj \
-		+trees.obj +zutil.obj
+		+trees.obj +zutil.obj +compress.obj
diff --git a/auto/lib/zlib/makefile.msvc b/auto/lib/zlib/makefile.msvc
index 304b986..a4ee89a 100644
--- a/auto/lib/zlib/makefile.msvc
+++ b/auto/lib/zlib/makefile.msvc
@@ -5,7 +5,7 @@
 CFLAGS = -nologo -O2 -Ob1 -Oi -Gs $(LIBC) $(CPU_OPT)
 
 zlib.lib:
-	cl -c $(CFLAGS) adler32.c crc32.c deflate.c trees.c zutil.c
+	cl -c $(CFLAGS) adler32.c crc32.c deflate.c trees.c zutil.c compress.c
 
 	link -lib -out:zlib.lib adler32.obj crc32.obj deflate.obj \
-		trees.obj zutil.obj
+		trees.obj zutil.obj compress.obj
diff --git a/auto/lib/zlib/makefile.owc b/auto/lib/zlib/makefile.owc
index 71ba512..dac4365 100644
--- a/auto/lib/zlib/makefile.owc
+++ b/auto/lib/zlib/makefile.owc
@@ -5,5 +5,5 @@
 CFLAGS = -zq -bt=nt -ot -op -oi -oe -s -bm $(CPU_OPT)
 
 zlib.lib:
-	wcl386 -c $(CFLAGS) adler32.c crc32.c deflate.c trees.c zutil.c
-	wlib -n zlib.lib adler32.obj crc32.obj deflate.obj trees.obj zutil.obj
+	wcl386 -c $(CFLAGS) adler32.c crc32.c deflate.c trees.c zutil.c compress.c
+	wlib -n zlib.lib adler32.obj crc32.obj deflate.obj trees.obj zutil.obj compress.obj
diff --git a/auto/os/conf b/auto/os/conf
index 7375199..8c4739f 100644
--- a/auto/os/conf
+++ b/auto/os/conf
@@ -12,11 +12,12 @@
     echo " + $NGX_SYSTEM $NGX_RELEASE $NGX_MACHINE"
 
     NGX_PLATFORM="$NGX_SYSTEM:$NGX_RELEASE:$NGX_MACHINE";
+
 else
     echo "building for $NGX_PLATFORM"
 fi
 
-case $NGX_PLATFORM in
+case "$NGX_PLATFORM" in
 
     FreeBSD:* | DragonFly:*)
         . auto/os/freebsd
@@ -43,7 +44,7 @@
 esac
 
 
-case $NGX_MACHINE in
+case "$NGX_MACHINE" in
 
      i386|i686|i86pc|amd64)
          have=NGX_HAVE_NONALIGNED . auto/have
@@ -52,7 +53,7 @@
 esac
 
 
-if [ $NGX_PLATFORM != win32 ]; then
+if [ "$NGX_PLATFORM" != win32 ]; then
 
      NGX_USER=${NGX_USER:-nobody}
 
@@ -77,6 +78,24 @@
     fi
 
 
+    ngx_feature="poll()"
+    ngx_feature_name=
+    ngx_feature_run=no
+    ngx_feature_incs="#include <poll.h>"
+    ngx_feature_libs=
+    ngx_feature_test="int  n, dp; struct pollfd  pl;
+                      dp = 0;
+                      pl.fd = 0;
+                      pl.events = 0;
+                      pl.revents = 0;
+                      n = poll(&pl, 1, 0)"
+    . auto/feature
+
+    if [ $ngx_found = no ]; then
+        EVENT_POLL=NONE
+    fi
+
+
     ngx_feature="/dev/poll"
     ngx_feature_name="NGX_HAVE_DEVPOLL"
     ngx_feature_run=no
@@ -124,14 +143,22 @@
         fi
     fi
 
-    if [ NGX_SYSTEM != "NetBSD" ]; then
+    if [ "$NGX_SYSTEM" = "NetBSD" ]; then
 
         # NetBSD 2.0 incompatibly defines kevent.udata as "intptr_t"
+
+        cat << END >> $NGX_AUTO_CONFIG_H
+
+#define NGX_KQUEUE_UDATA_T
+
+END
+
+    else
         cat << END >> $NGX_AUTO_CONFIG_H
 
 #define NGX_KQUEUE_UDATA_T  (void *)
 
 END
 
-     fi
+    fi
 fi
diff --git a/auto/os/linux b/auto/os/linux
index 8c140b3..a83c180 100644
--- a/auto/os/linux
+++ b/auto/os/linux
@@ -18,7 +18,7 @@
 ngx_spacer='
 '
 
-CC_AUX_FLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
+CC_AUX_FLAGS="$CC_AUX_FLAGS -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
 
 
 # Linux kernel version
diff --git a/auto/os/solaris b/auto/os/solaris
index 723ad84..2348c89 100644
--- a/auto/os/solaris
+++ b/auto/os/solaris
@@ -20,10 +20,10 @@
 # Solaris's make does not support a blank line between target and rules
 ngx_spacer=
 
-CC_AUX_FLAGS="-D_FILE_OFFSET_BITS=64 -lrt"
+CC_AUX_FLAGS="$CC_AUX_FLAGS -D_FILE_OFFSET_BITS=64 -lrt"
 
 
-case $NGX_PLATFORM in
+case "$NGX_PLATFORM" in
 
     *:sun4u)
         # "-mcpu=v9" enables the "casa" assembler instruction
diff --git a/auto/summary b/auto/summary
index 243d6a3..4848c22 100644
--- a/auto/summary
+++ b/auto/summary
@@ -118,22 +118,22 @@
 
 
 cat << END
-  nginx path prefix: $NGX_PREFIX
-  nginx binary file: $NGX_SBIN_PATH
-  nginx configuration file: $NGX_CONF_PATH
-  nginx pid file: $NGX_PID_PATH
+  nginx path prefix: "$NGX_PREFIX"
+  nginx binary file: "$NGX_SBIN_PATH"
+  nginx configuration file: "$NGX_CONF_PATH"
+  nginx pid file: "$NGX_PID_PATH"
 END
 
 if test -n "$NGX_ERROR_LOG_PATH"; then
-    echo "  nginx error log file: $NGX_ERROR_LOG_PATH"
+    echo "  nginx error log file: \"$NGX_ERROR_LOG_PATH\""
 else
     echo "  nginx logs errors to stderr"
 fi
 
 cat << END
-  nginx http access log file: $NGX_HTTP_LOG_PATH
-  nginx http client request body temporary files: $NGX_HTTP_CLIENT_TEMP_PATH
-  nginx http proxy temporary files: $NGX_HTTP_PROXY_TEMP_PATH
-  nginx http fastcgi temporary files: $NGX_HTTP_FASTCGI_TEMP_PATH
+  nginx http access log file: "$NGX_HTTP_LOG_PATH"
+  nginx http client request body temporary files: "$NGX_HTTP_CLIENT_TEMP_PATH"
+  nginx http proxy temporary files: "$NGX_HTTP_PROXY_TEMP_PATH"
+  nginx http fastcgi temporary files: "$NGX_HTTP_FASTCGI_TEMP_PATH"
 
 END
diff --git a/auto/threads b/auto/threads
index da03036..d72614b 100644
--- a/auto/threads
+++ b/auto/threads
@@ -9,7 +9,7 @@
         CORE_DEPS="$CORE_DEPS $FREEBSD_RFORK_DEPS"
         CORE_SRCS="$CORE_SRCS $FREEBSD_RFORK_SRCS"
 
-        case $NGX_PLATFORM in
+        case "$NGX_PLATFORM" in
             *:i386)
                 if [ \( $version -gt 500000 -a $version -lt 501000 \) \
                      -o $version -lt 491000 ]
@@ -42,7 +42,7 @@
     ;;
 
     libc_r)
-        case $NGX_PLATFORM in
+        case "$NGX_PLATFORM" in
             FreeBSD:[34]*)
                 have=NGX_THREADS . auto/have
                 CFLAGS="$CFLAGS -pthread"
diff --git a/auto/unix b/auto/unix
index 406f2a2..112626d 100755
--- a/auto/unix
+++ b/auto/unix
@@ -5,23 +5,21 @@
 have=NGX_HAVE_UNIX_DOMAIN . auto/have
 
 
+# STUB
 CC_WARN=
 ngx_fmt_collect=yes
 
+
 # C types
 
 ngx_type="int"; . auto/types/sizeof
-#ngx_formats="%d"; . auto/fmt/fmt
 
 ngx_type="long"; . auto/types/sizeof
-#ngx_formats="%ld"; . auto/fmt/fmt
 
 ngx_type="long long"; . auto/types/sizeof
-#ngx_formats="%lld %qd"; . auto/fmt/fmt
 
 ngx_type="void *"; . auto/types/sizeof; ngx_ptr_size=$ngx_size
-#ngx_fmt_name=PTR_FMT;
-#eval ngx_formats=\${ngx_${ngx_ptr_size}_fmt}; . auto/fmt/ptrfmt
+ngx_param=NGX_PTR_SIZE; ngx_value=$ngx_size; . auto/types/value
 
 
 # POSIX types