aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/ngx_connection.c8
-rw-r--r--src/event/ngx_event.c6
-rw-r--r--src/event/ngx_event.h1
-rw-r--r--src/http/modules/ngx_http_stub_status_module.c12
4 files changed, 24 insertions, 3 deletions
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index 09ad15fcc..60f4d5145 100644
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -970,6 +970,10 @@ ngx_reusable_connection(ngx_connection_t *c, ngx_uint_t reusable)
if (c->reusable) {
ngx_queue_remove(&c->queue);
+
+#if (NGX_STAT_STUB)
+ (void) ngx_atomic_fetch_add(ngx_stat_waiting, -1);
+#endif
}
c->reusable = reusable;
@@ -979,6 +983,10 @@ ngx_reusable_connection(ngx_connection_t *c, ngx_uint_t reusable)
ngx_queue_insert_head(
(ngx_queue_t *) &ngx_cycle->reusable_connections_queue, &c->queue);
+
+#if (NGX_STAT_STUB)
+ (void) ngx_atomic_fetch_add(ngx_stat_waiting, 1);
+#endif
}
}
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c
index cbae0ee6a..b7205f45b 100644
--- a/src/event/ngx_event.c
+++ b/src/event/ngx_event.c
@@ -73,6 +73,8 @@ 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_writing0;
+ngx_atomic_t ngx_stat_waiting0;
+ngx_atomic_t *ngx_stat_waiting = &ngx_stat_waiting0;
#endif
@@ -511,7 +513,8 @@ ngx_event_module_init(ngx_cycle_t *cycle)
+ cl /* ngx_stat_requests */
+ cl /* ngx_stat_active */
+ cl /* ngx_stat_reading */
- + cl; /* ngx_stat_writing */
+ + cl /* ngx_stat_writing */
+ + cl; /* ngx_stat_waiting */
#endif
@@ -558,6 +561,7 @@ ngx_event_module_init(ngx_cycle_t *cycle)
ngx_stat_active = (ngx_atomic_t *) (shared + 6 * cl);
ngx_stat_reading = (ngx_atomic_t *) (shared + 7 * cl);
ngx_stat_writing = (ngx_atomic_t *) (shared + 8 * cl);
+ ngx_stat_waiting = (ngx_atomic_t *) (shared + 9 * cl);
#endif
diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h
index 2096da234..93c457c7b 100644
--- a/src/event/ngx_event.h
+++ b/src/event/ngx_event.h
@@ -511,6 +511,7 @@ extern ngx_atomic_t *ngx_stat_requests;
extern ngx_atomic_t *ngx_stat_active;
extern ngx_atomic_t *ngx_stat_reading;
extern ngx_atomic_t *ngx_stat_writing;
+extern ngx_atomic_t *ngx_stat_waiting;
#endif
diff --git a/src/http/modules/ngx_http_stub_status_module.c b/src/http/modules/ngx_http_stub_status_module.c
index e2ac94928..83a35cda8 100644
--- a/src/http/modules/ngx_http_stub_status_module.c
+++ b/src/http/modules/ngx_http_stub_status_module.c
@@ -73,6 +73,9 @@ static ngx_http_variable_t ngx_http_stub_status_vars[] = {
{ ngx_string("connections_writing"), NULL, ngx_http_stub_status_variable,
2, NGX_HTTP_VAR_NOCACHEABLE, 0 },
+ { ngx_string("connections_waiting"), NULL, ngx_http_stub_status_variable,
+ 3, NGX_HTTP_VAR_NOCACHEABLE, 0 },
+
{ ngx_null_string, NULL, NULL, 0, 0, 0 }
};
@@ -83,7 +86,7 @@ static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r)
ngx_int_t rc;
ngx_buf_t *b;
ngx_chain_t out;
- ngx_atomic_int_t ap, hn, ac, rq, rd, wr;
+ ngx_atomic_int_t ap, hn, ac, rq, rd, wr, wa;
if (r->method != NGX_HTTP_GET && r->method != NGX_HTTP_HEAD) {
return NGX_HTTP_NOT_ALLOWED;
@@ -126,6 +129,7 @@ static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r)
rq = *ngx_stat_requests;
rd = *ngx_stat_reading;
wr = *ngx_stat_writing;
+ wa = *ngx_stat_waiting;
b->last = ngx_sprintf(b->last, "Active connections: %uA \n", ac);
@@ -135,7 +139,7 @@ static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r)
b->last = ngx_sprintf(b->last, " %uA %uA %uA \n", ap, hn, rq);
b->last = ngx_sprintf(b->last, "Reading: %uA Writing: %uA Waiting: %uA \n",
- rd, wr, ac - (rd + wr));
+ rd, wr, wa);
r->headers_out.status = NGX_HTTP_OK;
r->headers_out.content_length_n = b->last - b->pos;
@@ -177,6 +181,10 @@ ngx_http_stub_status_variable(ngx_http_request_t *r,
value = *ngx_stat_writing;
break;
+ case 3:
+ value = *ngx_stat_waiting;
+ break;
+
/* suppress warning */
default:
value = 0;