]> git.kaiwu.me - nginx.git/commitdiff
nginx-0.1.21-RELEASE import release-0.1.21
authorIgor Sysoev <igor@sysoev.ru>
Tue, 22 Feb 2005 14:40:13 +0000 (14:40 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 22 Feb 2005 14:40:13 +0000 (14:40 +0000)
    *) 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.

54 files changed:
auto/cc/icc
auto/cc/name
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/lib/zlib/makefile.bcc
auto/lib/zlib/makefile.msvc
auto/lib/zlib/makefile.owc
auto/os/conf
auto/os/linux
auto/os/solaris
auto/summary
auto/threads
auto/unix
conf/nginx.conf
docs/xml/nginx/changes.xml
src/core/nginx.h
src/core/ngx_connection.h
src/core/ngx_file.c
src/core/ngx_file.h
src/core/ngx_log.c
src/core/ngx_log.h
src/core/ngx_radix_tree.c
src/core/ngx_rbtree.c
src/core/ngx_rbtree.h
src/core/ngx_spinlock.c
src/core/ngx_string.c
src/core/ngx_string.h
src/event/modules/ngx_rtsig_module.c
src/event/ngx_event.c
src/event/ngx_event_accept.c
src/event/ngx_event_timer.c
src/event/ngx_event_timer.h
src/http/modules/ngx_http_range_filter.c
src/http/modules/ngx_http_stub_status_module.c
src/http/ngx_http_header_filter.c
src/http/ngx_http_log_handler.c
src/http/ngx_http_request.c
src/os/unix/ngx_atomic.h
src/os/unix/ngx_freebsd.h
src/os/unix/ngx_linux.h
src/os/unix/ngx_linux_init.c
src/os/unix/ngx_os.h
src/os/unix/ngx_process.h
src/os/unix/ngx_setproctitle.c
src/os/unix/ngx_solaris.h
src/os/win32/ngx_atomic.h
src/os/win32/ngx_win32_config.h

index 2195c10db84ab1c2cad22501f19fd69aaa3dd3d7..47b91d781e37f046a5cb7868d135cb854910d749 100644 (file)
@@ -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 @@ fi
 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
index cbed6a741e62e28e20c0de69cd5391887851bdf2..fb4f49aaf20e457ee8fc3c5ecda9af7a0b336573 100644 (file)
@@ -29,7 +29,7 @@ if [ $CC = bcc32 ]; then
     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"
 
index 7a26d040d36bb838063a4271569d39962e26a11b..558f64626018d10370f955fa2e3c46216875bb61 100644 (file)
@@ -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
index 1ca6b431709059f03e1f454f4c6086b4dca6e7be..799d0756f7c795df0e805a88beab108c86d1a5ab 100644 (file)
@@ -44,7 +44,7 @@ if [ $MD5 != NONE ]; then
 
 else
 
-    if [ $NGX_PLATFORM != win32 ]; then
+    if [ "$NGX_PLATFORM" != win32 ]; then
         MD5=NO
 
         # Solaris 8/9
index b333d4dfe8bf039f5c762a5ec16bc200057d5fae..8bdca0b508fd47776ea1075fbc89558717f72cda 100644 (file)
@@ -25,7 +25,7 @@ esac
 done=NO
 
 
-case $NGX_PLATFORM in
+case "$NGX_PLATFORM" in
 
     win32)
         cp auto/lib/md5/$ngx_makefile $MD5
index 6792e7fd2233430eab80f047c6342f95249e5870..e0da92a2b4d6aab164d828581cb31fe919651c41 100644 (file)
@@ -24,7 +24,7 @@ if [ $OPENSSL != NONE ]; then
 
 else
 
-    if [ $NGX_PLATFORM != win32 ]; then
+    if [ "$NGX_PLATFORM" != win32 ]; then
         OPENSSL=NO
 
         ngx_feature="OpenSSL library"
index 4007614129066ffa91227f7d7600bb296a4362f3..c1aec882a01441a9f793afa9adbc0bb082f9a663 100644 (file)
@@ -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
index 168acbaa22525c9ecb48477e879ff23d5dc8bd96..65163272a3a2128f033a0470ade9a2ebb6f60830 100644 (file)
@@ -42,7 +42,7 @@ if [ $PCRE != NONE ]; then
 
 else
 
-    if [ $NGX_PLATFORM != win32 ]; then
+    if [ "$NGX_PLATFORM" != win32 ]; then
         PCRE=NO
 
         # FreeBSD PCRE port requires --with-cc-opt="-I /usr/local/include"
index 27d774bb52aa0a97297193f2c575aff156e4fdca..6b5235704dfbf92dc06518d84b2d306b777c5d8c 100644 (file)
@@ -22,7 +22,7 @@ case "$NGX_CC_NAME" in
 esac
 
 
-case $NGX_PLATFORM in
+case "$NGX_PLATFORM" in
 
     win32)
         cp auto/lib/pcre/patch.pcre.in $PCRE
index 8edd3f371e0a7a404c10b22bed3ab00e355261ce..3123c669a517de0b261615a8d6259a9b01653641 100644 (file)
@@ -21,6 +21,7 @@ if [ $ZLIB != NONE ]; then
             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 @@ if [ $ZLIB != NONE ]; then
 
 else
 
-    if [ $NGX_PLATFORM != win32 ]; then
+    if [ "$NGX_PLATFORM" != win32 ]; then
         ZLIB=NO
 
         # FreeBSD, Solaris, Linux
index 8c1abdc44387e75c07738b0bab2f4bf6c175f7ac..1859a34b871bbb26b4de67be91a34126f1b246e4 100644 (file)
@@ -26,7 +26,7 @@ esac
 done=NO
 
 
-case $NGX_PLATFORM in
+case "$NGX_PLATFORM" in
 
     win32)
         cp auto/lib/zlib/$ngx_makefile $ZLIB
index 95e8800ad6d527b2a11c3b00989865190413f0a3..2c764242c8e2d6422946af6d3bc18bf4266429a6 100644 (file)
@@ -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
index 304b986cdf5495dafc15af6a0e7e3895f17df091..a4ee89a9ca389bb5f155c82cb8565828502e92d2 100644 (file)
@@ -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
index 71ba512dc0aa3f57bd8f34035429c80d50519d84..dac43655fed9e876acf9cd1f7cd6fb1099a90f21 100644 (file)
@@ -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
index 737519938960eaeee3e9aa2a7296d24505d96f77..8c4739fbf15b2b79966dd58bd92b4463ccf2e076 100644 (file)
@@ -12,11 +12,12 @@ if test -z "$NGX_PLATFORM"; then
     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 @@ case $NGX_PLATFORM in
 esac
 
 
-case $NGX_MACHINE in
+case "$NGX_MACHINE" in
 
      i386|i686|i86pc|amd64)
          have=NGX_HAVE_NONALIGNED . auto/have
@@ -52,7 +53,7 @@ case $NGX_MACHINE in
 esac
 
 
-if [ $NGX_PLATFORM != win32 ]; then
+if [ "$NGX_PLATFORM" != win32 ]; then
 
      NGX_USER=${NGX_USER:-nobody}
 
@@ -77,6 +78,24 @@ if [ $NGX_PLATFORM != win32 ]; then
     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 @@ if [ $NGX_PLATFORM != win32 ]; then
         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
index 8c140b38875fd0a591c079545fe3f385795e00a1..a83c1803b3c19682359ce00548ae5c195159d4f7 100644 (file)
@@ -18,7 +18,7 @@ EVENT_MODULES="$EVENT_MODULES"
 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
index 723ad84c3b2d14f88bdac3f6e8c36d020eefa9b5..2348c8985f11530499c4828f20a1944855ecdc40 100644 (file)
@@ -20,10 +20,10 @@ CORE_LIBS="$CORE_LIBS -lsocket -lnsl -lrt"
 # 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
index 243d6a362e78fe08143c30ef4cd05131e88a0d55..4848c225f004a0c98b74aa983dc350aee641a1e9 100644 (file)
@@ -118,22 +118,22 @@ fi
 
 
 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
index da030369afbccfbcfc09155d0ab9cdb5282d644e..d72614b21329e65ea319cff85660b0e6e8de1207 100644 (file)
@@ -9,7 +9,7 @@ case $USE_THREADS in
         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 @@ case $USE_THREADS in
     ;;
 
     libc_r)
-        case $NGX_PLATFORM in
+        case "$NGX_PLATFORM" in
             FreeBSD:[34]*)
                 have=NGX_THREADS . auto/have
                 CFLAGS="$CFLAGS -pthread"
