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.
This commit is contained in:
Igor Sysoev 2005-02-24 12:29:09 +00:00
parent 4dc57ba98f
commit 4a71559d9b
15 changed files with 164 additions and 112 deletions

View File

@ -5,40 +5,40 @@
cat << END >> $NGX_MAKEFILE cat << END >> $NGX_MAKEFILE
install: $NGX_OBJS${ngx_dirsep}nginx${ngx_binext} 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\"`" \ test -d '`dirname "$NGX_SBIN_PATH"`' \
|| mkdir -p "`dirname \"$NGX_SBIN_PATH\"`" || mkdir -p '`dirname "$NGX_SBIN_PATH"`'
test ! -f "$NGX_SBIN_PATH" || mv "$NGX_SBIN_PATH" "$NGX_SBIN_PATH.old" test ! -f '$NGX_SBIN_PATH' || mv '$NGX_SBIN_PATH' '$NGX_SBIN_PATH.old'
cp $NGX_OBJS/nginx "$NGX_SBIN_PATH" cp $NGX_OBJS/nginx '$NGX_SBIN_PATH'
test -d "`dirname \"$NGX_CONF_PATH\"`" \ test -d '`dirname "$NGX_CONF_PATH"`' \
|| mkdir -p "`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" || \ 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'
cp conf/mime.types "`dirname \"$NGX_CONF_PATH\"`/mime.types.default" cp conf/mime.types '`dirname "$NGX_CONF_PATH"`/mime.types.default'
test -f "$NGX_CONF_PATH" || cp conf/nginx.conf "$NGX_CONF_PATH" test -f '$NGX_CONF_PATH' || cp conf/nginx.conf '$NGX_CONF_PATH'
cp conf/nginx.conf "`dirname \"$NGX_CONF_PATH\"`/nginx.conf.default" cp conf/nginx.conf '`dirname "$NGX_CONF_PATH"`/nginx.conf.default'
test -d "`dirname \"$NGX_PID_PATH\"`" \ test -d '`dirname "$NGX_PID_PATH"`' \
|| mkdir -p "`dirname \"$NGX_PID_PATH\"`" || mkdir -p '`dirname "$NGX_PID_PATH"`'
test -d "`dirname \"$NGX_HTTP_LOG_PATH\"`" || \ test -d '`dirname "$NGX_HTTP_LOG_PATH"`' || \
mkdir -p "`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 END
if test -n "$NGX_ERROR_LOG_PATH"; then if test -n "$NGX_ERROR_LOG_PATH"; then
cat << END >> $NGX_MAKEFILE cat << END >> $NGX_MAKEFILE
test -d "`dirname \"$NGX_ERROR_LOG_PATH\"`" || \ test -d '`dirname "$NGX_ERROR_LOG_PATH"`' || \
mkdir -p "`dirname \"$NGX_ERROR_LOG_PATH\"`" mkdir -p '`dirname "$NGX_ERROR_LOG_PATH"`'
END END
fi fi

View File

@ -9,6 +9,34 @@
<title lang="en">nginx changelog</title> <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"> <changes ver="0.1.21" date="22.02.2005">
<change type="bugfix"> <change type="bugfix">

View File

@ -8,7 +8,7 @@
#define _NGINX_H_INCLUDED_ #define _NGINX_H_INCLUDED_
#define NGINX_VER "nginx/0.1.21" #define NGINX_VER "nginx/0.1.22"
#define NGINX_VAR "NGINX" #define NGINX_VAR "NGINX"
#define NGX_NEWPID_EXT ".newbin" #define NGX_NEWPID_EXT ".newbin"

View File

