diff --git a/src/ngx_http_vhost_traffic_status_node.c b/src/ngx_http_vhost_traffic_status_node.c index 6d0c948..22e3803 100644 --- a/src/ngx_http_vhost_traffic_status_node.c +++ b/src/ngx_http_vhost_traffic_status_node.c @@ -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) }, diff --git a/src/ngx_http_vhost_traffic_status_variables.c b/src/ngx_http_vhost_traffic_status_variables.c index e6e434e..1e71078 100644 --- a/src/ngx_http_vhost_traffic_status_variables.c +++ b/src/ngx_http_vhost_traffic_status_variables.c @@ -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); @@ -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; @@ -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;