diff options
| author | 刘畅 <[email protected]> | 2023-09-11 03:18:59 +0000 |
|---|---|---|
| committer | 刘畅 <[email protected]> | 2023-09-11 03:18:59 +0000 |
| commit | cd9e72e6e614691903e9befd0b1b7d9d4c3d8845 (patch) | |
| tree | d0a96546845fbcd40f5a76b1625e538ac2c5c340 | |
| parent | 0aec8e9e9926424aa73b94d7ec479bd87422b27f (diff) | |
| parent | f81ebf3c9cd180672eeb490f01f888264b993bb7 (diff) | |
Merge branch 'bugfix_metric_for_disabled_rule' into 'rel'v1.2.11
Bugfix metric for disabled rule
See merge request tango/shaping-engine!41
| -rw-r--r-- | ci/travis.sh | 5 | ||||
| -rw-r--r-- | shaping/src/shaper.cpp | 36 |
2 files changed, 24 insertions, 17 deletions
diff --git a/ci/travis.sh b/ci/travis.sh index 712bb4a..1197c99 100644 --- a/ci/travis.sh +++ b/ci/travis.sh @@ -73,8 +73,3 @@ if [ -n "${PACKAGE}" ]; then python3 rpm_upload_tools.py ${PULP3_REPO_NAME} ${PULP3_DIST_NAME} *.rpm fi -if [ -n "${UPLOAD_SYMBOL_FILES}" ]; then - rpm -i shaping_engine*debuginfo*.rpm - cp /usr/lib/debug/opt/tsg/shaping_engine/bin/shaping_engine*debug /tmp/shaping_engine.debuginfo.${CI_COMMIT_SHORT_SHA} - sentry-cli upload-dif -t elf /tmp/shaping_engine.debuginfo.${CI_COMMIT_SHORT_SHA} -fi diff --git a/shaping/src/shaper.cpp b/shaping/src/shaper.cpp index 6a5db5e..09a0c24 100644 --- a/shaping/src/shaper.cpp +++ b/shaping/src/shaper.cpp @@ -65,6 +65,12 @@ struct shaping_profile_container { int pf_type; }; +enum shaper_token_get_result { + SHAPER_TOKEN_GET_FAILED = -1, + SHAPER_TOKEN_GET_SUCCESS = 0, + SHAPER_TOKEN_GET_PASS = 1,//don't need to get token, regard as success +}; + struct shaper* shaper_new(unsigned int priority_queue_len_max) { struct shaper *sp = NULL; @@ -495,23 +501,23 @@ static int shaper_token_get_from_profile(struct shaping_thread_ctx *ctx, struct 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_bits, direction); - return 0; + return SHAPER_TOKEN_GET_SUCCESS; } if (pf_info->is_invalid) { if (profile_type == PROFILE_IN_RULE_TYPE_PRIMARY) {//for primary, means this rule don't need get token - return 0; + return SHAPER_TOKEN_GET_SUCCESS; } else {//for borrowing, means this profile has no token to borrow - return -1; + return SHAPER_TOKEN_GET_FAILED; } } if (shaper_deposit_token_is_enough(pf_info, req_token_bits, direction)) { shaper_deposit_token_sub(pf_info, req_token_bits, direction); - return 0; + return SHAPER_TOKEN_GET_SUCCESS; } - return -1; + return SHAPER_TOKEN_GET_FAILED; } static void shaper_queue_len_get_cb(const struct swarmkv_reply *reply, void * cb_arg) @@ -593,18 +599,18 @@ static int shaper_token_consume(struct shaping_thread_ctx *ctx, struct shaping_f sf->check_rule_time = curr_time; if (shaper_rule_is_enabled(ctx, rule->id) != 1) { rule->is_enabled = 0; - return 0;//rule is disabled, don't need to get token and forward packet + return SHAPER_TOKEN_GET_PASS;//rule is disabled, don't need to get token and forward packet } else { rule->is_enabled = 1; } } if (rule->is_enabled != 1) { - return 0; + return SHAPER_TOKEN_GET_PASS;//rule is disabled, don't need to get token and forward packet } if (shaper_profile_is_priority_blocked(ctx, sf, profile)) { - return -1; + return SHAPER_TOKEN_GET_FAILED; } else { int req_token_bits = req_token_bytes * 8; return shaper_token_get_from_profile(ctx, sf, profile, profile_type, req_token_bits, direction); @@ -697,8 +703,11 @@ static enum shaping_packet_action shaper_pkt_action_decide_queueing(struct shapi for (int i = 0; i < profile_num; i++) { profile = pf_container[i].pf_info; profile_type = pf_container[i].pf_type; - if (0 == shaper_token_consume(ctx, sf, pkt_wrapper->length, profile, profile_type, pkt_wrapper->direction)) { - shaper_stat_forward_inc(&profile->stat, pkt_wrapper->direction, pkt_wrapper->length, ctx->thread_index); + int ret = shaper_token_consume(ctx, sf, pkt_wrapper->length, profile, profile_type, pkt_wrapper->direction); + if (ret >= SHAPER_TOKEN_GET_SUCCESS) { + if (ret == SHAPER_TOKEN_GET_SUCCESS) { + shaper_stat_forward_inc(&profile->stat, pkt_wrapper->direction, pkt_wrapper->length, ctx->thread_index); + } get_token_success = 1; break; } @@ -742,8 +751,11 @@ static enum shaping_packet_action shaper_pkt_action_decide_no_queue(struct shapi return SHAPING_FORWARD; } - if (0 == shaper_token_consume(ctx, sf, meta->raw_len, profile, profile_type, meta->dir)) { - shaper_stat_forward_inc(&profile->stat, meta->dir, meta->raw_len, ctx->thread_index); + int ret = shaper_token_consume(ctx, sf, meta->raw_len, profile, profile_type, meta->dir); + if (ret >= SHAPER_TOKEN_GET_SUCCESS) { + if (ret == SHAPER_TOKEN_GET_SUCCESS) { + shaper_stat_forward_inc(&profile->stat, meta->dir, meta->raw_len, ctx->thread_index); + } sf->anchor = shaper_next_anchor_get(sf, meta->dir); if (sf->anchor == 0) {//no next rule |
