Welcome! Log In Create A New Profile

Advanced

[nginx] svn commit: r5080 - trunk/src/http/modules

Anonymous User
February 21, 2013 06:34PM
Author: defan
Date: 2013-02-21 23:31:57 +0000 (Thu, 21 Feb 2013)
New Revision: 5080
URL: http://trac.nginx.org/nginx/changeset/5080/nginx

Log:
Introduced variables in ngx_http_stub_status module.

Three new variables were added: $connections_active, $connections_reading
and $connections_writing.


Modified:
trunk/src/http/modules/ngx_http_stub_status_module.c

Modified: trunk/src/http/modules/ngx_http_stub_status_module.c
===================================================================
--- trunk/src/http/modules/ngx_http_stub_status_module.c 2013-02-20 16:41:05 UTC (rev 5079)
+++ trunk/src/http/modules/ngx_http_stub_status_module.c 2013-02-21 23:31:57 UTC (rev 5080)
@@ -10,6 +10,10 @@
#include <ngx_http.h>


+static ngx_int_t ngx_http_stub_status_variable(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_http_stub_status_add_variables(ngx_conf_t *cf);
+
static char *ngx_http_set_status(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);

@@ -28,7 +32,7 @@


static ngx_http_module_t ngx_http_stub_status_module_ctx = {
- NULL, /* preconfiguration */
+ ngx_http_stub_status_add_variables, /* preconfiguration */
NULL, /* postconfiguration */

NULL, /* create main configuration */
@@ -58,6 +62,21 @@
};


+static ngx_http_variable_t ngx_http_stub_status_vars[] = {
+
+ { ngx_string("connections_active"), NULL, ngx_http_stub_status_variable,
+ 0, NGX_HTTP_VAR_NOCACHEABLE, 0 },
+
+ { ngx_string("connections_reading"), NULL, ngx_http_stub_status_variable,
+ 1, NGX_HTTP_VAR_NOCACHEABLE, 0 },
+
+ { ngx_string("connections_writing"), NULL, ngx_http_stub_status_variable,
+ 2, NGX_HTTP_VAR_NOCACHEABLE, 0 },
+
+ { ngx_null_string, NULL, NULL, 0, 0, 0 }
+};
+
+
static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r)
{
size_t size;
@@ -133,6 +152,66 @@
}


+static ngx_int_t
+ngx_http_stub_status_variable(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data)
+{
+ u_char *p;
+ ngx_atomic_int_t value;
+
+ p = ngx_pnalloc(r->pool, NGX_ATOMIC_T_LEN);
+ if (p == NULL) {
+ return NGX_ERROR;
+ }
+
+ switch (data) {
+ case 0:
+ value = *ngx_stat_active;
+ break;
+
+ case 1:
+ value = *ngx_stat_reading;
+ break;
+
+ case 2:
+ value = *ngx_stat_writing;
+ break;
+
+ /* suppress warning */
+ default:
+ value = 0;
+ break;
+ }
+
+ v->len = ngx_sprintf(p, "%uA", value) - p;
+ v->valid = 1;
+ v->no_cacheable = 0;
+ v->not_found = 0;
+ v->data = p;
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
+ngx_http_stub_status_add_variables(ngx_conf_t *cf)
+{
+ ngx_http_variable_t *var, *v;
+
+ for (v = ngx_http_stub_status_vars; v->name.len; v++) {
+ var = ngx_http_add_variable(cf, &v->name, v->flags);
+ if (var == NULL) {
+ return NGX_ERROR;
+ }
+
+ var->get_handler = v->get_handler;
+ var->data = v->data;
+ }
+
+ return NGX_OK;
+}
+
+
static char *ngx_http_set_status(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_http_core_loc_conf_t *clcf;

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] svn commit: r5080 - trunk/src/http/modules

Anonymous User 1103 February 21, 2013 06:34PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 254
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready