changeset 495:fc9909c369b2 release-0.1.22

nginx-0.1.22-RELEASE import *) Bugfix: the ngx_http_stub_status_module showed incorrect handled connections statistics if the proxying or FastCGI server were used. *) Bugfix: the installation paths were incorrectly quoted on Linux and Solaris; the bug had appeared in 0.1.21.
author Igor Sysoev <igor@sysoev.ru>
date Thu, 24 Feb 2005 12:29:09 +0000
parents f94c1b769a7c
children 7ce7b31c3c83
files auto/install 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.h src/core/ngx_string.c src/event/ngx_event.c src/event/ngx_event.h src/event/ngx_event_accept.c src/http/modules/ngx_http_range_filter.c src/http/modules/ngx_http_stub_status_module.c src/http/ngx_http_request.c src/os/unix/ngx_atomic.h
diffstat 15 files changed, 164 insertions(+), 112 deletions(-) [+]
line wrap: on
line diff
--- a/auto/install
+++ b/auto/install
@@ -5,40 +5,40 @@
 cat << END                                                    >> $NGX_MAKEFILE
 
 install:	$NGX_OBJS${ngx_dirsep}nginx${ngx_binext}
-	test -d "$NGX_PREFIX" || mkdir -p "$NGX_PREFIX"
+	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
--- a/docs/xml/nginx/changes.xml
+++ b/docs/xml/nginx/changes.xml
@@ -9,6 +9,34 @@
 <title lang="en">nginx changelog</title>
 
 
+<changes ver="0.1.22" date="22.02.2005">
+
+<change type="bugfix">
+<para lang="ru">
+модуль ngx_http_stub_status_module показывал неверную статистику
+для обработанных соединений, если использовалось проксирование
+или FastCGI-сервер.
+</para>
+<para lang="en">
+the ngx_http_stub_status_module showed incorrect handled connections
+statictics if the proxing or FastCGI server were used.
+</para>
+</change>
+
+<change type="bugfix">
+<para lang="ru">
+на Linux и Solaris установочные пути были неверно заключены в кавычки;
+ошибка появилась в 0.1.21.
+</para>
+<para lang="en">
+the installation pathes were incorrectly quoted on Linux and Solaris;
+bug appeared in 0.1.21.
+</para>
+</change>
+
+</changes>
+
+
 <changes ver="0.1.21" date="22.02.2005">
 
 <change type="bugfix">
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
 #define _NGINX_H_INCLUDED_
 
 
-#define NGINX_VER          "nginx/0.1.21"
+#define NGINX_VER          "nginx/0.1.22"
 
 #define NGINX_VAR          "NGINX"
 #define NGX_NEWPID_EXT     ".newbin"
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -114,7 +114,7 @@ struct ngx_connection_s {
 
     ngx_buf_t          *buffer;
 
-    ngx_atomic_int_t    number;
+    ngx_atomic_uint_t   number;
 
     unsigned            log_error:2;     /* ngx_connection_log_error_e */
 
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -8,8 +8,8 @@
 #include <ngx_core.h>
 
 
-static ngx_atomic_int_t  ngx_temp_number;
-static ngx_atomic_int_t  ngx_random;
+static ngx_atomic_uint_t  ngx_temp_number;
+static ngx_atomic_uint_t  ngx_random;
 
 
 ssize_t
@@ -38,8 +38,8 @@ 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;
-    ngx_atomic_int_t   n;
+    ngx_err_t           err;
+    ngx_atomic_uint_t   n;
 
     file->name.len = path->name.len + 1 + path->len + NGX_ATOMIC_T_LEN;
 
@@ -176,7 +176,7 @@ ngx_init_temp_number()
 }
 
 