index 406f2a23f578953d1f31ab0a637f0edb14130767..112626d2fabcc5a4686b4a54e7ffd8f430fcfcb2 100755 (executable)
--- 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
index d482550335c4d56a8bcd20d0ccb7f0d23e6760cd..441fd0cfed10dacf422eeb0cab8cee396acc661e 100644 (file)
@@ -15,7 +15,10 @@ http {
     include       conf/mime.types;
     default_type  application/octet-stream;
 
-    sendfile  on;
+    sendfile        on;
+    # tcp_nodelay   on;
+
+    # keepalive_timeout  0;
 
     #gzip  on;
 
index 9dfa672c66c80f5cda648e9c15d9b292d48cfc51..f6716c1546988c0065d6a82101f11e4071455ada 100644 (file)
@@ -9,6 +9,43 @@
 <title lang="en">nginx changelog</title>
 
 
+<changes ver="0.1.21" date="22.02.2005">
+
+<change type="bugfix">
+<para lang="ru">
+ÍÏÄÕÌØ ngx_http_stub_status_module ÐÏËÁÚÙ×ÁÌ ÎÅ×ÅÒÎÕÀ ÓÔÁÔÉÓÔÉËÕ
+ÐÒÉ ÉÓÐÏÌØÚÏ×ÁÎÉÉ ÍÅÔÏÄÁ rtsig ÉÌÉ ÐÒÉ ÉÓÐÏÌØÚÏ×ÁÎÉÉ ÎÅÓËÏÌØËÉÈ
+ÒÁÂÏÞÉÈ ÐÒÏÃÅÓÓÏ× ÎÁ SMP ÍÁÛÉÎÅ.
+</para>
+<para lang="en">
+the ngx_http_stub_status_module showed incorrect statictics
+if "rtsig" method was used or if several worker process ran on SMP.
+</para>
+</change>
+
+<change type="bugfix">
+<para lang="ru">
+nginx ÎÅ ÓÏÂÉÒÁÌÓÑ ËÏÍÐÉÌÑÔÏÒÏÍ icc ÐÏÄ ìÉÎÕËÓÏÍ ÉÌÉ
+ÅÓÌÉ ÂÉÂÌÉÏÔÅËÁ zlib-1.2.x ÓÏÂÉÒÁÌÁÓØ ÉÚ ÉÓÈÏÄÎÙÈ ÔÅËÓÔÏ×.
+</para>
+<para lang="en">
+nginx could not be built by the icc compiler on Linux or
+if the zlib-1.2.x library was building from sources.
+</para>
+</change>
+
+<change type="bugfix">
+<para lang="ru">
+nginx ÎÅ ÓÏÂÉÒÁÌÓÑ ÐÏÄ NetBSD 2.0.
+</para>
+<para lang="en">
+nginx could not be built on NetBSD 2.0.
+</para>
+</change>
+
+</changes>
+
+
 <changes ver="0.1.20" date="17.02.2005">
 
 <change type="feature">
index 0e7508350918396484aff1fe9847a5921e96afc2..5c412078673a9894e2e3333dd299e280344f4799 100644 (file)
@@ -8,7 +8,7 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define NGINX_VER          "nginx/0.1.20"
+#define NGINX_VER          "nginx/0.1.21"
 
 #define NGINX_VAR          "NGINX"
 #define NGX_NEWPID_EXT     ".newbin"
index 5479faaaf942d24d808c26a4c72df6ee3db983fd..4d5d0c8d964d60ce459d4a542c516737c438db81 100644 (file)
@@ -114,7 +114,7 @@ struct ngx_connection_s {
 
     ngx_buf_t          *buffer;
 
-    ngx_uint_t          number;
+    ngx_atomic_int_t    number;
 
     unsigned            log_error:2;     /* ngx_connection_log_error_e */
 
index cc03d79cdba94b0bb1549dc1bb9bbd4d9d7793dd..e06b8ca2de0886234adb818479c81389d37a1272 100644 (file)
@@ -8,11 +8,12 @@
 #include <ngx_core.h>
 
 
-static ngx_uint_t ngx_temp_number;
-static ngx_uint_t ngx_random;
+static ngx_atomic_int_t  ngx_temp_number;
+static ngx_atomic_int_t  ngx_random;
 
 
-ssize_t ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain)
+ssize_t
+ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain)
 {
     ngx_int_t  rc;
 
@@ -33,13 +34,14 @@ ssize_t ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain)
 }
 
 
-ngx_int_t ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
-                               ngx_pool_t *pool, int persistent)
+ngx_int_t
+ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path, ngx_pool_t *pool,
+    int persistent)
 {
-    ngx_err_t   err;
-    uint32_t    num;
+    ngx_err_t          err;
+    ngx_atomic_int_t   n;
 
-    file->name.len = path->name.len + 1 + path->len + 10;
+    file->name.len = path->name.len + 1 + path->len + NGX_ATOMIC_T_LEN;
 
     if (!(file->name.data = ngx_palloc(pool, file->name.len + 1))) {
         return NGX_ERROR;
@@ -53,11 +55,11 @@ ngx_int_t ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
 
     ngx_memcpy(file->name.data, path->name.data, path->name.len);
 
-    num = (uint32_t) ngx_next_temp_number(0);
+    n = ngx_next_temp_number(0);
 
     for ( ;; ) {
         ngx_sprintf(file->name.data + path->name.len + 1 + path->len,
-                    "%010ui%Z", num);
+                    "%0muA%Z", n);
 
         ngx_create_hashed_filename(file, path);
 
@@ -77,7 +79,7 @@ ngx_int_t ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
         err = ngx_errno;
 
         if (err == NGX_EEXIST) {
-            num = ngx_next_temp_number(1);
+            n = ngx_next_temp_number(1);
             continue;
         }
 
@@ -101,7 +103,8 @@ ngx_int_t ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
 }
 
 
-void ngx_create_hashed_filename(ngx_file_t *file, ngx_path_t *path)
+void
+ngx_create_hashed_filename(ngx_file_t *file, ngx_path_t *path)
 {
     ngx_uint_t  i, name, pos, level;
 
@@ -128,7 +131,8 @@ void ngx_create_hashed_filename(ngx_file_t *file, ngx_path_t *path)
 }
 
 
-ngx_int_t ngx_create_path(ngx_file_t *file, ngx_path_t *path)
+ngx_int_t
+ngx_create_path(ngx_file_t *file, ngx_path_t *path)
 {
     int        i, pos;
     ngx_err_t  err;
@@ -164,19 +168,16 @@ ngx_int_t ngx_create_path(ngx_file_t *file, ngx_path_t *path)
 }
 
 
-void ngx_init_temp_number()
+void
+ngx_init_temp_number()
 {
-    ngx_random = 0;
-
-    ngx_temp_number = ngx_random;
-
-    while (ngx_random < 10000) {
-        ngx_random = 123456;
-    }
+    ngx_temp_number = 0;
+    ngx_random = 123456;
 }
 
 
-ngx_uint_t ngx_next_temp_number(ngx_uint_t collision)
+ngx_atomic_int_t
+ngx_next_temp_number(ngx_uint_t collision)
 {
     if (collision) {
         ngx_temp_number += ngx_random;
@@ -186,7 +187,8 @@ ngx_uint_t ngx_next_temp_number(ngx_uint_t collision)
 }
 
 
-char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+char *
+ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 {
     char  *p = conf;
 
@@ -237,7 +239,8 @@ char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 }
 
 
-ngx_int_t ngx_add_path(ngx_conf_t *cf, ngx_path_t **slot)
+ngx_int_t
+ngx_add_path(ngx_conf_t *cf, ngx_path_t **slot)
 {
     ngx_uint_t   i, n;
     ngx_path_t  *path, **p;
@@ -299,7 +302,8 @@ ngx_int_t ngx_add_path(ngx_conf_t *cf, ngx_path_t **slot)
 }
 
 
-ngx_int_t ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user)
+ngx_int_t
+ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user)
 {
     ngx_err_t         err;
     ngx_uint_t        i;
index bc64ed8e94aaa7cfe4fbb73880b0d3b140edbdec..a76a64877840da9de7886defce988efaecd23f20 100644 (file)
@@ -55,14 +55,14 @@ typedef struct {
 
 ssize_t ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain);
 ngx_int_t ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
-                               ngx_pool_t *pool, int persistent);
+    ngx_pool_t *pool, int persistent);
 void ngx_create_hashed_filename(ngx_file_t *file, ngx_path_t *path);
 ngx_int_t ngx_create_path(ngx_file_t *file, ngx_path_t *path);
 ngx_int_t ngx_add_path(ngx_conf_t *cf, ngx_path_t **slot);
 ngx_int_t ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user);
 
 void ngx_init_temp_number();
-ngx_uint_t ngx_next_temp_number(ngx_uint_t collision);
+ngx_atomic_int_t ngx_next_temp_number(ngx_uint_t collision);
 
 char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
 
index d9c5c59bc234d9fe7fca36a9d8a7b39e1865be1a..58894e91574b2af10f3d06f3418b12fdc0bb25c6 100644 (file)
@@ -87,15 +87,9 @@ void ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
     p = ngx_sprintf(p, "%P#" NGX_TID_T_FMT ": ", ngx_log_pid, ngx_log_tid);
 
     if (log->connection) {
-        p = ngx_sprintf(p, "*%ui ", log->connection);
+        p = ngx_sprintf(p, "*%uA ", log->connection);
     }
 
-#if 0
-    if (log->data && *(int *) log->data != -1) {
-        p = ngx_sprintf(p, "*%ud ", *(u_int *) log->data);
-    }
-#endif
-
 #if (NGX_HAVE_VARIADIC_MACROS)
 
     va_start(args, fmt);
