diff options
Diffstat (limited to 'plugin/business/tsg-http/src/tsg_http.cpp')
| -rw-r--r-- | plugin/business/tsg-http/src/tsg_http.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/plugin/business/tsg-http/src/tsg_http.cpp b/plugin/business/tsg-http/src/tsg_http.cpp index d3443e5..26cc7ac 100644 --- a/plugin/business/tsg-http/src/tsg_http.cpp +++ b/plugin/business/tsg-http/src/tsg_http.cpp @@ -152,7 +152,7 @@ struct tsg_proxy_rt int plolicy_table_id[POLICY_PROFILE_TABLE_MAX]; ctemplate::Template * tpl_403, * tpl_404, * tpl_451; - screen_stat_handle_t fs_handle; + struct fieldstat_easy *fs_handle; long long stat_val[__PX_STAT_MAX]; int fs_id[__PX_STAT_MAX]; struct event_base* gc_evbase; @@ -167,15 +167,13 @@ struct tsg_proxy_rt }; struct tsg_proxy_rt * g_proxy_rt; -static void proxy_http_gc_cb(evutil_socket_t fd, short what, void * arg) +static void proxy_http_gc_cb(evutil_socket_t fd, short what, void *arg) { - int i=0; - - for(i=0;i<__PX_STAT_MAX;i++) + for (int i = 0; i < __PX_STAT_MAX; i++) { - FS_operate(g_proxy_rt->fs_handle, g_proxy_rt->fs_id[i], 0, FS_OP_SET, ATOMIC_READ(&(g_proxy_rt->stat_val[i]))); + long long delta = ATOMIC_EXCHANGE(&(g_proxy_rt->stat_val[i]), 0); + fieldstat_easy_counter_incrby(g_proxy_rt->fs_handle, 0, g_proxy_rt->fs_id[i], NULL, 0, delta); } - return; } static void proxy_http_stat_init(struct tsg_proxy_rt * pangu_runtime) @@ -200,9 +198,9 @@ static void proxy_http_stat_init(struct tsg_proxy_rt * pangu_runtime) for(i=0;i<__PX_STAT_MAX;i++) { - if(spec[i]!=NULL) + if (spec[i] != NULL) { - pangu_runtime->fs_id[i]=FS_register(pangu_runtime->fs_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, spec[i]); + pangu_runtime->fs_id[i] = fieldstat_easy_register_counter(pangu_runtime->fs_handle, spec[i]); } } g_proxy_rt->gcev = event_new(pangu_runtime->gc_evbase, -1, EV_PERSIST, proxy_http_gc_cb, NULL); |