@ -114,7 +114,7 @@ struct ngx_connection_s {
ngx_buf_t *buffer; ngx_buf_t *buffer;
ngx_atomic_int_t number; ngx_atomic_uint_t number;
unsigned log_error:2; /* ngx_connection_log_error_e */ unsigned log_error:2; /* ngx_connection_log_error_e */

View File

@ -8,8 +8,8 @@
#include <ngx_core.h> #include <ngx_core.h>
static ngx_atomic_int_t ngx_temp_number; static ngx_atomic_uint_t ngx_temp_number;
static ngx_atomic_int_t ngx_random; static ngx_atomic_uint_t ngx_random;
ssize_t 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, ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path, ngx_pool_t *pool,
int persistent) int persistent)
{ {
ngx_err_t err; ngx_err_t err;
ngx_atomic_int_t n; ngx_atomic_uint_t n;
file->name.len = path->name.len + 1 + path->len + NGX_ATOMIC_T_LEN; 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) ngx_next_temp_number(ngx_uint_t collision)
{ {
if (collision) { if (collision) {

View File

@ -62,7 +62,7 @@ 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);
void ngx_init_temp_number(); 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); char *ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);

View File

@ -47,7 +47,7 @@ struct ngx_log_s {
ngx_uint_t log_level; ngx_uint_t log_level;
ngx_open_file_t *file; ngx_open_file_t *file;
ngx_atomic_int_t connection; ngx_atomic_uint_t connection;
ngx_log_handler_pt handler; ngx_log_handler_pt handler;
void *data; void *data;

View File

@ -54,7 +54,7 @@ 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|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]D int32_t/uint32_t
* %[0][width][u][x|X]L int64_t/uint64_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 * %P ngx_pid_t
* %r rlim_t * %r rlim_t
* %p pointer * %p pointer
@ -277,7 +277,7 @@ ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args)
if (sign) { if (sign) {
i64 = (int64_t) va_arg(args, ngx_atomic_int_t); i64 = (int64_t) va_arg(args, ngx_atomic_int_t);
} else { } else {
ui64 = (uint64_t) va_arg(args, ngx_atomic_int_t); ui64 = (uint64_t) va_arg(args, ngx_atomic_uint_t);
} }
if (max_width) { if (max_width) {

View File

@ -34,27 +34,29 @@ 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 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_uint_t ngx_event_flags;
ngx_event_actions_t ngx_event_actions; 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_connection_counter = &connection_counter;
ngx_atomic_t *ngx_accept_mutex_ptr; ngx_atomic_t *ngx_accept_mutex_ptr;
ngx_atomic_t *ngx_accept_mutex; ngx_atomic_t *ngx_accept_mutex;
ngx_uint_t ngx_accept_mutex_held; ngx_uint_t ngx_accept_mutex_held;
ngx_msec_t ngx_accept_mutex_delay; ngx_msec_t ngx_accept_mutex_delay;
ngx_int_t ngx_accept_disabled; ngx_int_t ngx_accept_disabled;
#if (NGX_STAT_STUB) #if (NGX_STAT_STUB)
ngx_atomic_t ngx_stat_accepted0; ngx_atomic_t ngx_stat_accepted0;
ngx_atomic_t *ngx_stat_accepted = &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_requests0;
ngx_atomic_t *ngx_stat_requests = &ngx_stat_requests0; ngx_atomic_t *ngx_stat_requests = &ngx_stat_requests0;
ngx_atomic_t ngx_stat_active0; ngx_atomic_t ngx_stat_active0;
@ -62,7 +64,7 @@ ngx_atomic_t *ngx_stat_active = &ngx_stat_active0;
ngx_atomic_t ngx_stat_reading0; ngx_atomic_t ngx_stat_reading0;
ngx_atomic_t *ngx_stat_reading = &ngx_stat_reading0; ngx_atomic_t *ngx_stat_reading = &ngx_stat_reading0;
ngx_atomic_t ngx_stat_writing0; 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 #endif
@ -209,6 +211,7 @@ static ngx_int_t ngx_event_module_init(ngx_cycle_t *cycle)
#if (NGX_STAT_STUB) #if (NGX_STAT_STUB)
size += 128 /* ngx_stat_accepted */ size += 128 /* ngx_stat_accepted */
+ 128 /* ngx_stat_handled */
+ 128 /* ngx_stat_requests */ + 128 /* ngx_stat_requests */
+ 128 /* ngx_stat_active */ + 128 /* ngx_stat_active */
+ 128 /* ngx_stat_reading */ + 128 /* ngx_stat_reading */
@ -226,10 +229,11 @@ static ngx_int_t ngx_event_module_init(ngx_cycle_t *cycle)
#if (NGX_STAT_STUB) #if (NGX_STAT_STUB)
ngx_stat_accepted = (ngx_atomic_t *) (shared + 2 * 128); ngx_stat_accepted = (ngx_atomic_t *) (shared + 2 * 128);
ngx_stat_requests = (ngx_atomic_t *) (shared + 3 * 128); ngx_stat_handled = (ngx_atomic_t *) (shared + 3 * 128);
ngx_stat_active = (ngx_atomic_t *) (shared + 4 * 128); ngx_stat_requests = (ngx_atomic_t *) (shared + 4 * 128);
ngx_stat_reading = (ngx_atomic_t *) (shared + 5 * 128); ngx_stat_active = (ngx_atomic_t *) (shared + 5 * 128);
ngx_stat_writing = (ngx_atomic_t *) (shared + 6 * 128); ngx_stat_reading = (ngx_atomic_t *) (shared + 6 * 128);
ngx_stat_writing = (ngx_atomic_t *) (shared + 7 * 128);
#endif #endif

View File

@ -442,6 +442,7 @@ extern ngx_int_t ngx_accept_disabled;
#if (NGX_STAT_STUB) #if (NGX_STAT_STUB)
extern ngx_atomic_t *ngx_stat_accepted; 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_requests;
extern ngx_atomic_t *ngx_stat_active; extern ngx_atomic_t *ngx_stat_active;
extern ngx_atomic_t *ngx_stat_reading; extern ngx_atomic_t *ngx_stat_reading;

View File

@ -118,6 +118,7 @@ ngx_event_accept(ngx_event_t *ev)
#if (NGX_STAT_STUB) #if (NGX_STAT_STUB)
ngx_atomic_inc(ngx_stat_accepted); ngx_atomic_inc(ngx_stat_accepted);
ngx_atomic_inc(ngx_stat_active);
#endif #endif
ngx_accept_disabled = (ngx_uint_t) s + NGX_ACCEPT_THRESHOLD ngx_accept_disabled = (ngx_uint_t) s + NGX_ACCEPT_THRESHOLD
@ -138,10 +139,6 @@ ngx_event_accept(ngx_event_t *ev)
return; return;
} }
#if (NGX_STAT_STUB)
ngx_atomic_inc(ngx_stat_active);
#endif
/* set a blocking mode for aio and non-blocking mode for others */ /* set a blocking mode for aio and non-blocking mode for others */
if (ngx_inherited_nonblocking) { if (ngx_inherited_nonblocking) {
@ -263,6 +260,10 @@ ngx_event_accept(ngx_event_t *ev)
c->number = ngx_atomic_inc(ngx_connection_counter); c->number = ngx_atomic_inc(ngx_connection_counter);
#if (NGX_STAT_STUB)
ngx_atomic_inc(ngx_stat_handled);
#endif
#if (NGX_THREADS) #if (NGX_THREADS)
rev->lock = &c->lock; rev->lock = &c->lock;
wev->lock = &c->lock; wev->lock = &c->lock;
@ -452,6 +453,10 @@ ngx_close_accepted_socket(ngx_socket_t s, ngx_log_t *log)
ngx_log_error(NGX_LOG_ALERT, log, ngx_socket_errno, ngx_log_error(NGX_LOG_ALERT, log, ngx_socket_errno,
ngx_close_socket_n " failed"); ngx_close_socket_n " failed");
} }
#if (NGX_STAT_STUB)
ngx_atomic_dec(ngx_stat_active);
#endif
} }