index 588837fff72858f28394c057d7d8fbbb3ff5b0b6..95dfe41545866c4287686e854c4c560580eea8bd 100644 (file)
@@ -47,7 +47,7 @@ struct ngx_log_s {
     ngx_uint_t           log_level;
     ngx_open_file_t     *file;
 
-    ngx_uint_t           connection;
+    ngx_atomic_int_t     connection;
 
     ngx_log_handler_pt   handler;
     void                *data;
index fa056afe31445298aded17ef404c167943b55a9f..202421906e50968170848d26c903565d120fd91d 100644 (file)
@@ -40,8 +40,8 @@ ngx_radix_tree_create(ngx_pool_t *pool, ngx_int_t preallocate)
     }
 
     /*
-     * We preallocate the first nodes: 0, 1, 00, 01, 10, 11, 000, 001, etc.,
-     * to increase the TLB hits even if for the first lookup iterations.
+     * The preallocation the first nodes: 0, 1, 00, 01, 10, 11, 000, 001, etc.
+     * increases the TLB hits even if for the first lookup iterations.
      * On the 32-bit platforms the 7 preallocated bits takes continuous 4K,
      * 8 - 8K, 9 - 16K, etc.  On the 64-bit platforms the 6 preallocated bits
      * takes continuous 4K, 7 - 8K, 8 - 16K, etc.  There is no sense to
index ef572895a4defbdfbb2cda8f7a3a341929258dc5..d3bb3a57310d8870c8f5c8df4c3cb3046696396d 100644 (file)
 
 
 static ngx_inline void ngx_rbtree_left_rotate(ngx_rbtree_t **root,
-                                              ngx_rbtree_t *sentinel,
-                                              ngx_rbtree_t *node);
+    ngx_rbtree_t *sentinel, ngx_rbtree_t *node);
 static ngx_inline void ngx_rbtree_right_rotate(ngx_rbtree_t **root,
-                                               ngx_rbtree_t *sentinel,
-                                               ngx_rbtree_t *node);
+    ngx_rbtree_t *sentinel, ngx_rbtree_t *node);
 
 
-void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
-                       ngx_rbtree_t *node)
+void
+ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
+    ngx_rbtree_t *node)
 {
     ngx_rbtree_t  *temp;
 
@@ -125,8 +124,9 @@ void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
 }
 
 
-void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
-                       ngx_rbtree_t *node)
+void
+ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
+    ngx_rbtree_t *node)
 {
     ngx_int_t      is_red;
     ngx_rbtree_t  *subst, *temp, *w;
@@ -289,9 +289,9 @@ void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
 }
 
 
-static ngx_inline void ngx_rbtree_left_rotate(ngx_rbtree_t **root,
-                                              ngx_rbtree_t *sentinel,
-                                              ngx_rbtree_t *node)
+static ngx_inline void
+ngx_rbtree_left_rotate(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
+    ngx_rbtree_t *node)
 {
     ngx_rbtree_t  *temp;
 
@@ -319,9 +319,9 @@ static ngx_inline void ngx_rbtree_left_rotate(ngx_rbtree_t **root,
 }
 
 
-static ngx_inline void ngx_rbtree_right_rotate(ngx_rbtree_t **root,
-                                               ngx_rbtree_t *sentinel,
-                                               ngx_rbtree_t *node)
+static ngx_inline void
+ngx_rbtree_right_rotate(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
+    ngx_rbtree_t *node)
 {
     ngx_rbtree_t  *temp;
 
index d876ec04c62c924e887b65b7af244d3e4fccbd2b..c8b7092ff5abddddf0183e2c2f5a4be1aa49e821 100644 (file)
@@ -24,13 +24,13 @@ struct ngx_rbtree_s {
 
 
 void ngx_rbtree_insert(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
-                       ngx_rbtree_t *node);
+    ngx_rbtree_t *node);
 void ngx_rbtree_delete(ngx_rbtree_t **root, ngx_rbtree_t *sentinel,
-                       ngx_rbtree_t *node);
+    ngx_rbtree_t *node);
 
 
-static ngx_inline ngx_rbtree_t *ngx_rbtree_min(ngx_rbtree_t *node,
-                                               ngx_rbtree_t *sentinel)
+static ngx_inline ngx_rbtree_t *
+ngx_rbtree_min(ngx_rbtree_t *node, ngx_rbtree_t *sentinel)
 {
    while (node->left != sentinel) {
        node = node->left;
index dfa7da4112086b367f87c921626d15bae21d629b..00e7fca7d12ed80d01224768db10639e54cd1ef5 100644 (file)
@@ -8,6 +8,10 @@
 #include <ngx_core.h>
 
 
+/*
+ * TODO: the P4 optimized assembler version with the "pause" operation
+ */
+
 void ngx_spinlock(ngx_atomic_t *lock, ngx_uint_t spin)
 {
 
index d63a238505813ede829958bd40b34118b7b243b5..ca9d669c529b77e97a783de1f30371d8df94249b 100644 (file)
@@ -8,7 +8,8 @@
 #include <ngx_core.h>
 
 
-u_char *ngx_cpystrn(u_char *dst, u_char *src, size_t n)
+u_char *
+ngx_cpystrn(u_char *dst, u_char *src, size_t n)
 {
     if (n == 0) {
         return dst;
@@ -28,7 +29,8 @@ u_char *ngx_cpystrn(u_char *dst, u_char *src, size_t n)
 }
 
 
-u_char *ngx_pstrdup(ngx_pool_t *pool, ngx_str_t *src)
+u_char *
+ngx_pstrdup(ngx_pool_t *pool, ngx_str_t *src)
 {
     u_char  *dst;
 
@@ -52,6 +54,7 @@ u_char *ngx_pstrdup(ngx_pool_t *pool, ngx_str_t *src)
  *    %[0][width|m][u][x|X]i    ngx_int_t/ngx_uint_t
  *    %[0][width][u][x|X]D      int32_t/uint32_t
  *    %[0][width][u][x|X]L      int64_t/uint64_t
+ *    %[0][width|m][u][x|X]A    ngx_atomic_int_t
  *    %P                        ngx_pid_t
  *    %r                        rlim_t
  *    %p                        pointer
@@ -63,7 +66,6 @@ u_char *ngx_pstrdup(ngx_pool_t *pool, ngx_str_t *src)
  *
  *  TODO:
  *    %M                        ngx_msec_t
- *    %A                        ngx_atomic_t
  *
  *  reserved:
  *    %t                        ptrdiff_t
@@ -72,7 +74,8 @@ u_char *ngx_pstrdup(ngx_pool_t *pool, ngx_str_t *src)
  */
 
 
-u_char *ngx_sprintf(u_char *buf, const char *fmt, ...)
+u_char *
+ngx_sprintf(u_char *buf, const char *fmt, ...)
 {
     u_char   *p;
     va_list   args;
@@ -85,7 +88,8 @@ u_char *ngx_sprintf(u_char *buf, const char *fmt, ...)
 }
 
 
-u_char *ngx_snprintf(u_char *buf, size_t max, const char *fmt, ...)
+u_char *
+ngx_snprintf(u_char *buf, size_t max, const char *fmt, ...)
 {
     u_char   *p;
     va_list   args;
@@ -98,12 +102,13 @@ u_char *ngx_snprintf(u_char *buf, size_t max, const char *fmt, ...)
 }
 
 
-u_char *ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args)
+u_char *
+ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args)
 {
     u_char         *p, zero, *last, temp[NGX_INT64_LEN + 1];
                                     /*
                                      * really we need temp[NGX_INT64_LEN] only,
-                                     * but icc shows the warning
+                                     * but icc issues the warning
                                      */
     int             d;
     size_t          len;
@@ -111,7 +116,7 @@ u_char *ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args)
     int64_t         i64;
     uint64_t        ui64;
     ngx_str_t      *s;
-    ngx_uint_t      width, sign, hexadecimal;
+    ngx_uint_t      width, sign, hexadecimal, max_width;
     static u_char   hex[] = "0123456789abcdef";
     static u_char   HEX[] = "0123456789ABCDEF";
 
@@ -137,6 +142,7 @@ u_char *ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args)
             width = 0;
             sign = 1;
             hexadecimal = 0;
+            max_width = 0;
 
             p = temp + NGX_INT64_LEN;
 
@@ -154,7 +160,7 @@ u_char *ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args)
                     continue;
 
                 case 'm':
-                    width = NGX_INT_T_LEN;
+                    max_width = 1;
                     fmt++;
                     continue;
 
@@ -228,6 +234,11 @@ u_char *ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args)
                 } else {
                     ui64 = (uint64_t) va_arg(args, ngx_uint_t);
                 }
+
+                if (max_width) {
+                    width = NGX_INT_T_LEN;
+                }
+
                 break;
 
             case 'd':
@@ -262,6 +273,19 @@ u_char *ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args)
                 }
                 break;
 
+            case 'A':
+                if (sign) {
+                    i64 = (int64_t) va_arg(args, ngx_atomic_int_t);
+                } else {
+                    ui64 = (uint64_t) va_arg(args, ngx_atomic_int_t);
+                }
+
+                if (max_width) {
+                    width = NGX_ATOMIC_T_LEN;
+                }
+
+                break;
+
 #if !(NGX_WIN32)
             case 'r':
                 i64 = (int64_t) va_arg(args, rlim_t);
@@ -334,13 +358,15 @@ u_char *ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args)
                  * To divide 64-bit number and to find the remainder
                  * on the x86 platform gcc and icc call the libc functions
                  * [u]divdi3() and [u]moddi3(), they call another function
-                 * in return.  On FreeBSD it is the qdivrem() function,
+                 * in its turn.  On FreeBSD it is the qdivrem() function,
                  * its source code is about 170 lines of the code.
                  * The glibc counterpart is about 150 lines of the code.
                  *
-                 * For 32-bit numbers gcc and icc use the inlined
-                 * multiplication and shifts.  For example, unsigned
-                 * "i32 / 10" is compiled to "(i32 * 0xCCCCCCCD) >> 35".
+                 * For 32-bit numbers and some divisors gcc and icc use
+                 * the inlined multiplication and shifts.  For example,
+                 * unsigned "i32 / 10" is compiled to
+                 *
+                 *     (i32 * 0xCCCCCCCD) >> 35
                  */
 
                 ui32 = (uint32_t) ui64;
@@ -379,7 +405,8 @@ u_char *ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args)
 }
 
 
-ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n)
+ngx_int_t
+ngx_rstrncmp(u_char *s1, u_char *s2, size_t n)
 {
     if (n == 0) {
         return 0;
@@ -401,7 +428,8 @@ ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n)
 }
 
 
-ngx_int_t ngx_rstrncasecmp(u_char *s1, u_char *s2, size_t n)
+ngx_int_t
+ngx_rstrncasecmp(u_char *s1, u_char *s2, size_t n)
 {
     u_char  c1, c2;
 
@@ -435,7 +463,8 @@ ngx_int_t ngx_rstrncasecmp(u_char *s1, u_char *s2, size_t n)
 }
 
 
-ngx_int_t ngx_atoi(u_char *line, size_t n)
+ngx_int_t
+ngx_atoi(u_char *line, size_t n)
 {
     ngx_int_t  value;
 
@@ -460,7 +489,8 @@ ngx_int_t ngx_atoi(u_char *line, size_t n)
 }
 
 
-ngx_int_t ngx_hextoi(u_char *line, size_t n)
+ngx_int_t
+ngx_hextoi(u_char *line, size_t n)
 {
     u_char     ch;
     ngx_int_t  value;
@@ -499,7 +529,8 @@ ngx_int_t ngx_hextoi(u_char *line, size_t n)
 }
 
 
-void ngx_md5_text(u_char *text, u_char *md5)
+void
+ngx_md5_text(u_char *text, u_char *md5)
 {
     int            i;
     static u_char  hex[] = "0123456789abcdef";
@@ -513,7 +544,8 @@ void ngx_md5_text(u_char *text, u_char *md5)
 }
 
 
-void ngx_encode_base64(ngx_str_t *dst, ngx_str_t *src)
+void
+ngx_encode_base64(ngx_str_t *dst, ngx_str_t *src)
 {
     u_char         *d, *s;
     size_t          len;
@@ -553,7 +585,8 @@ void ngx_encode_base64(ngx_str_t *dst, ngx_str_t *src)
 }
 
 
-ngx_int_t ngx_decode_base64(ngx_str_t *dst, ngx_str_t *src)
+ngx_int_t
+ngx_decode_base64(ngx_str_t *dst, ngx_str_t *src)
 {
     size_t          len;
     u_char         *d, *s;
@@ -616,19 +649,20 @@ ngx_int_t ngx_decode_base64(ngx_str_t *dst, ngx_str_t *src)
 }
 
 
-uintptr_t ngx_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type)
+uintptr_t
+ngx_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type)
 {
     ngx_uint_t        i, n;
     uint32_t         *escape;
     static u_char     hex[] = "0123456789abcdef";
 
-                      /* " ", "%", "?", %00-%1F, %7F-%FF */
+                      /* " ", "#", "%", "?", %00-%1F, %7F-%FF */
 
     static uint32_t   uri[] =
         { 0xffffffff, /* 1111 1111 1111 1111  1111 1111 1111 1111 */
 
                       /* ?>=< ;:98 7654 3210  /.-, +*)( '&%$ #"!  */
-          0x80000021, /* 1000 0000 0000 0000  0000 0000 0010 0001 */
+          0x80000029, /* 1000 0000 0000 0000  0000 0000 0010 1001 */
 
                       /* _^]\ [ZYX WVUT SRQP  ONML KJIH GFED CBA@ */
           0x00000000, /* 0000 0000 0000 0000  0000 0000 0000 0000 */
@@ -641,13 +675,13 @@ uintptr_t ngx_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type)
           0xffffffff, /* 1111 1111 1111 1111  1111 1111 1111 1111 */
           0xffffffff  /* 1111 1111 1111 1111  1111 1111 1111 1111 */ };
 
