diff options
| author | root <[email protected]> | 2024-04-08 09:32:19 +0000 |
|---|---|---|
| committer | root <[email protected]> | 2024-04-08 09:32:19 +0000 |
| commit | 08b07394e024de27b825de3261a09b510e726284 (patch) | |
| tree | 36847aeff4812c86188307a3565b0690eb882393 | |
| parent | 4f37764594ab56ad610924fe9ad98ceb19793832 (diff) | |
TSG-19771: 将profile配置刷新周期改为500ms
| -rw-r--r-- | shaping/include/shaper.h | 2 | ||||
| -rw-r--r-- | shaping/src/shaper.cpp | 13 |
2 files changed, 8 insertions, 7 deletions
diff --git a/shaping/include/shaper.h b/shaping/include/shaper.h index bf6bd3a..46bc07f 100644 --- a/shaping/include/shaper.h +++ b/shaping/include/shaper.h @@ -125,7 +125,7 @@ struct shaping_profile_hash_node { long long priority_blocked_time_ms[SHAPING_PRIORITY_NUM_MAX]; int hmget_ref_cnt; int tconsume_ref_cnt; - time_t last_refresh_time_s; + unsigned long long last_refresh_time_ms; struct shaper_token_multiple token_multiple; struct shaper_aqm_blue_para aqm_blue_para; struct shaper_aqm_codel_para aqm_codel_para; diff --git a/shaping/src/shaper.cpp b/shaping/src/shaper.cpp index 09e2b28..66594f0 100644 --- a/shaping/src/shaper.cpp +++ b/shaping/src/shaper.cpp @@ -30,7 +30,7 @@ extern "C" { #define HMGET_REQUEST_INTERVAL_MS 10 #define PRIORITY_BLOCK_MIN_TIME_MS 500 -#define PROFILE_HASH_NODE_REFRESH_SEC 5 +#define PROFILE_HASH_NODE_REFRESH_MS 500 #define SWARMKV_CALLER_LOOP_DIVISOR_MIN 1 #define SWARMKV_CALLER_LOOP_DIVISOR_MAX 10 @@ -571,10 +571,11 @@ static int shaper_deposit_token_get(struct shaping_profile_info *profile, int re return -1; } -static void shaper_profile_hash_node_refresh(struct shaping_thread_ctx *ctx, struct shaping_profile_hash_node *pf_hash_node) +static void shaper_profile_hash_node_refresh(struct shaping_thread_ctx *ctx, struct shaping_profile_hash_node *pf_hash_node, struct timespec *curr_timespec) { - time_t curr_time_s = time(NULL); - if (curr_time_s - pf_hash_node->last_refresh_time_s < PROFILE_HASH_NODE_REFRESH_SEC) { + unsigned long long curr_time_ms = curr_timespec->tv_sec * MILLI_SECONDS_PER_SEC + curr_timespec->tv_nsec / NANO_SECONDS_PER_MILLI_SEC; + + if (curr_time_ms - pf_hash_node->last_refresh_time_ms < PROFILE_HASH_NODE_REFRESH_MS) { return; } @@ -583,7 +584,7 @@ static void shaper_profile_hash_node_refresh(struct shaping_thread_ctx *ctx, str pf_hash_node->limit_direction = profile->limit_direction; pf_hash_node->aqm_type = profile->aqm_type; } - pf_hash_node->last_refresh_time_s = curr_time_s; + pf_hash_node->last_refresh_time_ms = curr_time_ms; return; } @@ -598,7 +599,7 @@ static void shaper_token_get_from_profile(struct shaping_thread_ctx *ctx, struct return; } - shaper_profile_hash_node_refresh(ctx, pf_hash_node); + shaper_profile_hash_node_refresh(ctx, pf_hash_node, curr_timespec); if (pf_hash_node->limit_direction == PROFILE_LIMIT_DIRECTION_BIDIRECTION) { snprintf(key, sizeof(key), "tsg-shaping-%d-bidirectional", pf_info->id); |
