summaryrefslogtreecommitdiff
path: root/shaping/src/main.cpp
diff options
context:
space:
mode:
authorroot <[email protected]>2024-07-19 10:02:16 +0000
committerroot <[email protected]>2024-07-19 10:02:16 +0000
commit782ee7558dc53f308edd9c0ad1813d43bb22b33c (patch)
tree5b498dd644f91b40635c446f5580fd568b2e2e2a /shaping/src/main.cpp
parent50c554ee4ec2ae89cba124605775995f8afeb34f (diff)
update to fieldstat4, not complete
Diffstat (limited to 'shaping/src/main.cpp')
-rw-r--r--shaping/src/main.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/shaping/src/main.cpp b/shaping/src/main.cpp
index 597230b..6d210ea 100644
--- a/shaping/src/main.cpp
+++ b/shaping/src/main.cpp
@@ -23,6 +23,7 @@ static void *shaper_thread_loop(void *data)
char thread_name[16] = {0};
struct shaping_thread_ctx *ctx = (struct shaping_thread_ctx *)data;
int output_interval_s = ctx->ref_ctx->global_stat->output_interval_s;
+ time_t last_refresh_stat_time = time(NULL);
snprintf(thread_name, sizeof(thread_name), "shape-work-%d", ctx->thread_index);
prctl(PR_SET_NAME, (unsigned long long)thread_name, NULL, NULL, NULL);
@@ -41,7 +42,14 @@ static void *shaper_thread_loop(void *data)
session_table_reset_with_callback(ctx->session_table, shaper_session_data_free_cb, ctx);
__atomic_fetch_and(&ctx->session_need_reset, 0, __ATOMIC_SEQ_CST);
}
- marsio_poll_wait(ctx->marsio_info->instance, &ctx->marsio_info->mr_dev, 1, ctx->thread_index, output_interval_s);
+
+ time_t curr_time = time(NULL);
+ if (curr_time - last_refresh_stat_time >= output_interval_s) {
+ shaper_thread_global_stat_refresh(ctx);
+ last_refresh_stat_time = curr_time;
+ }
+
+ marsio_poll_wait(ctx->marsio_info->instance, &ctx->marsio_info->mr_dev, 1, ctx->thread_index, 10);
}
shaper_thread_resource_clear();
@@ -68,7 +76,7 @@ static void sig_handler(int signo)
int main(int argc, char **argv)
{
struct shaping_ctx *ctx = NULL;
- time_t last_update_time = time(NULL);
+ time_t last_stat_update_time = time(NULL);
if (LOG_INIT("./conf/zlog.conf") == -1)
{
@@ -111,11 +119,13 @@ int main(int argc, char **argv)
while(!quit) {
time_t curr_time = time(NULL);
- if (curr_time - last_update_time >= ctx->global_stat->output_interval_s) {
- shaper_global_stat_refresh(ctx);
- last_update_time = curr_time;
+
+ if (curr_time - last_stat_update_time >= ctx->stat->output_interval_s) {
+ shaper_stat_output(ctx->stat);
+ last_stat_update_time = curr_time;
}
- sleep(ctx->global_stat->output_interval_s);
+
+ sleep(ctx->stat->output_interval_s);
}
for (int i = 0; i < ctx->thread_num; i++) {