-                      /* " ", "%", "+", "?", %00-%1F, %7F-%FF */
+                      /* " ", "#", "%", "+", "?", %00-%1F, %7F-%FF */
 
     static uint32_t   args[] =
         { 0xffffffff, /* 1111 1111 1111 1111  1111 1111 1111 1111 */
 
                       /* ?>=< ;:98 7654 3210  /.-, +*)( '&%$ #"!  */
-          0x80000821, /* 1000 0000 0000 0000  0000 1000 0010 0001 */
+          0x80000829, /* 1000 0000 0000 0000  0000 1000 0010 1001 */
 
                       /* _^]\ [ZYX WVUT SRQP  ONML KJIH GFED CBA@ */
           0x00000000, /* 0000 0000 0000 0000  0000 0000 0000 0000 */
@@ -666,7 +700,7 @@ uintptr_t ngx_escape_uri(u_char *dst, u_char *src, size_t size, ngx_uint_t type)
         { 0xffffffff, /* 1111 1111 1111 1111  1111 1111 1111 1111 */
 
                       /* ?>=< ;:98 7654 3210  /.-, +*)( '&%$ #"!  */
-          0x80000021, /* 0000 0000 0000 0000  0000 0000 1010 0101 */
+          0x800000ad, /* 0000 0000 0000 0000  0000 0000 1010 1101 */
 
                       /* _^]\ [ZYX WVUT SRQP  ONML KJIH GFED CBA@ */
           0x00000000, /* 0000 0000 0000 0000  0000 0000 0000 0000 */
index 766880738b1ae03065d18297dbd9a85531556b9c..52bac6a094b8942fc56a6e019cd82884b2084b70 100644 (file)
@@ -98,7 +98,7 @@ ngx_int_t ngx_decode_base64(ngx_str_t *dst, ngx_str_t *src);
 #define NGX_ESCAPE_HTML  2
 
 uintptr_t ngx_escape_uri(u_char *dst, u_char *src, size_t size,
-                         ngx_uint_t type);
+    ngx_uint_t type);
 
 
 #define  ngx_qsort                qsort
index d017f05bdf21f14e2f1d81409dbf51c6d2777daf..f1df54991b5cb38dc7b09c8779109406d4dd897a 100644 (file)
@@ -701,18 +701,18 @@ static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle)
                 name[0] = CTL_KERN;
                 name[1] = KERN_RTSIGMAX;
                 len = sizeof(rtsig_max);
