summaryrefslogtreecommitdiff
path: root/shaping/src/shaper.cpp
diff options
context:
space:
mode:
authorliuchang <[email protected]>2023-07-04 02:50:27 +0000
committerliuchang <[email protected]>2023-07-04 02:50:27 +0000
commit99d4d6cf8850c3b0a5a02316e363fe462633bd3d (patch)
tree01ab67dfd0c824bababfed847e6c4e7f2bbc909a /shaping/src/shaper.cpp
parent96c628d2cda78c5952963d764b3f821951ff862c (diff)
add enables switch in shaping rule
Diffstat (limited to 'shaping/src/shaper.cpp')
-rw-r--r--shaping/src/shaper.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/shaping/src/shaper.cpp b/shaping/src/shaper.cpp
index ec81d75..ddb23c5 100644
--- a/shaping/src/shaper.cpp
+++ b/shaping/src/shaper.cpp
@@ -588,15 +588,23 @@ static int shaper_profile_is_priority_blocked(struct shaping_thread_ctx *ctx, st
static int shaper_token_consume(struct shaping_thread_ctx *ctx, struct shaping_flow *sf, int req_token_bytes,
struct shaping_profile_info *profile, int profile_type, unsigned char direction)
{
+ struct shaping_rule_info *rule = &sf->matched_rule_infos[sf->anchor];
time_t curr_time = time(NULL);
if (curr_time - sf->check_rule_time >= ctx->conf.check_rule_enable_interval_sec) {
sf->check_rule_time = curr_time;
- if (shaper_rule_is_enabled(ctx, sf->matched_rule_infos[sf->anchor].id) != 1) {
+ 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
+ } else {
+ rule->is_enabled = 1;
}
}
+ if (rule->is_enabled != 1) {
+ return 0;
+ }
+
if (shaper_profile_is_priority_blocked(ctx, sf, profile)) {
return -1;
} else {