diff options
| author | 刘畅 <[email protected]> | 2023-04-06 02:58:28 +0000 |
|---|---|---|
| committer | 刘畅 <[email protected]> | 2023-04-06 02:58:28 +0000 |
| commit | 121cc045981f27de604ba7b6cebdf2a5efe1b868 (patch) | |
| tree | 4db0f449f2edd3f3e1e747216fe164a0f1beafef /shaping/src/shaper.cpp | |
| parent | 3200d56255caf1b3c8d2ba1782da8c3f61bf96c5 (diff) | |
| parent | 3a4c942bf1c57c800bf7a4513f22d29e3a7c0bd0 (diff) | |
Merge branch 'merge_from_bytes_to_bits' into 'rel'v1.1.7
merge from shaping_master, get token unit from tybes to bits
See merge request tango/shaping-engine!9
Diffstat (limited to 'shaping/src/shaper.cpp')
| -rw-r--r-- | shaping/src/shaper.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/shaping/src/shaper.cpp b/shaping/src/shaper.cpp index 95277f1..a8a955a 100644 --- a/shaping/src/shaper.cpp +++ b/shaping/src/shaper.cpp @@ -426,7 +426,7 @@ static int shaper_deposit_token_is_enough(struct shaping_profile_info *pf_info, } } -static int shaper_token_get_from_profile(struct swarmkv *db, struct shaping_flow *sf, struct shaping_profile_info *pf_info, int profile_type, int req_token, unsigned char direction) +static int shaper_token_get_from_profile(struct swarmkv *db, struct shaping_flow *sf, struct shaping_profile_info *pf_info, int profile_type, int req_token_bits, unsigned char direction) { struct shaping_async_cb_arg *arg; char key[32] = {0}; @@ -440,9 +440,9 @@ static int shaper_token_get_from_profile(struct swarmkv *db, struct shaping_flow arg->sf = sf; arg->direction = direction; - swarmkv_tconsume(db, key, strlen(key), req_token, shaper_token_get_cb, arg); + swarmkv_tconsume(db, key, strlen(key), req_token_bits, shaper_token_get_cb, arg); if (__atomic_load_n(&pf_info->async_token_ref_count, __ATOMIC_SEQ_CST) != 0) {//has async operation not completed - shaper_deposit_token_sub(pf_info, req_token, direction); + shaper_deposit_token_sub(pf_info, req_token_bits, direction); return 0; } @@ -454,8 +454,8 @@ static int shaper_token_get_from_profile(struct swarmkv *db, struct shaping_flow } } - if (shaper_deposit_token_is_enough(pf_info, req_token, direction)) { - shaper_deposit_token_sub(pf_info, req_token, direction); + if (shaper_deposit_token_is_enough(pf_info, req_token_bits, direction)) { + shaper_deposit_token_sub(pf_info, req_token_bits, direction); return 0; } @@ -517,13 +517,14 @@ static int shaper_profile_is_priority_blocked(struct swarmkv *db, struct shaping } } -static int shaper_token_consume(struct swarmkv *db, struct shaping_flow *sf, int req_token, +static int shaper_token_consume(struct swarmkv *db, struct shaping_flow *sf, int req_token_bytes, struct shaping_profile_info *profile, int profile_type, unsigned char direction) { if (shaper_profile_is_priority_blocked(db, sf, profile)) { return -1; } else { - return shaper_token_get_from_profile(db, sf, profile, profile_type, req_token, direction); + int req_token_bits = req_token_bytes * 8; + return shaper_token_get_from_profile(db, sf, profile, profile_type, req_token_bits, direction); } } |