-ngx_atomic_int_t
+ngx_atomic_uint_t
 ngx_next_temp_number(ngx_uint_t collision)
 {
     if (collision) {
--- a/src/core/ngx_file.h
+++ b/src/core/ngx_file.h
@@ -62,7 +62,7 @@ ngx_int_t ngx_add_path(ngx_conf_t *cf, n
 ngx_int_t ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user);
 
 void ngx_init_temp_number();
-ngx_atomic_int_t ngx_next_temp_number(ngx_uint_t collision);
+ngx_atomic_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);
 
--- a/src/core/ngx_log.h
+++ b/src/core/ngx_log.h
@@ -47,7 +47,7 @@ struct ngx_log_s {
     ngx_uint_t           log_level;
     ngx_open_file_t     *file;
 
-    ngx_atomic_int_t     connection;
+    ngx_atomic_uint_t    connection;
 
     ngx_log_handler_pt   handler;
     void                *data;
--- a/src/core/ngx_string.c
+++ b/src/core/ngx_string.c
@@ -54,7 +54,7 @@ ngx_pstrdup(ngx_pool_t *pool, ngx_str_t 
  *    %[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
+ *    %[0][width|m][u][x|X]A    ngx_atomic_int_t/ngx_atomic_uint_t
  *    %P                        ngx_pid_t
  *    %r                        rlim_t
  *    %p                        pointer
@@ -277,7 +277,7 @@ ngx_vsnprintf(u_char *buf, size_t max, c
                 if (sign) {
                     i64 = (int64_t) va_arg(args, ngx_atomic_int_t);
                 } else {
-                    ui64 = (uint64_t) va_arg(args, ngx_atomic_int_t);
+                    ui64 = (uint64_t) va_arg(args, ngx_atomic_uint_t);
                 }
 
                 if (max_width) {
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -34,27 +34,29 @@ static char *ngx_event_init_conf(ngx_cyc
 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          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_uint_t            ngx_accept_mutex_held;
+ngx_msec_t            ngx_accept_mutex_delay;
+ngx_int_t             ngx_accept_disabled;
 
 
 #if (NGX_STAT_STUB)
 
 ngx_atomic_t   ngx_stat_accepted0;
 ngx_atomic_t  *ngx_stat_accepted = &ngx_stat_accepted0;
+ngx_atomic_t   ngx_stat_handled0;
+ngx_atomic_t  *ngx_stat_handled = &ngx_stat_handled0;
 ngx_atomic_t   ngx_stat_requests0;
 ngx_atomic_t  *ngx_stat_requests = &ngx_stat_requests0;
 ngx_atomic_t   ngx_stat_active0;
@@ -62,7 +64,7 @@ ngx_atomic_t  *ngx_stat_active = &ngx_st
 ngx_atomic_t   ngx_stat_reading0;
 ngx_atomic_t  *ngx_stat_reading = &ngx_stat_reading0;
 ngx_atomic_t   ngx_stat_writing0;
-ngx_atomic_t  *ngx_stat_writing = &ngx_stat_reading0;
+ngx_atomic_t  *ngx_stat_writing = &ngx_stat_writing0;
 
 #endif
 
@@ -209,6 +211,7 @@ static ngx_int_t ngx_event_module_init(n
 #if (NGX_STAT_STUB)
 
     size += 128           /* ngx_stat_accepted */
+           + 128          /* ngx_stat_handled */
            + 128          /* ngx_stat_requests */
            + 128          /* ngx_stat_active */
            + 128          /* ngx_stat_reading */
@@ -226,10 +229,11 @@ static ngx_int_t ngx_event_module_init(n
 #if (NGX_STAT_STUB)
 
     ngx_stat_accepted = (ngx_atomic_t *) (shared + 2 * 128);
-    ngx_stat_requests = (ngx_atomic_t *) (shared + 3 * 128);
-    ngx_stat_active = (ngx_atomic_t *) (shared + 4 * 128);
-    ngx_stat_reading = (ngx_atomic_t *) (shared + 5 * 128);
-    ngx_stat_writing = (ngx_atomic_t *) (shared + 6 * 128);
+    ngx_stat_handled = (ngx_atomic_t *) (shared + 3 * 128);
+    ngx_stat_requests = (ngx_atomic_t *) (shared + 4 * 128);
+    ngx_stat_active = (ngx_atomic_t *) (shared + 5 * 128);
+    ngx_stat_reading = (ngx_atomic_t *) (shared + 6 * 128);
+    ngx_stat_writing = (ngx_atomic_t *) (shared + 7 * 128);
 
 #endif
 
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -442,6 +442,7 @@ extern ngx_int_t              ngx_accept
 #if (NGX_STAT_STUB)
 
 extern ngx_atomic_t  *ngx_stat_accepted;
+extern ngx_atomic_t  *ngx_stat_handled;
 extern ngx_atomic_t  *ngx_stat_requests;
 extern ngx_atomic_t  *ngx_stat_active;
 extern ngx_atomic_t  *ngx_stat_reading;
--- a/src/event/ngx_event_accept.c
+++ b/src/event/ngx_event_accept.c
@@ -118,6 +118,7 @@ ngx_event_accept(ngx_event_t *ev)
 
 #if (NGX_STAT_STUB)
         ngx_atomic_inc(ngx_stat_accepted);
+        ngx_atomic_inc(ngx_stat_active);
 #endif
 
         ngx_accept_disabled = (ngx_uint_t) s + NGX_ACCEPT_THRESHOLD
@@ -138,10 +139,6 @@ ngx_event_accept(ngx_event_t *ev)
             return;
         }
 
-#if (NGX_STAT_STUB)
-        ngx_atomic_inc(ngx_stat_active);
-#endif
-
         /* set a blocking mode for aio and non-blocking mode for others */
 
         if (ngx_inherited_nonblocking) {
@@ -263,6 +260,10 @@ ngx_event_accept(ngx_event_t *ev)
 
         c->number = ngx_atomic_inc(ngx_connection_counter);
 
+#if (NGX_STAT_STUB)
+        ngx_atomic_inc(ngx_stat_handled);
+#endif
+
 #if (NGX_THREADS)
         rev->lock = &c->lock;
         wev->lock = &c->lock;
@@ -452,6 +453,10 @@ ngx_close_accepted_socket(ngx_socket_t s
         ngx_log_error(NGX_LOG_ALERT, log, ngx_socket_errno,
                       ngx_close_socket_n " failed");
     }
+
+#if (NGX_STAT_STUB)
+    ngx_atomic_dec(ngx_stat_active);
+#endif
 }
 
 
--- a/src/http/modules/ngx_http_range_filter.c
+++ b/src/http/modules/ngx_http_range_filter.c
@@ -113,7 +113,7 @@ ngx_http_range_header_filter(ngx_http_re
     off_t                         start, end;
     ngx_int_t                     rc;
     ngx_uint_t                    suffix, i;
-    ngx_atomic_int_t              boundary;
+    ngx_atomic_uint_t             boundary;
     ngx_table_elt_t              *content_range;
     ngx_http_range_t             *range;
     ngx_http_range_filter_ctx_t  *ctx;
--- a/src/http/modules/ngx_http_stub_status_module.c
+++ b/src/http/modules/ngx_http_stub_status_module.c
@@ -47,11 +47,11 @@ ngx_module_t  ngx_http_stub_status_modul
 
 static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r)
 {
-    size_t        size;
-    ngx_int_t     rc;
-    uint32_t      ap, hn, ac, rq, rd, wr;
-    ngx_buf_t    *b;
-    ngx_chain_t   out;
+    size_t             size;
+    ngx_int_t          rc;
+    ngx_buf_t         *b;
+    ngx_chain_t        out;
+    ngx_atomic_int_t   ap, hn, ac, rq, rd, wr;
     
     if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) {
         return NGX_HTTP_NOT_ALLOWED;
@@ -83,10 +83,10 @@ static ngx_int_t ngx_http_status_handler
         }
     }
 
-    size = sizeof("Active connections:  \n") + NGX_INT32_LEN
+    size = sizeof("Active connections:  \n") + NGX_ATOMIC_T_LEN
            + sizeof("server accepts handled requests\n") - 1
-           + 6 + 3 * NGX_INT32_LEN
-           + sizeof("Reading:  Writing:  Waiting:  \n") + 3 * NGX_INT32_LEN;
+           + 6 + 3 * NGX_ATOMIC_T_LEN
+           + sizeof("Reading:  Writing:  Waiting:  \n") + 3 * NGX_ATOMIC_T_LEN;
 
     if (!(b = ngx_create_temp_buf(r->pool, size))) {
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -96,20 +96,20 @@ static ngx_int_t ngx_http_status_handler
     out.next = NULL;
 
     ap = *ngx_stat_accepted;
-    hn = *ngx_connection_counter;
+    hn = *ngx_stat_handled;
     ac = *ngx_stat_active;
     rq = *ngx_stat_requests;
     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: %A \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, " %A %A %A \n", ap, hn, rq);
 
-    b->last = ngx_sprintf(b->last, "Reading: %D Writing: %D Waiting: %d \n",
+    b->last = ngx_sprintf(b->last, "Reading: %A Writing: %A Waiting: %A \n",
                           rd, wr, ac - (rd + wr));
 
     r->headers_out.status = NGX_HTTP_OK;
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -148,7 +148,7 @@ void ngx_http_init_connection(ngx_connec
             ngx_mutex_unlock(ngx_posted_events_mutex);
 
 #if (NGX_STAT_STUB)
-        ngx_atomic_inc(ngx_stat_reading);
+            ngx_atomic_inc(ngx_stat_reading);
 #endif
             return;
         }
--- a/src/os/unix/ngx_atomic.h
+++ b/src/os/unix/ngx_atomic.h
@@ -16,8 +16,9 @@
 
 #define NGX_HAVE_ATOMIC_OPS  1
 
-typedef uint32_t  ngx_atomic_int_t;
-typedef volatile ngx_atomic_int_t  ngx_atomic_t;
+typedef int32_t  ngx_atomic_int_t;
+typedef uint32_t  ngx_atomic_uint_t;
+typedef volatile ngx_atomic_uint_t  ngx_atomic_t;
 #define NGX_ATOMIC_T_LEN  sizeof("-2147483648") - 1
 
 
@@ -31,12 +32,18 @@ typedef volatile ngx_atomic_int_t  ngx_a
  * 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.
+ *
+ * "xadd  r, [m]":
+ *
+ *     temp = [m];
+ *     [m] += r;
+ *     r = temp;
  */
 
-static ngx_inline ngx_atomic_int_t
+static ngx_inline ngx_atomic_uint_t
 ngx_atomic_inc(ngx_atomic_t *value)
 {
-    ngx_atomic_int_t  old;
+    ngx_atomic_uint_t  old;
 
     __asm__ volatile (
 
@@ -50,10 +57,10 @@ ngx_atomic_inc(ngx_atomic_t *value)
 }
 
 
-static ngx_inline ngx_atomic_int_t
+static ngx_inline ngx_atomic_uint_t
 ngx_atomic_dec(ngx_atomic_t *value)
 {
-    ngx_atomic_int_t  old;
+    ngx_atomic_uint_t  old;
 
     __asm__ volatile (
 
@@ -74,20 +81,20 @@ ngx_atomic_dec(ngx_atomic_t *value)
  *
  * "cmpxchg  r, [m]":
  *
- *   if (eax == [m]) {
- *       zf = 1;
- *       [m] = r;
- *   } else {
- *       zf = 0;
- *       eax = [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)
+static ngx_inline ngx_atomic_uint_t
+ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
+    ngx_atomic_uint_t set)
 {
-    ngx_atomic_int_t  res;
+    ngx_atomic_uint_t  res;
 
     __asm__ volatile (
 
@@ -107,7 +114,8 @@ ngx_atomic_cmp_set(ngx_atomic_t *lock, n
 #define NGX_HAVE_ATOMIC_OPS  1
 
 typedef int64_t  ngx_atomic_int_t;
-typedef volatile ngx_atomic_int_t  ngx_atomic_t;
+typedef uint64_t  ngx_atomic_uint_t;
+typedef volatile ngx_atomic_uint_t  ngx_atomic_t;
 #define NGX_ATOMIC_T_LEN  sizeof("-9223372036854775808") - 1
 
 
@@ -118,10 +126,10 @@ typedef volatile ngx_atomic_int_t  ngx_a
 #endif
 
 
-static ngx_inline ngx_atomic_int_t
+static ngx_inline ngx_atomic_uint_t
 ngx_atomic_inc(ngx_atomic_t *value)
 {
-    ngx_atomic_int_t  old;
+    ngx_atomic_uint_t  old;
 
     __asm__ volatile (
 
@@ -137,10 +145,10 @@ ngx_atomic_inc(ngx_atomic_t *value)
 
 /* the '"0" (-1LL)' parameter preloads -1 into the 64-bit %0 register */
 
-static ngx_inline ngx_atomic_int_t
+static ngx_inline ngx_atomic_uint_t
 ngx_atomic_dec(ngx_atomic_t *value)
 {
-    ngx_atomic_int_t  old;
+    ngx_atomic_uint_t  old;
 
     __asm__ volatile (
 
@@ -156,11 +164,11 @@ ngx_atomic_dec(ngx_atomic_t *value)
 
 /* 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)
+static ngx_inline ngx_atomic_uint_t
+ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
+    ngx_atomic_uint_t set)
 {
-    ngx_atomic_int_t  res;
+    ngx_atomic_uint_t  res;
 
     __asm__ volatile (
 
@@ -180,16 +188,18 @@ ngx_atomic_cmp_set(ngx_atomic_t *lock, n
 #define NGX_HAVE_ATOMIC_OPS  1
 
 #if (NGX_PTR_SIZE == 8)
-typedef uint64_t  ngx_atomic_int_t;
+typedef int64_t  ngx_atomic_int_t;
+typedef uint64_t  ngx_atomic_uint_t;
 #define NGX_ATOMIC_T_LEN  sizeof("-9223372036854775808") - 1
 #define NGX_CASXA         "casxa"
 #else
-typedef uint32_t  ngx_atomic_int_t;
+typedef int32_t  ngx_atomic_int_t;
+typedef uint32_t  ngx_atomic_uint_t;
 #define NGX_ATOMIC_T_LEN  sizeof("-2147483648") - 1
 #define NGX_CASXA         "casa"
 #endif
 
-typedef volatile ngx_atomic_int_t  ngx_atomic_t;
+typedef volatile ngx_atomic_uint_t  ngx_atomic_t;
 
 
 /*
@@ -207,10 +217,10 @@ typedef volatile ngx_atomic_int_t  ngx_a
  * so "r0 == r2" means that the operation was successfull.
  */
 
-static ngx_inline ngx_atomic_int_t
+static ngx_inline ngx_atomic_uint_t
 ngx_atomic_inc(ngx_atomic_t *value)
 {
-    ngx_atomic_int_t  old, new, res;
+    ngx_atomic_uint_t  old, new, res;
 
     old = *value;
 
@@ -234,10 +244,10 @@ ngx_atomic_inc(ngx_atomic_t *value)
 }
 
 
-static ngx_inline ngx_atomic_int_t
+static ngx_inline ngx_atomic_uint_t
 ngx_atomic_dec(ngx_atomic_t *value)
 {
-    ngx_atomic_int_t  old, new, res;
+    ngx_atomic_uint_t  old, new, res;
 
     old = *value;
 
@@ -261,8 +271,9 @@ ngx_atomic_dec(ngx_atomic_t *value)
 }
 
 
-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)
+static ngx_inline ngx_atomic_uint_t
+ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
+    ngx_atomic_uint_t set)
 {
     __asm__ volatile (
 
@@ -279,14 +290,16 @@ ngx_atomic_cmp_set(ngx_atomic_t *lock, n
 #define NGX_HAVE_ATOMIC_OPS  1
 
 #if (NGX_PTR_SIZE == 8)
-typedef uint64_t  ngx_atomic_int_t;
+typedef int64_t  ngx_atomic_int_t;
+typedef uint64_t  ngx_atomic_uint_t;
 #define NGX_ATOMIC_T_LEN  sizeof("-9223372036854775808") - 1
 #else
+typedef int32_t  ngx_atomic_int_t;
+typedef uint32_t  ngx_atomic_uint_t;
 #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;
+typedef volatile ngx_atomic_uint_t  ngx_atomic_t;
 
 
 /*
@@ -301,10 +314,10 @@ typedef volatile ngx_atomic_int_t  ngx_a
  * the nearest forward label "1".
  */
 
-static ngx_inline ngx_atomic_int_t
+static ngx_inline ngx_atomic_uint_t
 ngx_atomic_inc(ngx_atomic_t *value)
 {
-    ngx_atomic_int_t  res;
+    ngx_atomic_uint_t  res;
 
     __asm__ volatile (
 
@@ -321,10 +334,10 @@ ngx_atomic_inc(ngx_atomic_t *value)
 }
 
 
-static ngx_inline ngx_atomic_int_t
+static ngx_inline ngx_atomic_uint_t
 ngx_atomic_dec(ngx_atomic_t *value)
 {
-    ngx_atomic_int_t  res;
+    ngx_atomic_uint_t  res;
 
     __asm__ volatile (
 
@@ -341,11 +354,11 @@ ngx_atomic_dec(ngx_atomic_t *value)
 }
 
 
-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)
+static ngx_inline ngx_atomic_uint_t
+ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
+    ngx_atomic_uint_t set)
 {
-    ngx_atomic_int_t  res, temp;
+    ngx_atomic_uint_t  res, temp;
 
     __asm__ volatile (
 
@@ -372,15 +385,16 @@ ngx_atomic_cmp_set(ngx_atomic_t *lock, n
 
 #define NGX_HAVE_ATOMIC_OPS  0
 
-typedef uint32_t  ngx_atomic_int_t;
-typedef volatile ngx_atomic_int_t  ngx_atomic_t;
+typedef int32_t  ngx_atomic_int_t;
+typedef uint32_t  ngx_atomic_uint_t;
+typedef volatile ngx_atomic_uint_t  ngx_atomic_t;
 
 #define ngx_atomic_inc(x)  ++(*(x))
 #define ngx_atomic_dec(x)  --(*(x))
 
-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)
+static ngx_inline ngx_atomic_uint_t
+ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
+     ngx_atomic_uint_t set)
 {
      *lock = set;
      return 1;