View File

@ -113,7 +113,7 @@ ngx_http_range_header_filter(ngx_http_request_t *r)
off_t start, end; off_t start, end;
ngx_int_t rc; ngx_int_t rc;
ngx_uint_t suffix, i; ngx_uint_t suffix, i;
ngx_atomic_int_t boundary; ngx_atomic_uint_t boundary;
ngx_table_elt_t *content_range; ngx_table_elt_t *content_range;
ngx_http_range_t *range; ngx_http_range_t *range;
ngx_http_range_filter_ctx_t *ctx; ngx_http_range_filter_ctx_t *ctx;

View File

@ -47,11 +47,11 @@ ngx_module_t ngx_http_stub_status_module = {
static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r) static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r)
{ {
size_t size; size_t size;
ngx_int_t rc; ngx_int_t rc;
uint32_t ap, hn, ac, rq, rd, wr; ngx_buf_t *b;
ngx_buf_t *b; ngx_chain_t out;
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) { if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) {
return NGX_HTTP_NOT_ALLOWED; return NGX_HTTP_NOT_ALLOWED;
@ -83,10 +83,10 @@ static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r)
} }
} }
size = sizeof("Active connections: \n") + NGX_INT32_LEN size = sizeof("Active connections: \n") + NGX_ATOMIC_T_LEN
+ sizeof("server accepts handled requests\n") - 1 + sizeof("server accepts handled requests\n") - 1
+ 6 + 3 * NGX_INT32_LEN + 6 + 3 * NGX_ATOMIC_T_LEN
+ sizeof("Reading: Writing: Waiting: \n") + 3 * NGX_INT32_LEN; + sizeof("Reading: Writing: Waiting: \n") + 3 * NGX_ATOMIC_T_LEN;
if (!(b = ngx_create_temp_buf(r->pool, size))) { if (!(b = ngx_create_temp_buf(r->pool, size))) {
return NGX_HTTP_INTERNAL_SERVER_ERROR; return NGX_HTTP_INTERNAL_SERVER_ERROR;
@ -96,20 +96,20 @@ static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r)
out.next = NULL; out.next = NULL;
ap = *ngx_stat_accepted; ap = *ngx_stat_accepted;
hn = *ngx_connection_counter; hn = *ngx_stat_handled;
ac = *ngx_stat_active; ac = *ngx_stat_active;
rq = *ngx_stat_requests; rq = *ngx_stat_requests;
rd = *ngx_stat_reading; rd = *ngx_stat_reading;
wr = *ngx_stat_writing; 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", b->last = ngx_cpymem(b->last, "server accepts handled requests\n",
sizeof("server accepts handled requests\n") - 1); 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)); rd, wr, ac - (rd + wr));
r->headers_out.status = NGX_HTTP_OK; r->headers_out.status = NGX_HTTP_OK;