-                if (sysctl(name, sizeof(name), &rtsig_max, &len, NULL, 0) == -1)
-                {
+
+                if (sysctl(name, 2, &rtsig_max, &len, NULL, 0) == -1) {
                     ngx_log_error(NGX_LOG_ALERT, cycle->log, errno,
                                   "sysctl(KERN_RTSIGMAX) failed");
                     return NGX_ERROR;
                 }
 
-                name[0] = CTL_KERN;
+                /* name[0] = CTL_KERN; */
                 name[1] = KERN_RTSIGNR;
                 len = sizeof(rtsig_nr);
-                if (sysctl(name, sizeof(name), &rtsig_nr, &len, NULL, 0) == -1)
-                {
+
+                if (sysctl(name, 2, &rtsig_nr, &len, NULL, 0) == -1) {
                     ngx_log_error(NGX_LOG_ALERT, cycle->log, errno,
                                   "sysctl(KERN_RTSIGNR) failed");
                     return NGX_ERROR;
index d79e5ff71b8ba6f701343de13ef478dbeaac0337..780dbeba547a51db5e6bd3b29ad80810c3fd2002 100644 (file)
@@ -34,21 +34,21 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf);
 static char *ngx_accept_mutex_check(ngx_conf_t *cf, void *post, void *data);
 
 
-static ngx_uint_t                 ngx_event_max_module;
+static ngx_uint_t    ngx_event_max_module;
 
-ngx_uint_t                        ngx_event_flags;
-ngx_event_actions_t               ngx_event_actions;
+ngx_uint_t           ngx_event_flags;
+ngx_event_actions_t  ngx_event_actions;
 
 
-ngx_atomic_t                      connection_counter;
-ngx_atomic_t                     *ngx_connection_counter = &connection_counter;
+ngx_atomic_t         connection_counter;
+ngx_atomic_t         *ngx_connection_counter = &connection_counter;
 
 
-ngx_atomic_t                     *ngx_accept_mutex_ptr;
-ngx_atomic_t                     *ngx_accept_mutex;
-ngx_uint_t                        ngx_accept_mutex_held;
-ngx_msec_t                        ngx_accept_mutex_delay;
-ngx_int_t                         ngx_accept_disabled;
+ngx_atomic_t         *ngx_accept_mutex_ptr;
+ngx_atomic_t         *ngx_accept_mutex;
+ngx_uint_t           ngx_accept_mutex_held;
+ngx_msec_t           ngx_accept_mutex_delay;
+ngx_int_t            ngx_accept_disabled;
 
 
 #if (NGX_STAT_STUB)
index c7f7595531b1b37feb69da05465bbe9033053c50..fb2d98473873d67fb56cbeca80b0360b92d523a1 100644 (file)
@@ -7,14 +7,14 @@
 #include <ngx_config.h>
 #include <ngx_core.h>
 #include <ngx_event.h>
-#include <nginx.h>
 
 
 static void ngx_close_accepted_socket(ngx_socket_t s, ngx_log_t *log);
 static u_char *ngx_accept_log_error(ngx_log_t *log, u_char *buf, size_t len);
 
 
-void ngx_event_accept(ngx_event_t *ev)
+void
+ngx_event_accept(ngx_event_t *ev)
 {
     ngx_uint_t         instance, accepted;
     socklen_t          len;
@@ -53,7 +53,7 @@ void ngx_event_accept(ngx_event_t *ev)
             /*
              * Create the pool before accept() to avoid the copying of
              * the sockaddr.  Although accept() can fail it is uncommon
-             * case and besides the pool can be got from the free pool list
+             * case and besides the pool can be got from the free pool list.
              */
 
             if (!(pool = ngx_create_pool(ls->listening->pool_size, ev->log))) {
@@ -117,7 +117,7 @@ void ngx_event_accept(ngx_event_t *ev)
         }
 
 #if (NGX_STAT_STUB)
-        (*ngx_stat_accepted)++;
+        ngx_atomic_inc(ngx_stat_accepted);
 #endif
 
         ngx_accept_disabled = (ngx_uint_t) s + NGX_ACCEPT_THRESHOLD
@@ -139,7 +139,7 @@ void ngx_event_accept(ngx_event_t *ev)
         }
 
 #if (NGX_STAT_STUB)
-        (*ngx_stat_active)++;
+        ngx_atomic_inc(ngx_stat_active);
 #endif
 
         /* set a blocking mode for aio and non-blocking mode for others */
@@ -234,7 +234,7 @@ void ngx_event_accept(ngx_event_t *ev)
         wev->ready = 1;
 
         if (ngx_event_flags & (NGX_USE_AIO_EVENT|NGX_USE_RTSIG_EVENT)) {
-            /* epoll, rtsig, aio, iocp */
+            /* rtsig, aio, iocp */
             rev->ready = 1;
         }
 
@@ -336,7 +336,8 @@ void ngx_event_accept(ngx_event_t *ev)
 }
 
 
-ngx_int_t ngx_trylock_accept_mutex(ngx_cycle_t *cycle)
+ngx_int_t
+ngx_trylock_accept_mutex(ngx_cycle_t *cycle)
 {
     if (*ngx_accept_mutex == 0
         && ngx_atomic_cmp_set(ngx_accept_mutex, 0, ngx_pid))
@@ -368,7 +369,8 @@ ngx_int_t ngx_trylock_accept_mutex(ngx_cycle_t *cycle)
 }
 
 
-ngx_int_t ngx_enable_accept_events(ngx_cycle_t *cycle)
+ngx_int_t
+ngx_enable_accept_events(ngx_cycle_t *cycle)
 {
     ngx_uint_t        i;
     ngx_listening_t  *s;
@@ -400,7 +402,8 @@ ngx_int_t ngx_enable_accept_events(ngx_cycle_t *cycle)
 }
 
 
-ngx_int_t ngx_disable_accept_events(ngx_cycle_t *cycle)
+ngx_int_t
+ngx_disable_accept_events(ngx_cycle_t *cycle)
 {
     ngx_uint_t        i;
     ngx_listening_t  *s;
@@ -442,7 +445,8 @@ ngx_int_t ngx_disable_accept_events(ngx_cycle_t *cycle)
 }
 
 
-static void ngx_close_accepted_socket(ngx_socket_t s, ngx_log_t *log)
+static void
+ngx_close_accepted_socket(ngx_socket_t s, ngx_log_t *log)
 {
     if (ngx_close_socket(s) == -1) {
         ngx_log_error(NGX_LOG_ALERT, log, ngx_socket_errno,
@@ -451,7 +455,8 @@ static void ngx_close_accepted_socket(ngx_socket_t s, ngx_log_t *log)
 }
 
 
-static u_char *ngx_accept_log_error(ngx_log_t *log, u_char *buf, size_t len)
+static u_char *
+ngx_accept_log_error(ngx_log_t *log, u_char *buf, size_t len)
 {
     return ngx_snprintf(buf, len, " while accept() on %V", log->data);
 }
index c1ca124143a97192324d69f2080225e4f5b5bd5a..4b98656501cffbe643131c8fd871ac9a7b63b51b 100644 (file)
@@ -18,7 +18,8 @@ ngx_thread_volatile ngx_rbtree_t  *ngx_event_timer_rbtree;
 ngx_rbtree_t                       ngx_event_timer_sentinel;
 
 
-ngx_int_t ngx_event_timer_init(ngx_log_t *log)
+ngx_int_t
+ngx_event_timer_init(ngx_log_t *log)
 {
     if (ngx_event_timer_rbtree) {
 #if (NGX_THREADS)
@@ -39,7 +40,8 @@ ngx_int_t ngx_event_timer_init(ngx_log_t *log)
 }
 
 
-ngx_msec_t ngx_event_find_timer(void)
+ngx_msec_t
+ngx_event_find_timer(void)
 {
     ngx_msec_t     timer;
     ngx_rbtree_t  *node;
@@ -68,7 +70,8 @@ ngx_msec_t ngx_event_find_timer(void)
 }
 
 
-void ngx_event_expire_timers(ngx_msec_t timer)
+void
+ngx_event_expire_timers(ngx_msec_t timer)
 {
     ngx_event_t   *ev;
     ngx_rbtree_t  *node;
index 090d4046ae34328a162b518e68464371c15e8cc1..edbfcf6041dc94b9b27a877d7053463e29a2a3a9 100644 (file)
@@ -16,8 +16,9 @@
 #define NGX_TIMER_INFINITE  -1
 #define NGX_TIMER_ERROR     -2
 
+
 /*
- * 32 bit timer key value resolution
+ * the 32-bit timer key value resolution
  *
  * 1 msec - 24 days
  * 10 msec - 8 months
@@ -27,6 +28,8 @@
 
 #define NGX_TIMER_RESOLUTION  1
 
+#define NGX_TIMER_LAZY_DELAY  300
+
 
 ngx_int_t ngx_event_timer_init(ngx_log_t *log);
 ngx_msec_t ngx_event_find_timer(void);
@@ -42,7 +45,8 @@ extern ngx_thread_volatile ngx_rbtree_t  *ngx_event_timer_rbtree;
 extern ngx_rbtree_t                       ngx_event_timer_sentinel;
 
 
-static ngx_inline void ngx_event_del_timer(ngx_event_t *ev)
+static ngx_inline void
+ngx_event_del_timer(ngx_event_t *ev)
 {
     ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
                    "event timer del: %d: %d",
@@ -68,7 +72,8 @@ static ngx_inline void ngx_event_del_timer(ngx_event_t *ev)
 }
 
 
-static ngx_inline void ngx_event_add_timer(ngx_event_t *ev, ngx_msec_t timer)
+static ngx_inline void
+ngx_event_add_timer(ngx_event_t *ev, ngx_msec_t timer)
 {
     ngx_int_t  key;
 
@@ -83,11 +88,13 @@ static ngx_inline void ngx_event_add_timer(ngx_event_t *ev, ngx_msec_t timer)
 
         /*
          * Use the previous timer value if a difference between them is less
-         * then 100 milliseconds.  It allows to minimize the rbtree operations
-         * for the fast connections.
+         * then NGX_TIMER_LAZY_DELAY milliseconds.  It allows to minimize
+         * the rbtree operations for the fast connections.
          */
 
-        if (abs(key - ev->rbtree_key) < 100 / NGX_TIMER_RESOLUTION) {
+        if (abs(key - ev->rbtree_key)
+                                 < NGX_TIMER_LAZY_DELAY / NGX_TIMER_RESOLUTION)
+        {
             ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
                            "event timer: %d, old: %i, new: %i",
                             ngx_event_ident(ev->data), ev->rbtree_key, key);
index 8f98719a17bc05d502c3a00380ebd5c659c79f42..1eb4cc61717b8b0db4b8b5399913730adc91ba96 100644 (file)
@@ -105,14 +105,15 @@ static ngx_http_output_header_filter_pt  ngx_http_next_header_filter;
 static ngx_http_output_body_filter_pt    ngx_http_next_body_filter;
 
 
-static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
+static ngx_int_t
+ngx_http_range_header_filter(ngx_http_request_t *r)
 {
     u_char                       *p;
     size_t                        len;
     off_t                         start, end;
     ngx_int_t                     rc;
-    uint32_t                      boundary;
     ngx_uint_t                    suffix, i;
+    ngx_atomic_int_t              boundary;
     ngx_table_elt_t              *content_range;
     ngx_http_range_t             *range;
     ngx_http_range_filter_ctx_t  *ctx;
@@ -328,7 +329,8 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
                         sizeof(ngx_http_range_filter_ctx_t), NGX_ERROR);
 
 
-    len = sizeof(CRLF "--0123456789" CRLF "Content-Type: ") - 1
+    len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN
+          + sizeof(CRLF "Content-Type: ") - 1
           + r->headers_out.content_type->value.len
           + sizeof(CRLF "Content-Range: bytes ") - 1;
 
@@ -340,7 +342,7 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
         return NGX_ERROR;
     }
 
-    boundary = (uint32_t) ngx_next_temp_number(0);
+    boundary = ngx_next_temp_number(0);
 
     /*
      * The boundary header of the range:
@@ -352,7 +354,7 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
 
     if (r->headers_out.charset.len) {
         ctx->boundary_header.len = ngx_sprintf(ctx->boundary_header.data,
-                                           CRLF "--%010ud" CRLF
+                                           CRLF "--%0muA" CRLF
                                            "Content-Type: %V; charset=%V" CRLF
                                            "Content-Range: bytes ",
                                            boundary,
@@ -364,7 +366,7 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
 
     } else {
         ctx->boundary_header.len = ngx_sprintf(ctx->boundary_header.data,
-                                           CRLF "--%010ud" CRLF
+                                           CRLF "--%0muA" CRLF
                                            "Content-Type: %V" CRLF
                                            "Content-Range: bytes ",
                                            boundary,
@@ -373,8 +375,9 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
     }
 
     r->headers_out.content_type->value.data =
-           ngx_palloc(r->pool, sizeof("Content-Type: multipart/byteranges; "
-                                      "boundary=0123456789") - 1);
+         ngx_palloc(r->pool,
+                    sizeof("Content-Type: multipart/byteranges; boundary=") - 1
+                    + NGX_ATOMIC_T_LEN);
 
     if (r->headers_out.content_type->value.data == NULL) {
         return NGX_ERROR;
@@ -384,12 +387,14 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
 
     r->headers_out.content_type->value.len =
                            ngx_sprintf(r->headers_out.content_type->value.data,
-                                       "multipart/byteranges; boundary=%010ud",
+                                       "multipart/byteranges; boundary=%0muA",
                                        boundary)
                            - r->headers_out.content_type->value.data;
 
+
     /* the size of the last boundary CRLF "--0123456789--" CRLF */
-    len = sizeof(CRLF "--0123456789--" CRLF) - 1;
+
+    len = sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN + sizeof("--" CRLF) - 1;
 
     range = r->headers_out.ranges.elts;
     for (i = 0; i < r->headers_out.ranges.nelts; i++) {
@@ -420,8 +425,8 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r)
 }
 
 
-static ngx_int_t ngx_http_range_body_filter(ngx_http_request_t *r,
-                                            ngx_chain_t *in)
+static ngx_int_t
+ngx_http_range_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
 {
     ngx_uint_t                    i;
     ngx_buf_t                    *b;
@@ -525,7 +530,8 @@ static ngx_int_t ngx_http_range_body_filter(ngx_http_request_t *r,
         b->temporary = 1;
         b->last_buf = 1;
 
-        b->pos = ngx_palloc(r->pool, sizeof(CRLF "--0123456789--" CRLF) - 1);
+        b->pos = ngx_palloc(r->pool, sizeof(CRLF "--") - 1 + NGX_ATOMIC_T_LEN
+                                     + sizeof("--" CRLF) - 1);
         if (b->pos == NULL) {
             return NGX_ERROR;
         }
@@ -552,7 +558,8 @@ static ngx_int_t ngx_http_range_body_filter(ngx_http_request_t *r,
 }
 
 
-static ngx_int_t ngx_http_range_header_filter_init(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_http_range_header_filter_init(ngx_cycle_t *cycle)
 {
     ngx_http_next_header_filter = ngx_http_top_header_filter;
     ngx_http_top_header_filter = ngx_http_range_header_filter;
@@ -561,7 +568,8 @@ static ngx_int_t ngx_http_range_header_filter_init(ngx_cycle_t *cycle)
 }
 
 
-static ngx_int_t ngx_http_range_body_filter_init(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_http_range_body_filter_init(ngx_cycle_t *cycle)
 {
     ngx_http_next_body_filter = ngx_http_top_body_filter;
     ngx_http_top_body_filter = ngx_http_range_body_filter;
index 3a35fe9106dd2e203dfba5e9aa2ab2c0440653dd..834beaa9255c482673bb7d517cfd33896debc670 100644 (file)
@@ -102,15 +102,15 @@ static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r)
     rd = *ngx_stat_reading;
     wr = *ngx_stat_writing;
 
-    b->last = ngx_sprintf(b->last, "Active connections: %d \n", ac);
+    b->last = ngx_sprintf(b->last, "Active connections: %D \n", ac);
 
     b->last = ngx_cpymem(b->last, "server accepts handled requests\n",
                          sizeof("server accepts handled requests\n") - 1);
 
-    b->last = ngx_sprintf(b->last, " %d %d %d \n", ap, hn, rq);
+    b->last = ngx_sprintf(b->last, " %D %D %D \n", ap, hn, rq);
 
-    b->last = ngx_sprintf(b->last, "Reading: %d Writing: %d Waiting: %d \n",
-                           rd, wr, ac - (rd + wr));
+    b->last = ngx_sprintf(b->last, "Reading: %D Writing: %D Waiting: %d \n",
+                          rd, wr, ac - (rd + wr));
 
     r->headers_out.status = NGX_HTTP_OK;
     r->headers_out.content_length_n = b->last - b->pos;
index 3610b1e3ac89d396094805b80de4e8275ff4a51f..ea0907ff196df890118b2576cd771c10c980c000 100644 (file)
@@ -117,7 +117,8 @@ ngx_http_header_t  ngx_http_headers_out[] = {
 };
 
 
-static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
+static ngx_int_t
+ngx_http_header_filter(ngx_http_request_t *r)
 {
     u_char                    *p;
     size_t                     len;
@@ -146,8 +147,9 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
         }
     }
 
-    /* 2 is for trailing "\r\n" and 2 is for "\r\n" in the end of header */
-    len = sizeof("HTTP/1.x ") - 1 + 2 + 2;
+    len = sizeof("HTTP/1.x ") - 1 + sizeof(CRLF) - 1
+          /* the end of the header */
+          + sizeof(CRLF) - 1;
 
     /* status line */
 
@@ -279,8 +281,8 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
             continue;
         }
 
-        /* 2 is for ": " and 2 is for "\r\n" */
-        len += header[i].key.len + 2 + header[i].value.len + 2;
+        len += header[i].key.len + sizeof(": ") - 1 + header[i].value.len
+               + sizeof(CRLF) - 1;
     }
 
     if (!(b = ngx_create_temp_buf(r->pool, len))) {
@@ -299,7 +301,7 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
         b->last = ngx_cpymem(b->last, http_codes[status].data,
                              http_codes[status].len);
     }
-    *(b->last++) = CR; *(b->last++) = LF;
+    *b->last++ = CR; *b->last++ = LF;
 
     if (!(r->headers_out.server && r->headers_out.server->key.len)) {
         b->last = ngx_cpymem(b->last, server_string, sizeof(server_string) - 1);
@@ -310,7 +312,7 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
         b->last = ngx_cpymem(b->last, ngx_cached_http_time.data,
                              ngx_cached_http_time.len);
 
-        *(b->last++) = CR; *(b->last++) = LF;
+        *b->last++ = CR; *b->last++ = LF;
     }
 
     if (r->headers_out.content_length == NULL) {
@@ -337,7 +339,7 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
             r->headers_out.content_type->value.data = p;
         }
 
-        *(b->last++) = CR; *(b->last++) = LF;
+        *b->last++ = CR; *b->last++ = LF;
     }
 
     if (r->headers_out.location
@@ -360,7 +362,7 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
         r->headers_out.location->value.len = b->last - p;
         r->headers_out.location->value.data = p;
 
-        *(b->last++) = CR; *(b->last++) = LF;
+        *b->last++ = CR; *b->last++ = LF;
     }
 
     if (!(r->headers_out.last_modified && r->headers_out.last_modified->key.len)
@@ -370,7 +372,7 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
                              sizeof("Last-Modified: ") - 1);
         b->last = ngx_http_time(b->last, r->headers_out.last_modified_time);
 
-        *(b->last++) = CR; *(b->last++) = LF;
+        *b->last++ = CR; *b->last++ = LF;
     }
 
     if (r->chunked) {
@@ -412,20 +414,20 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
         }
 
         b->last = ngx_cpymem(b->last, header[i].key.data, header[i].key.len);
-        *(b->last++) = ':' ; *(b->last++) = ' ' ;
+        *b->last++ = ':' ; *b->last++ = ' ' ;
 
         b->last = ngx_cpymem(b->last, header[i].value.data,
                              header[i].value.len);
-        *(b->last++) = CR; *(b->last++) = LF;
+        *b->last++ = CR; *b->last++ = LF;
     }
 
 #if (NGX_DEBUG)
-    *(b->last) = '\0';
+    *b->last = '\0';
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "%s\n", b->pos);
 #endif
 
     /* the end of HTTP header */
-    *(b->last++) = CR; *(b->last++) = LF;
+    *b->last++ = CR; *b->last++ = LF;
 
     r->header_size = b->last - b->pos;
 
@@ -444,7 +446,8 @@ static ngx_int_t ngx_http_header_filter(ngx_http_request_t *r)
 }
 
 
