[nginx] svn commit: r5116 - in trunk/src: core event http/modules
vbart at nginx.com
vbart at nginx.com
Fri Mar 15 20:00:49 UTC 2013
Author: vbart
Date: 2013-03-15 20:00:49 +0000 (Fri, 15 Mar 2013)
New Revision: 5116
URL: http://trac.nginx.org/nginx/changeset/5116/nginx
Log:
Status: introduced the "ngx_stat_waiting" counter.
And corresponding variable $connections_waiting was added.
Previously, waiting connections were counted as the difference between
active connections and the sum of reading and writing connections.
That made it impossible to count more than one request in one connection
as reading or writing (as is the case for SPDY).
Also, we no longer count connections in handshake state as waiting.
Modified:
trunk/src/core/ngx_connection.c
trunk/src/event/ngx_event.c
trunk/src/event/ngx_event.h
trunk/src/http/modules/ngx_http_stub_status_module.c
Modified: trunk/src/core/ngx_connection.c
===================================================================
--- trunk/src/core/ngx_connection.c 2013-03-15 19:49:54 UTC (rev 5115)
+++ trunk/src/core/ngx_connection.c 2013-03-15 20:00:49 UTC (rev 5116)
@@ -970,6 +970,10 @@
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_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
}
}
Modified: trunk/src/event/ngx_event.c
===================================================================
--- trunk/src/event/ngx_event.c 2013-03-15 19:49:54 UTC (rev 5115)
+++ trunk/src/event/ngx_event.c 2013-03-15 20:00:49 UTC (rev 5116)
@@ -73,6 +73,8 @@
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 @@
+ 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_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
Modified: trunk/src/event/ngx_event.h
===================================================================
--- trunk/src/event/ngx_event.h 2013-03-15 19:49:54 UTC (rev 5115)
+++ trunk/src/event/ngx_event.h 2013-03-15 20:00:49 UTC (rev 5116)
@@ -511,6 +511,7 @@
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
Modified: trunk/src/http/modules/ngx_http_stub_status_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_stub_status_module.c 2013-03-15 19:49:54 UTC (rev 5115)
+++ trunk/src/http/modules/ngx_http_stub_status_module.c 2013-03-15 20:00:49 UTC (rev 5116)
@@ -73,6 +73,9 @@
{ 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 @@
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 @@
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 @@
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 @@
value = *ngx_stat_writing;
break;
+ case 3:
+ value = *ngx_stat_waiting;
+ break;
+
/* suppress warning */
default:
value = 0;
More information about the nginx-devel
mailing list