View File

@ -148,7 +148,7 @@ void ngx_http_init_connection(ngx_connection_t *c)
ngx_mutex_unlock(ngx_posted_events_mutex); ngx_mutex_unlock(ngx_posted_events_mutex);
#if (NGX_STAT_STUB) #if (NGX_STAT_STUB)
ngx_atomic_inc(ngx_stat_reading); ngx_atomic_inc(ngx_stat_reading);
#endif #endif
return; return;
} }

View File

@ -16,8 +16,9 @@
#define NGX_HAVE_ATOMIC_OPS 1 #define NGX_HAVE_ATOMIC_OPS 1
typedef uint32_t ngx_atomic_int_t; typedef int32_t ngx_atomic_int_t;
typedef volatile ngx_atomic_int_t ngx_atomic_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 #define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1
@ -31,12 +32,18 @@ typedef volatile ngx_atomic_int_t ngx_atomic_t;
* the "=q" is any of the %eax, %ebx, %ecx, or %edx registers. * the "=q" is any of the %eax, %ebx, %ecx, or %edx registers.
* the '"0" (1)' parameter preloads 1 into %0. * the '"0" (1)' parameter preloads 1 into %0.
* the "cc" means that flags were changed. * 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_inc(ngx_atomic_t *value)
{ {
ngx_atomic_int_t old; ngx_atomic_uint_t old;
__asm__ volatile ( __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_dec(ngx_atomic_t *value)
{ {
ngx_atomic_int_t old; ngx_atomic_uint_t old;
__asm__ volatile ( __asm__ volatile (
@ -74,20 +81,20 @@ ngx_atomic_dec(ngx_atomic_t *value)
* *
* "cmpxchg r, [m]": * "cmpxchg r, [m]":
* *
* if (eax == [m]) { * if (eax == [m]) {
* zf = 1; * zf = 1;
* [m] = r; * [m] = r;
* } else { * } else {
* zf = 0; * zf = 0;
* eax = [m]; * eax = [m];
* } * }
*/ */
static ngx_inline ngx_atomic_int_t static ngx_inline ngx_atomic_uint_t
ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_int_t old, ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
ngx_atomic_int_t set) ngx_atomic_uint_t set)
{ {
ngx_atomic_int_t res; ngx_atomic_uint_t res;
__asm__ volatile ( __asm__ volatile (
@ -107,7 +114,8 @@ ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_int_t old,
#define NGX_HAVE_ATOMIC_OPS 1 #define NGX_HAVE_ATOMIC_OPS 1
typedef int64_t ngx_atomic_int_t; 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 #define NGX_ATOMIC_T_LEN sizeof("-9223372036854775808") - 1
@ -118,10 +126,10 @@ typedef volatile ngx_atomic_int_t ngx_atomic_t;
#endif #endif
static ngx_inline ngx_atomic_int_t static ngx_inline ngx_atomic_uint_t
ngx_atomic_inc(ngx_atomic_t *value) ngx_atomic_inc(ngx_atomic_t *value)
{ {
ngx_atomic_int_t old; ngx_atomic_uint_t old;
__asm__ volatile ( __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 */ /* 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_dec(ngx_atomic_t *value)
{ {
ngx_atomic_int_t old; ngx_atomic_uint_t old;
__asm__ volatile ( __asm__ volatile (
@ -156,11 +164,11 @@ ngx_atomic_dec(ngx_atomic_t *value)
/* the "=a" and "a" are the %rax register. */ /* the "=a" and "a" are the %rax register. */
static ngx_inline ngx_atomic_int_t static ngx_inline ngx_atomic_uint_t
ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_int_t old, ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
ngx_atomic_int_t set) ngx_atomic_uint_t set)
{ {
ngx_atomic_int_t res; ngx_atomic_uint_t res;
__asm__ volatile ( __asm__ volatile (
@ -180,16 +188,18 @@ ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_int_t old,
#define NGX_HAVE_ATOMIC_OPS 1 #define NGX_HAVE_ATOMIC_OPS 1
#if (NGX_PTR_SIZE == 8) #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_ATOMIC_T_LEN sizeof("-9223372036854775808") - 1
#define NGX_CASXA "casxa" #define NGX_CASXA "casxa"
#else #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_ATOMIC_T_LEN sizeof("-2147483648") - 1
#define NGX_CASXA "casa" #define NGX_CASXA "casa"
#endif #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_atomic_t;
* so "r0 == r2" means that the operation was successfull. * 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_inc(ngx_atomic_t *value)
{ {
ngx_atomic_int_t old, new, res; ngx_atomic_uint_t old, new, res;
old = *value; 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_dec(ngx_atomic_t *value)
{ {
ngx_atomic_int_t old, new, res; ngx_atomic_uint_t old, new, res;
old = *value; old = *value;
@ -261,8 +271,9 @@ ngx_atomic_dec(ngx_atomic_t *value)
} }
static ngx_inline ngx_atomic_int_t static ngx_inline ngx_atomic_uint_t
ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_int_t old, ngx_atomic_int_t set) ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
ngx_atomic_uint_t set)
{ {
__asm__ volatile ( __asm__ volatile (
@ -279,14 +290,16 @@ ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_int_t old, ngx_atomic_int_t se
#define NGX_HAVE_ATOMIC_OPS 1 #define NGX_HAVE_ATOMIC_OPS 1
#if (NGX_PTR_SIZE == 8) #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_ATOMIC_T_LEN sizeof("-9223372036854775808") - 1
#else #else
typedef int32_t ngx_atomic_int_t;
typedef uint32_t ngx_atomic_uint_t;
#define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1 #define NGX_ATOMIC_T_LEN sizeof("-2147483648") - 1
typedef uint32_t ngx_atomic_int_t;
#endif #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_atomic_t;
* the nearest forward label "1". * 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_inc(ngx_atomic_t *value)
{ {
ngx_atomic_int_t res; ngx_atomic_uint_t res;
__asm__ volatile ( __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_dec(ngx_atomic_t *value)
{ {
ngx_atomic_int_t res; ngx_atomic_uint_t res;
__asm__ volatile ( __asm__ volatile (
@ -341,11 +354,11 @@ ngx_atomic_dec(ngx_atomic_t *value)
} }
static ngx_inline ngx_atomic_int_t static ngx_inline ngx_atomic_uint_t
ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_int_t old, ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
ngx_atomic_int_t set) ngx_atomic_uint_t set)
{ {
ngx_atomic_int_t res, temp; ngx_atomic_uint_t res, temp;
__asm__ volatile ( __asm__ volatile (
@ -372,15 +385,16 @@ ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_int_t old,
#define NGX_HAVE_ATOMIC_OPS 0 #define NGX_HAVE_ATOMIC_OPS 0
typedef uint32_t ngx_atomic_int_t; typedef int32_t ngx_atomic_int_t;
typedef volatile ngx_atomic_int_t ngx_atomic_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_inc(x) ++(*(x))
#define ngx_atomic_dec(x) --(*(x)) #define ngx_atomic_dec(x) --(*(x))
static ngx_inline ngx_atomic_int_t static ngx_inline ngx_atomic_uint_t
ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_int_t old, ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
ngx_atomic_int_t set) ngx_atomic_uint_t set)
{ {
*lock = set; *lock = set;
return 1; return 1;