-static ngx_int_t ngx_http_header_filter_init(ngx_cycle_t *cycle)
+static ngx_int_t
+ngx_http_header_filter_init(ngx_cycle_t *cycle)
 {
     ngx_http_top_header_filter = ngx_http_header_filter;
 
index 0d031fe0df3e505b89368535b1132c36c0f00529..148246f64d5967f37015d00e519b27f0d35c7ff5 100644 (file)
@@ -135,7 +135,8 @@ static ngx_str_t ngx_http_combined_fmt =
 
 ngx_http_log_op_name_t ngx_http_log_fmt_ops[] = {
     { ngx_string("addr"), INET_ADDRSTRLEN - 1, NULL, NULL, ngx_http_log_addr },
-    { ngx_string("conn"), NGX_INT32_LEN, NULL, NULL, ngx_http_log_connection },
+    { ngx_string("conn"), NGX_ATOMIC_T_LEN, NULL, NULL,
+                          ngx_http_log_connection },
     { ngx_string("pipe"), 1, NULL, NULL, ngx_http_log_pipe },
     { ngx_string("time"), sizeof("28/Sep/1970:12:00:00 +0600") - 1,
                           NULL, NULL, ngx_http_log_time },
@@ -143,13 +144,13 @@ ngx_http_log_op_name_t ngx_http_log_fmt_ops[] = {
     { ngx_string("status"), 3, NULL, NULL, ngx_http_log_status },
     { ngx_string("length"), NGX_OFF_T_LEN, NULL, NULL, ngx_http_log_length },
     { ngx_string("apache_length"), NGX_OFF_T_LEN,
-                                   NULL, NULL, ngx_http_log_apache_length },
+                          NULL, NULL, ngx_http_log_apache_length },
     { ngx_string("request_length"), NGX_SIZE_T_LEN,
-                                    NULL, NULL, ngx_http_log_request_length },
+                          NULL, NULL, ngx_http_log_request_length },
 
     { ngx_string("request"), 0, NULL,
-                                ngx_http_log_request_getlen,
-                                ngx_http_log_request },
+                          ngx_http_log_request_getlen,
+                          ngx_http_log_request },
 
     { ngx_string("i"), 0, ngx_http_log_header_in_compile,
                           ngx_http_log_header_in_getlen,
index a6046f1bf1aae6aaa4b026b692c44a2106158307..f4908476c68bafff28588c7d4c647fc67e0c4f5e 100644 (file)
@@ -138,6 +138,7 @@ void ngx_http_init_connection(ngx_connection_t *c)
 
         if (ngx_accept_mutex) {
             if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) {
+
                 ngx_http_close_connection(c);
                 return;
             }
@@ -145,11 +146,15 @@ void ngx_http_init_connection(ngx_connection_t *c)
             ngx_post_event(rev); 
 
             ngx_mutex_unlock(ngx_posted_events_mutex);
+
+#if (NGX_STAT_STUB)
+        ngx_atomic_inc(ngx_stat_reading);
+#endif
             return;
         }
 
 #if (NGX_STAT_STUB)
-        (*ngx_stat_reading)++;
+        ngx_atomic_inc(ngx_stat_reading);
 #endif
 
         ngx_http_init_request(rev);
@@ -176,7 +181,7 @@ void ngx_http_init_connection(ngx_connection_t *c)
 #endif
 
 #if (NGX_STAT_STUB)
-    (*ngx_stat_reading)++;
+    ngx_atomic_inc(ngx_stat_reading);
 #endif
 
 }
@@ -205,7 +210,7 @@ static void ngx_http_init_request(ngx_event_t *rev)
         ngx_log_error(NGX_LOG_INFO, c->log, NGX_ETIMEDOUT, "client timed out");
 
 #if (NGX_STAT_STUB)
-        (*ngx_stat_reading)--;
+        ngx_atomic_dec(ngx_stat_reading);
 #endif
 
         ngx_http_close_connection(c);
@@ -217,14 +222,14 @@ static void ngx_http_init_request(ngx_event_t *rev)
     if (hc) {
 
 #if (NGX_STAT_STUB)
-        (*ngx_stat_reading)++;
+        ngx_atomic_inc(ngx_stat_reading);
 #endif
 
     } else {
         if (!(hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)))) {
 
 #if (NGX_STAT_STUB)
-            (*ngx_stat_reading)--;
+            ngx_atomic_dec(ngx_stat_reading);
 #endif
 
             ngx_http_close_connection(c);
@@ -247,7 +252,7 @@ static void ngx_http_init_request(ngx_event_t *rev)
         if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) {
 
 #if (NGX_STAT_STUB)
-            (*ngx_stat_reading)--;
+            ngx_atomic_dec(ngx_stat_reading);
 #endif
 
             ngx_http_close_connection(c);
@@ -258,7 +263,7 @@ static void ngx_http_init_request(ngx_event_t *rev)
     }
 
 #if (NGX_STAT_STUB)
-    (*ngx_stat_reading)--;
+    ngx_atomic_dec(ngx_stat_reading);
 #endif
 
     c->data = r;
@@ -427,9 +432,9 @@ static void ngx_http_init_request(ngx_event_t *rev)
     r->http_state = NGX_HTTP_READING_REQUEST_STATE;
 
 #if (NGX_STAT_STUB)
-    (*ngx_stat_reading)++;
+    ngx_atomic_inc(ngx_stat_reading);
     r->stat_reading = 1;
-    (*ngx_stat_requests)++;
+    ngx_atomic_inc(ngx_stat_requests);
 #endif
 
     rev->event_handler(rev);
@@ -829,9 +834,9 @@ static void ngx_http_process_request_headers(ngx_event_t *rev)
             }
 
 #if (NGX_STAT_STUB)
-            (*ngx_stat_reading)--;
+            ngx_atomic_dec(ngx_stat_reading);
             r->stat_reading = 0;
-            (*ngx_stat_writing)++;
+            ngx_atomic_inc(ngx_stat_writing);
             r->stat_writing = 1;
 #endif
 
@@ -2076,11 +2081,11 @@ void ngx_http_close_request(ngx_http_request_t *r, int error)
 
 #if (NGX_STAT_STUB)
     if (r->stat_reading) {
-        (*ngx_stat_reading)--;
+        ngx_atomic_dec(ngx_stat_reading);
     }
 
     if (r->stat_writing) {
-        (*ngx_stat_writing)--;
+        ngx_atomic_dec(ngx_stat_writing);
     }
 #endif
 
@@ -2203,7 +2208,7 @@ void ngx_http_close_connection(ngx_connection_t *c)
 #endif
 
 #if (NGX_STAT_STUB)
-    (*ngx_stat_active)--;
+    ngx_atomic_dec(ngx_stat_active);
 #endif
 
     pool = c->pool;
index 2de61cf81834d4065010466ecc7f26afbe22d4f0..c313964686c1564d6ca0d7d7219cdc5e0e36b383 100644 (file)
 #include <ngx_core.h>
 
 
-#if ( __i386__ || __amd64__ )
+#if ( __i386__ )
 
 #define NGX_HAVE_ATOMIC_OPS  1
 
-typedef volatile uint32_t  ngx_atomic_t;
+typedef uint32_t  ngx_atomic_int_t;
+typedef volatile ngx_atomic_int_t  ngx_atomic_t;
+#define NGX_ATOMIC_T_LEN  sizeof("-2147483648") - 1
+
 
 #if (NGX_SMP)
 #define NGX_SMP_LOCK  "lock;"
@@ -24,57 +27,149 @@ typedef volatile uint32_t  ngx_atomic_t;
 #define NGX_SMP_LOCK
 #endif
 
+/*
+ * the "=q" is any of the %eax, %ebx, %ecx, or %edx registers.
+ * the '"0" (1)' parameter preloads 1 into %0.
+ * the "cc" means that flags were changed.
+ */
 
