summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shaping/include/shaper_stat.h1
-rw-r--r--shaping/src/main.cpp1
-rw-r--r--shaping/src/shaper.cpp3
-rw-r--r--shaping/src/shaper_session.cpp7
-rw-r--r--shaping/src/shaper_stat.cpp31
5 files changed, 17 insertions, 26 deletions
diff --git a/shaping/include/shaper_stat.h b/shaping/include/shaper_stat.h
index 5d4cefe..20da941 100644
--- a/shaping/include/shaper_stat.h
+++ b/shaping/include/shaper_stat.h
@@ -47,7 +47,6 @@ struct shaping_stat {
void shaper_stat_destroy(struct shaping_stat *stat);
struct shaping_stat* shaper_stat_init(int thread_num);
-void shaper_stat_tags_init();
void shaper_stat_queueing_pkt_inc(struct shaping_stat_for_profile *profile_stat, unsigned char direction, int thread_id);
void shaper_stat_queueing_pkt_dec(struct shaping_stat_for_profile *profile_stat, unsigned char direction, int thread_id);
diff --git a/shaping/src/main.cpp b/shaping/src/main.cpp
index f07787f..91d245f 100644
--- a/shaping/src/main.cpp
+++ b/shaping/src/main.cpp
@@ -18,7 +18,6 @@ static void *shaper_thread_loop(void *data)
struct shaping_thread_ctx *ctx = (struct shaping_thread_ctx *)data;
marsio_thread_init(ctx->marsio_info->instance);
- shaper_stat_tags_init();
//loop to process pkts
while(1) {
diff --git a/shaping/src/shaper.cpp b/shaping/src/shaper.cpp
index 3ca1ae3..f8dbe6e 100644
--- a/shaping/src/shaper.cpp
+++ b/shaping/src/shaper.cpp
@@ -800,6 +800,7 @@ static int shaper_polling_first_pkt_token_get(struct shaper *sp, struct shaping_
if (shaper_queue_empty(sf)) {
if (sf->flag & SESSION_CLOSE) {
shaping_flow_free(ctx, sf);
+ sf->flag &= (~SESSION_CLOSE);
}
return 0;
} else {
@@ -817,6 +818,7 @@ static int shaper_polling_first_pkt_token_get(struct shaper *sp, struct shaping_
shaper_queue_clear(sf, ctx);//first packet fail, then every packet will fail
if (sf->flag & SESSION_CLOSE) {
shaping_flow_free(ctx, sf);
+ sf->flag &= (~SESSION_CLOSE);
}
}
return 0;
@@ -902,6 +904,7 @@ END:
LOG_DEBUG("%s: shaping free a shaping_flow for session: %s", LOG_TAG_SHAPING, addr_str);
shaping_flow_free(ctx, sf);
+ sf->flag &= (~SESSION_CLOSE);
if (addr_str) {
free(addr_str);
diff --git a/shaping/src/shaper_session.cpp b/shaping/src/shaper_session.cpp
index 685b41a..946a56f 100644
--- a/shaping/src/shaper_session.cpp
+++ b/shaping/src/shaper_session.cpp
@@ -177,7 +177,12 @@ struct shaping_flow* shaper_session_close(struct shaping_thread_ctx *ctx, struct
}
sf = (struct shaping_flow *)session_node->val_data;
- sf->flag |= SESSION_CLOSE;
+
+ if (shaper_queue_empty(sf)) {
+ shaping_flow_free(ctx, sf);
+ } else {
+ sf->flag |= SESSION_CLOSE;
+ }
shaper_global_stat_ctrlpkt_active_close_inc(ctx->global_stat);
diff --git a/shaping/src/shaper_stat.cpp b/shaping/src/shaper_stat.cpp
index 0685e01..e7d03a1 100644
--- a/shaping/src/shaper_stat.cpp
+++ b/shaping/src/shaper_stat.cpp
@@ -22,7 +22,14 @@ struct shaper_stat_conf {
short telegraf_port;
};
-thread_local struct fieldstat_tag tags[TAG_IDX_MAX];
+thread_local struct fieldstat_tag tags[TAG_IDX_MAX] =
+{
+ [TAG_VSYS_ID_IDX] = {.key = "vsys_id", .value_type = 0},
+ [TAG_RULE_ID_IDX] = {.key = "rule_id", .value_type = 0},
+ [TAG_PROFILE_ID_IDX] = {.key = "profile_id", .value_type = 0},
+ [TAG_PRIORITY_IDX] = {.key = "priority", .value_type = 0},
+ [TAG_PROFILE_TYPE_IDX] = {.key = "profile_type", .value_type = 2}
+};
void shaper_stat_destroy(struct shaping_stat *stat)
{
@@ -91,8 +98,6 @@ struct shaping_stat* shaper_stat_init(int thread_num)
goto ERROR;
}
- shaper_stat_tags_init();
-
fieldstat_dynamic_instance_start(stat->instance);
return stat;
@@ -107,26 +112,6 @@ ERROR:
return NULL;
}
-void shaper_stat_tags_init()
-{
- tags[TAG_RULE_ID_IDX].key = "rule_id";
- tags[TAG_RULE_ID_IDX].value_type = 0;
-
- tags[TAG_VSYS_ID_IDX].key = "vsys_id";
- tags[TAG_VSYS_ID_IDX].value_type = 0;
-
- tags[TAG_PROFILE_ID_IDX].key = "profile_id";
- tags[TAG_PROFILE_ID_IDX].value_type = 0;
-
- tags[TAG_PRIORITY_IDX].key = "priority";
- tags[TAG_PRIORITY_IDX].value_type = 0;
-
- tags[TAG_PROFILE_TYPE_IDX].key = "profile_type";
- tags[TAG_PROFILE_TYPE_IDX].value_type = 2;
-
- return;
-}
-
static void shaper_stat_tags_build(int vsys_id, int rule_id, int profile_id, int priority, int profile_type)
{
tags[TAG_VSYS_ID_IDX].value_int = vsys_id;