diff options
| -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; } |