-static ngx_inline uint32_t ngx_atomic_inc(ngx_atomic_t *value)
+static ngx_inline ngx_atomic_int_t
+ngx_atomic_inc(ngx_atomic_t *value)
 {
-    uint32_t  old;
+    ngx_atomic_int_t  old;
 
     __asm__ volatile (
 
-        NGX_SMP_LOCK
-    "   xaddl  %0, %2;   "
-    "   incl   %0;       "
+         NGX_SMP_LOCK
+    "    xaddl  %0, %2;   "
+    "    incl   %0;       "
 
-    : "=q" (old) : "0" (1), "m" (*value));
+    : "=q" (old) : "0" (1), "m" (*value) : "cc", "memory");
 
     return old;
 }
 
 
-#if 0
-
-static ngx_inline uint32_t ngx_atomic_dec(ngx_atomic_t *value)
+static ngx_inline ngx_atomic_int_t
+ngx_atomic_dec(ngx_atomic_t *value)
 {
-    uint32_t  old;
+    ngx_atomic_int_t  old;
 
     __asm__ volatile (
 
-        NGX_SMP_LOCK
-    "   xaddl  %0, %1;   "
-    "   decl   %0;       "
+         NGX_SMP_LOCK
+    "    xaddl  %0, %2;   "
+    "    decl   %0;       "
 
-    : "=q" (old) : "0" (-1), "m" (*value));
+    : "=q" (old) : "0" (-1), "m" (*value) : "cc", "memory");
 
     return old;
 }
 
+
+/*
+ * the "q" is any of the %eax, %ebx, %ecx, or %edx registers.
+ * the "=a" and "a" are the %eax register.  Although we can return result
+ * in any register, we use %eax because it is used in cmpxchg anyway.
+ *
+ * "cmpxchg  r, [m]":
+ *
+ *   if (eax == [m]) {
+ *       zf = 1;
+ *       [m] = r;
+ *   } else {
+ *       zf = 0;
+ *       eax = [m];
+ *   }
+ */
+
+static ngx_inline ngx_atomic_int_t
+ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_int_t old,
+    ngx_atomic_int_t set)
+{
+    ngx_atomic_int_t  res;
+
+    __asm__ volatile (
+
+         NGX_SMP_LOCK
+    "    cmpxchgl  %3, %1;   "
+    "    setz      %b0;      "
+    "    movzbl    %b0, %0;  "
+
+    : "=a" (res) : "m" (*lock), "a" (old), "q" (set) : "cc", "memory");
+
+    return res;
+}
+
+
+#elif ( __amd64__ )
+
+#define NGX_HAVE_ATOMIC_OPS  1
+
+typedef int64_t  ngx_atomic_int_t;
+typedef volatile ngx_atomic_int_t  ngx_atomic_t;
+#define NGX_ATOMIC_T_LEN  sizeof("-9223372036854775808") - 1
+
+
+#if (NGX_SMP)
+#define NGX_SMP_LOCK  "lock;"
+#else
+#define NGX_SMP_LOCK
 #endif
 
 
-static ngx_inline uint32_t ngx_atomic_cmp_set(ngx_atomic_t *lock,
-                                              ngx_atomic_t old,
-                                              ngx_atomic_t set)
+static ngx_inline ngx_atomic_int_t
+ngx_atomic_inc(ngx_atomic_t *value)
+{
+    ngx_atomic_int_t  old;
+
+    __asm__ volatile (
+
+         NGX_SMP_LOCK
+    "    xaddq  %0, %2;   "
+    "    incq   %0;       "
+
+    : "=r" (old) : "0" (1), "m" (*value) : "cc", "memory");
+
+    return old;
+}
+
+
+/* the '"0" (-1LL)' parameter preloads -1 into the 64-bit %0 register */
+
+static ngx_inline ngx_atomic_int_t
+ngx_atomic_dec(ngx_atomic_t *value)
 {
-    uint32_t  res;
+    ngx_atomic_int_t  old;
 
     __asm__ volatile (
 
-        NGX_SMP_LOCK
-    "   cmpxchgl  %3, %1;   "
-    "   setz      %%al;     "
-    "   movzbl    %%al, %0; "
+         NGX_SMP_LOCK
+    "    xaddq  %0, %2;   "
+    "    decq   %0;       "
+
+    : "=r" (old) : "0" (-1LL), "m" (*value) : "cc", "memory");
 
-    : "=a" (res) : "m" (*lock), "a" (old), "q" (set));
+    return old;
+}
+
+
+/* the "=a" and "a" are the %rax register. */
+
+static ngx_inline ngx_atomic_int_t
+ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_int_t old,
+    ngx_atomic_int_t set)
+{
+    ngx_atomic_int_t  res;
+
+    __asm__ volatile (
+
+         NGX_SMP_LOCK
+    "    cmpxchgq  %3, %1;   "
+    "    setz      %b0;      "
+    "    movzbq    %b0, %0;  "
+
+    : "=a" (res) : "m" (*lock), "a" (old), "r" (set) : "cc", "memory");
 
     return res;
 }
@@ -84,12 +179,38 @@ static ngx_inline uint32_t ngx_atomic_cmp_set(ngx_atomic_t *lock,
 
 #define NGX_HAVE_ATOMIC_OPS  1
 
-typedef volatile uint32_t  ngx_atomic_t;
+#if (NGX_PTR_SIZE == 8)
+typedef uint64_t  ngx_atomic_int_t;
+#define NGX_ATOMIC_T_LEN  sizeof("-9223372036854775808") - 1
+#define NGX_CASXA         "casxa"
+#else
+typedef uint32_t  ngx_atomic_int_t;
+#define NGX_ATOMIC_T_LEN  sizeof("-2147483648") - 1
+#define NGX_CASXA         "casa"
+#endif
+
+typedef volatile ngx_atomic_int_t  ngx_atomic_t;
+
 
+/*
+ * the "+r" means the general register used for both input and output.
+ *
+ * "casa   [r1] 0x80, r2, r0"  and
+ * "casxa  [r1] 0x80, r2, r0"  do the following:
+ *
+ *     if ([r1] == r2) {
+ *         swap(r0, [r1]);
+ *     } else {
+ *         r0 = [r1];
+ *     }
+ *
+ * so "r0 == r2" means that the operation was successfull.
+ */
 
-static ngx_inline uint32_t ngx_atomic_inc(ngx_atomic_t *value)
+static ngx_inline ngx_atomic_int_t
+ngx_atomic_inc(ngx_atomic_t *value)
 {
-    uint32_t  old, new, res;
+    ngx_atomic_int_t  old, new, res;
 
     old = *value;
 
@@ -100,9 +221,36 @@ static ngx_inline uint32_t ngx_atomic_inc(ngx_atomic_t *value)
 
         __asm__ volatile (
 
-        "casa [%1] 0x80, %2, %0"
+        NGX_CASXA " [%1] 0x80, %2, %0"
+
+        : "+r" (res) : "r" (value), "r" (old) : "memory");
+
+        if (res == old) {
+            return new;
+        }
+
+        old = res;
+    }
+}
+
+
+static ngx_inline ngx_atomic_int_t
+ngx_atomic_dec(ngx_atomic_t *value)
+{
+    ngx_atomic_int_t  old, new, res;
+
+    old = *value;
+
+    for ( ;; ) {
+
+        new = old - 1;
+        res = new;
+
+        __asm__ volatile (
+
+        NGX_CASXA " [%1] 0x80, %2, %0"
 
-        : "+r" (res) : "r" (value), "r" (old));
+        : "+r" (res) : "r" (value), "r" (old) : "memory");
 
         if (res == old) {
             return new;
@@ -113,33 +261,128 @@ static ngx_inline uint32_t ngx_atomic_inc(ngx_atomic_t *value)
 }
 
 
-static ngx_inline uint32_t ngx_atomic_cmp_set(ngx_atomic_t *lock,
-                                              ngx_atomic_t old,
-                                              ngx_atomic_t set)
+static ngx_inline ngx_atomic_int_t
+ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_int_t old, ngx_atomic_int_t set)
+{
+    __asm__ volatile (
+
+    NGX_CASXA " [%1] 0x80, %2, %0"
+
+    : "+r" (set) : "r" (lock), "r" (old) : "memory");
+
+    return (set == old);
+}
+
+
+#elif ( __ppc__ )
+
+#define NGX_HAVE_ATOMIC_OPS  1
+
+#if (NGX_PTR_SIZE == 8)
+typedef uint64_t  ngx_atomic_int_t;
+#define NGX_ATOMIC_T_LEN  sizeof("-9223372036854775808") - 1
+#else
+#define NGX_ATOMIC_T_LEN  sizeof("-2147483648") - 1
+typedef uint32_t  ngx_atomic_int_t;
+#endif
+
+typedef volatile ngx_atomic_int_t  ngx_atomic_t;
+
+
+/*
+ * the ppc assembler treats ";" as comment, so we have to use "\n".
+ * the minus in "bne-" is a hint for the branch prediction unit that
+ * this branch is unlikely to be taken.
+ *
+ * the "=&r" means that no input registers can be used.
+ * the "=&b" means that the base registers can be used only, i.e. any register
+ * except r0.  the r0 register can not be used in "addi  r0, r0, 1".
+ * the "1b" means the nearest backward label "1" and the "1f" means
+ * the nearest forward label "1".
+ */
+
+static ngx_inline ngx_atomic_int_t
+ngx_atomic_inc(ngx_atomic_t *value)
+{
+    ngx_atomic_int_t  res;
+
+    __asm__ volatile (
+
+    "1:  lwarx   %0, 0, %1  \n" /* load from [value] into "res"             */
+                                /*   and store reservation                  */
+    "    addi    %0, %0, 1  \n" /* add "1" to "res"                         */
+    "    stwcx.  %0, 0, %1  \n" /* store "res" into [value] if reservation  */
+                                /*    is not cleared                        */
+    "    bne-    1b         \n" /* try again if reservation was cleared     */
+
+    : "=&b" (res) : "r" (value) : "cc", "memory");
+
+    return res;
+}
+
+
+static ngx_inline ngx_atomic_int_t
+ngx_atomic_dec(ngx_atomic_t *value)
 {
-    uint32_t  res = (uint32_t) set;
+    ngx_atomic_int_t  res;
 
     __asm__ volatile (
 
-    "casa [%1] 0x80, %2, %0"
+    "1:  lwarx   %0, 0, %1  \n" /* load from [value] into "res"             */
+                                /*   and store reservation                  */
+    "    addi    %0, %0, -1 \n" /* sub "1" from "res"                       */
+    "    stwcx.  %0, 0, %1  \n" /* store "res" into [value] if reservation  */
+                                /*    is not cleared                        */
+    "    bne-    1b         \n" /* try again if reservation was cleared     */
+
+    : "=&b" (res) : "r" (value) : "cc", "memory");
+
+    return res;
+}
+
+
+static ngx_inline ngx_atomic_int_t
+ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_int_t old,
+    ngx_atomic_int_t set)
+{
+    ngx_atomic_int_t  res, temp;
 
-    : "+r" (res) : "r" (lock), "r" (old));
+    __asm__ volatile (
 
-    return (res == old);
+    "    li      %0, 0      \n" /* preset "0" to "res"                      */
+    "    lwarx   %1, 0, %2  \n" /* load from [lock] into "temp"             */
+                                /*   and store reservation                  */
+    "    cmpw    %1, %3     \n" /* compare "temp" and "old"                 */
+    "    bne-    1f         \n" /* not equal                                */
+    "    stwcx.  %4, 0, %2  \n" /* store "set" into [lock] if reservation   */
+                                /*    is not cleared                        */
+    "    bne-    1f         \n" /* the reservation was cleared              */
+    "    li      %0, 1      \n" /* set "1" to "res"                         */
+    "1:                     \n"
+
+    : "=&r" (res), "=&r" (temp)
+    : "r" (lock), "r" (old), "r" (set)
+    : "cc", "memory");
+
+    return res;
 }
 
