Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/ngx_http_vhost_traffic_status_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,17 @@ ngx_http_vhost_traffic_status_member_t
NGX_HTTP_VHOST_TRAFFIC_STATUS_MEMBER_QUEUE,
ngx_vts_member(stat_request_times) },

/*
* These two have no variable because there is nothing for one to read.
* A variable is answered from the server zone of the request, and the
* upstream times are written to the node of the peer that served it, in
* shm.c. On a server zone they are the zeroes the node was created with,
* so a variable named here would report 0 for every request forever.
*
* set_by_filter can name them because it is given the zone to read, and
* an upstream zone is one of the zones it can be given.
*/

{ ngx_null_string, ngx_string("responseMsecCounter"), ngx_null_string,
NGX_HTTP_VHOST_TRAFFIC_STATUS_MEMBER_COUNTER,
ngx_vts_member(stat_upstream.response_time_counter) },
Expand Down
14 changes: 9 additions & 5 deletions src/ngx_http_vhost_traffic_status_variables.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ ngx_http_vhost_traffic_status_node_variable(ngx_http_request_t *r,
ngx_slab_pool_t *shpool;
ngx_rbtree_node_t *node;
ngx_http_vhost_traffic_status_node_t *vtsn;
ngx_http_vhost_traffic_status_member_t *m;
ngx_http_vhost_traffic_status_loc_conf_t *vtscf;

m = (ngx_http_vhost_traffic_status_member_t *) data;

vtscf = ngx_http_get_module_loc_conf(r, ngx_http_vhost_traffic_status_module);

ngx_http_vhost_traffic_status_find_name(r, &dst);
Expand Down Expand Up @@ -54,16 +57,17 @@ ngx_http_vhost_traffic_status_node_variable(ngx_http_request_t *r,

vtsn = (ngx_http_vhost_traffic_status_node_t *) &node->color;

if (data == offsetof(ngx_http_vhost_traffic_status_node_t, stat_request_times)) {
if (m->kind == NGX_HTTP_VHOST_TRAFFIC_STATUS_MEMBER_QUEUE) {

/* the queue is the value, there is no counter kept for it */

value = (ngx_atomic_t) ngx_http_vhost_traffic_status_node_time_queue_average(
&vtsn->stat_request_times, vtscf->average_method,
vtscf->average_period);
(ngx_http_vhost_traffic_status_node_time_queue_t *)
((char *) vtsn + m->offset),
vtscf->average_method, vtscf->average_period);

} else {
value = *((ngx_atomic_t *) ((char *) vtsn + data));
value = *((ngx_atomic_t *) ((char *) vtsn + m->offset));
}

v->len = ngx_sprintf(p, "%uA", value) - p;
Expand Down Expand Up @@ -117,7 +121,7 @@ ngx_http_vhost_traffic_status_add_variables(ngx_conf_t *cf)
}

var->get_handler = ngx_http_vhost_traffic_status_node_variable;
var->data = (uintptr_t) m->offset;
var->data = (uintptr_t) m;
}

return NGX_OK;
Expand Down