diff options
| author | 刘畅 <[email protected]> | 2024-01-08 08:24:58 +0000 |
|---|---|---|
| committer | 刘畅 <[email protected]> | 2024-01-08 08:24:58 +0000 |
| commit | 7c599b8c88ecc009651062eddbff0b07909b8928 (patch) | |
| tree | 44c201c29523b1d92bde498ba10f5cbd0d5a3c88 | |
| parent | 926d48d5f2c3d5a53484554b042e795e1b358eb9 (diff) | |
| parent | 83875395f362d9fa6a9e049a0a36b94158a38b83 (diff) | |
Merge branch 'bugfix_fix_refresh_stat_by_timeout' into 'rel'v3.1.19
fix some long session don't refresh stat in time
See merge request tango/shaping-engine!69
| -rw-r--r-- | shaping/src/shaper.cpp | 15 | ||||
| -rw-r--r-- | shaping/src/shaper_global_stat.cpp | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/shaping/src/shaper.cpp b/shaping/src/shaper.cpp index 0977213..5a53232 100644 --- a/shaping/src/shaper.cpp +++ b/shaping/src/shaper.cpp @@ -1075,7 +1075,7 @@ END: shaper_stat_refresh(ctx, sf, ctx->thread_index, 0); time_t curr_time = time(NULL); if (curr_time > sf->last_update_timeout_sec) { - timeouts_add(ctx->expires, &sf->timeout_handle, curr_time + SHAPING_STAT_REFRESH_INTERVAL_SEC); + timeouts_add(ctx->expires, &sf->timeout_handle, curr_time + SHAPING_STAT_REFRESH_INTERVAL_SEC);//timeouts_add will delete if sf exist, then add sf->last_update_timeout_sec = curr_time; } @@ -1100,7 +1100,6 @@ void polling_entry(struct shaper *sp, struct shaping_stat *stat, struct shaping_ { swarmkv_caller_loop(ctx->swarmkv_db, SWARMKV_LOOP_NONBLOCK, NULL); - struct timeout *t = NULL; struct shaping_flow *sf = NULL; time_t curr_time = time(NULL); int cnt = 0; @@ -1110,12 +1109,16 @@ void polling_entry(struct shaper *sp, struct shaping_stat *stat, struct shaping_ ctx->last_update_timeout_sec = curr_time; } - t = timeouts_get(ctx->expires); - while (t && cnt < SHAPING_STAT_REFRESH_MAX_PER_POLLING) { + while (cnt < SHAPING_STAT_REFRESH_MAX_PER_POLLING) { + struct timeout *t = NULL; + t = timeouts_get(ctx->expires); + if (!t) { + break; + } + sf = container_of(t, struct shaping_flow, timeout_handle); shaper_stat_refresh(ctx, sf, ctx->thread_index, 0); - timeouts_add(ctx->expires, &sf->timeout_handle, time(NULL) + SHAPING_STAT_REFRESH_INTERVAL_SEC); - t = timeouts_get(ctx->expires); + timeouts_add(ctx->expires, &sf->timeout_handle, time(NULL) + SHAPING_STAT_REFRESH_INTERVAL_SEC);//timeouts_get will delete sf from queue, add it back cnt++; } diff --git a/shaping/src/shaper_global_stat.cpp b/shaping/src/shaper_global_stat.cpp index 03a913f..7144658 100644 --- a/shaping/src/shaper_global_stat.cpp +++ b/shaping/src/shaper_global_stat.cpp @@ -260,7 +260,7 @@ void shaper_global_stat_tconsume_callback_inc(struct shaping_global_stat_data *t void shaper_global_stat_hincrby_invoke_inc(struct shaping_global_stat_data *thread_global_stat) { - thread_global_stat->async_hmget_invoke++; + thread_global_stat->async_hincrby_invoke++; return; } |
