diff options
| author | root <[email protected]> | 2023-12-15 10:50:52 +0000 |
|---|---|---|
| committer | root <[email protected]> | 2023-12-15 10:50:52 +0000 |
| commit | 55c8ad6b4c439b29f681a8c5e604646f81b8a768 (patch) | |
| tree | 3f04d8590b26c41bf735eb931865979a1c87f8f6 /shaping/src/main.cpp | |
| parent | 908b0f3a8e6a492b6ba185cda47beae3a5aef39d (diff) | |
global stat 由原子操作改为每个线程自己计数,每次输出时合并
Diffstat (limited to 'shaping/src/main.cpp')
| -rw-r--r-- | shaping/src/main.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/shaping/src/main.cpp b/shaping/src/main.cpp index 89cb176..d31f768 100644 --- a/shaping/src/main.cpp +++ b/shaping/src/main.cpp @@ -22,6 +22,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; snprintf(thread_name, sizeof(thread_name), "shape-work-%d", ctx->thread_index); prctl(PR_SET_NAME, (unsigned long long)thread_name, NULL, NULL, NULL); @@ -40,7 +41,7 @@ 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, ctx->global_stat->output_interval_s * 1000); + marsio_poll_wait(ctx->marsio_info->instance, &ctx->marsio_info->mr_dev, 1, ctx->thread_index, output_interval_s * 1000); } shaper_thread_resource_clear(); @@ -111,7 +112,7 @@ 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->global_stat); + shaper_global_stat_refresh(ctx); last_update_time = curr_time; } sleep(ctx->global_stat->output_interval_s); |