+
 #else
 
 #define NGX_HAVE_ATOMIC_OPS  0
 
-typedef volatile uint32_t  ngx_atomic_t;
+typedef uint32_t  ngx_atomic_int_t;
+typedef volatile ngx_atomic_int_t  ngx_atomic_t;
 
-#define ngx_atomic_inc(x)  ++(*(x));
+#define ngx_atomic_inc(x)  ++(*(x))
+#define ngx_atomic_dec(x)  --(*(x))
 
-static ngx_inline uint32_t ngx_atomic_cmp_set(ngx_atomic_t *lock,
-                                              ngx_atomic_t old,
-                                              ngx_atomic_t set)
+static ngx_inline ngx_atomic_int_t
+ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_int_t old,
+     ngx_atomic_int_t set)
 {
+     *lock = set;
      return 1;
 }
 
index 7a1e2031e860168655bd2757d1b37c846eed8352..4e865a3c0734b078f8414295878dfcbe59c2f439 100644 (file)
@@ -9,7 +9,7 @@
 
 
 ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
-                                        off_t limit);
+    off_t limit);
 
 extern int ngx_freebsd_kern_osreldate;
 extern int ngx_freebsd_hw_ncpu;
index 4a8f8f3dafe0cb1e69af66b9384f78e4a313466a..e871ba9b0e6130df2d1e97811cc537e4b89b7221 100644 (file)
@@ -8,11 +8,8 @@
 #define _NGX_LINUX_H_INCLUDED_
 
 
-ngx_int_t  ngx_init_setproctitle(ngx_log_t *log);
-void ngx_setproctitle(char *title);
-
 ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
-                                      off_t limit);
+    off_t limit);
 
 extern int ngx_linux_rtsig_max;
 
index 9c1c84758a5ef79cf0f49065b47e076764b8edea..7f7be890a04bbec711c4fc1836719e1213d907e5 100644 (file)
@@ -28,7 +28,8 @@ ngx_os_io_t ngx_os_io = {
 };
 
 
-ngx_int_t ngx_os_init(ngx_log_t *log)
+ngx_int_t
+ngx_os_init(ngx_log_t *log)
 {
     int        name[2];
     size_t     len;
@@ -37,28 +38,29 @@ ngx_int_t ngx_os_init(ngx_log_t *log)
     name[0] = CTL_KERN;
     name[1] = KERN_OSTYPE;
     len = sizeof(ngx_linux_kern_ostype);
-    if (sysctl(name, sizeof(name), ngx_linux_kern_ostype, &len, NULL, 0)
-                                                                       == -1) {
+
+    if (sysctl(name, 2, ngx_linux_kern_ostype, &len, NULL, 0) == -1) {
         ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
                       "sysctl(KERN_OSTYPE) failed");
         return NGX_ERROR;
     }
 
-    name[0] = CTL_KERN;
+    /* name[0] = CTL_KERN; */
     name[1] = KERN_OSRELEASE;
     len = sizeof(ngx_linux_kern_osrelease);
-    if (sysctl(name, sizeof(name), ngx_linux_kern_osrelease, &len, NULL, 0)
-                                                                       == -1) {
+
+    if (sysctl(name, 2, ngx_linux_kern_osrelease, &len, NULL, 0) == -1) {
         ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
                       "sysctl(KERN_OSRELEASE) failed");
         return NGX_ERROR;
     }
 
 
-    name[0] = CTL_KERN;
+    /* name[0] = CTL_KERN; */
     name[1] = KERN_RTSIGMAX;
     len = sizeof(ngx_linux_rtsig_max);
-    if (sysctl(name, sizeof(name), &ngx_linux_rtsig_max, &len, NULL, 0) == -1) {
+
+    if (sysctl(name, 2, &ngx_linux_rtsig_max, &len, NULL, 0) == -1) {
         err = ngx_errno;
 
         if (err != NGX_ENOTDIR) {
@@ -78,7 +80,8 @@ ngx_int_t ngx_os_init(ngx_log_t *log)
 }
 
 
-void ngx_os_status(ngx_log_t *log)
+void
+ngx_os_status(ngx_log_t *log)
 {
     ngx_log_error(NGX_LOG_INFO, log, 0, "OS: %s %s",
                   ngx_linux_kern_ostype, ngx_linux_kern_osrelease);
index 42fc886291e26dd97db2d131d5248b37d2110381..e39aab0eff2b09029a0f7936a42e55e8e33d938e 100644 (file)
@@ -20,7 +20,7 @@ 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);
 typedef ssize_t (*ngx_send_pt)(ngx_connection_t *c, u_char *buf, size_t size);
 typedef ngx_chain_t *(*ngx_send_chain_pt)(ngx_connection_t *c, ngx_chain_t *in,
-                                          off_t limit);
+    off_t limit);
 
 typedef struct {
     ngx_recv_pt        recv;
@@ -44,7 +44,7 @@ ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size);
 ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *entry);
 ssize_t ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size);
 ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in,
-                              off_t limit);
+    off_t limit);
 
 
 extern ngx_os_io_t  ngx_os_io;
index 12703b3e35a6144f163b7728c06f4a496227416e..995e93ce29d580a8dd71a577c9927eb5e0a4c3e0 100644 (file)
@@ -49,8 +49,7 @@ typedef struct {
 #define ngx_log_pid  ngx_pid
 
 ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
-                            ngx_spawn_proc_pt proc, void *data,
-                            char *name, ngx_int_t respawn);
+    ngx_spawn_proc_pt proc, void *data, char *name, ngx_int_t respawn);
 ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
 void ngx_process_get_status(void);
 void ngx_debug_point(void);
@@ -63,6 +62,12 @@ void ngx_debug_point(void);
 #endif
 
 
+#if !defined(ngx_setproctitle)
+ngx_int_t ngx_init_setproctitle(ngx_log_t *log);
+void ngx_setproctitle(char *title);
+#endif
+
+
 extern int            ngx_argc;
 extern char         **ngx_argv;
 extern char         **ngx_os_argv;
index 2e41108b5398867c25b365bb402a3b71f19e485c..6c95cdf4ee7c3661e2396876506bd03b032696e3 100644 (file)
@@ -30,9 +30,10 @@ extern char **environ;
 
 static char *ngx_os_argv_last;
 
-ngx_int_t  ngx_init_setproctitle(ngx_log_t *log)
+ngx_int_t
+ngx_init_setproctitle(ngx_log_t *log)
 {
-    char        *p;
+    u_char      *p;
     size_t       size;
     ngx_uint_t   i;
 
@@ -60,8 +61,8 @@ ngx_int_t  ngx_init_setproctitle(ngx_log_t *log)
             size = ngx_strlen(environ[i]) + 1;
             ngx_os_argv_last = environ[i] + size;
 
-            ngx_cpystrn(p, environ[i], size);
-            environ[i] = p;
+            ngx_cpystrn(p, (u_char *) environ[i], size);
+            environ[i] = (char *) p;
             p += size;
         }
     }
@@ -72,7 +73,8 @@ ngx_int_t  ngx_init_setproctitle(ngx_log_t *log)
 }
 
 
-void ngx_setproctitle(char *title)
+void
+ngx_setproctitle(char *title)
 {
     u_char     *p;
 
@@ -131,13 +133,16 @@ void ngx_setproctitle(char *title)
 
 #elif !defined(ngx_setproctitle)
 
-ngx_int_t  ngx_init_setproctitle(ngx_log_t *log)
+ngx_int_t
+ngx_init_setproctitle(ngx_log_t *log)
 {
     return NGX_OK;
 }
 
-void ngx_setproctitle(char *title)
+void
+ngx_setproctitle(char *title)
 {
+    return;
 }
 
 #endif
index 705cd57eeeb6919ca82d827356c4929c65333e3f..44ce79679832a3d31da2f2b82113e413de61c33d 100644 (file)
@@ -8,12 +8,8 @@
 #define _NGX_SOLARIS_H_INCLUDED_
 
 
-ngx_int_t  ngx_init_setproctitle(ngx_log_t *log);
-void ngx_setproctitle(char *title);
-
-
 ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
-                                         off_t limit);
+    off_t limit);
 
 
 #endif /* _NGX_SOLARIS_H_INCLUDED_ */
index b4915d0a283a308243c7afe44241bdbb1aa4bfa7..7022bfae83887c04b2ac3de14380dd1d523e7884 100644 (file)
 
 #define NGX_HAVE_ATOMIC_OPS   1
 
+typedef uint32_t  ngx_atomic_int_t;
+typedef volatile ngx_atomic_int_t  ngx_atomic_t;
+#define NGX_ATOMIC_T_LEN  sizeof("-2147483648") - 1
+
 
 #define ngx_atomic_inc(p)       InterlockedIncrement((long *) p)
+#define ngx_atomic_dec(p)       InterlockedDecrement((long *) p)
 
 
 #if defined( __WATCOMC__ ) || defined( __BORLANDC__ ) || ( _MSC_VER >= 1300 )
index 7c3bcd5fa4502c9c37f308cd4763311655331465..5bdf91f66f2957c5fb121a411091699412477bfe 100644 (file)
@@ -111,7 +111,6 @@ typedef __int64           off_t;
 typedef uint32_t          in_addr_t;
 typedef u_short           in_port_t;
 typedef int               sig_atomic_t;
-typedef uint32_t          ngx_atomic_t;
 
 
 #define NGX_SIZE_T_LEN          sizeof("-2147483648") - 1