summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliuchang <[email protected]>2023-04-03 12:25:03 +0000
committerliuchang <[email protected]>2023-04-03 12:25:03 +0000
commit5e9d5418d1c0950352e3ab704285f8a371a7bae5 (patch)
tree753478c0e9208c6cb6747112ed84e891173c7e49
parentf4d683426ce6b9572971d005cb5cc32a06ceef2c (diff)
fix crash, init thread_local value for every threadv1.1.5
-rw-r--r--shaping/include/shaper_stat.h1
-rw-r--r--shaping/src/main.cpp2
-rw-r--r--shaping/src/shaper_stat.cpp23
3 files changed, 17 insertions, 9 deletions
diff --git a/shaping/include/shaper_stat.h b/shaping/include/shaper_stat.h
index 30d869e..eada87d 100644
--- a/shaping/include/shaper_stat.h
+++ b/shaping/include/shaper_stat.h
@@ -67,6 +67,7 @@ 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 *stat, int rule_id, int profile_id, int priority, unsigned char direction, int pkt_len, int profile_type, int thread_id);
void shaper_stat_queueing_pkt_dec(struct shaping_stat *stat, int rule_id, int profile_id, int priority, unsigned char direction, int pkt_len, int profile_type, int thread_id);
diff --git a/shaping/src/main.cpp b/shaping/src/main.cpp
index 62d3dcb..7f106ed 100644
--- a/shaping/src/main.cpp
+++ b/shaping/src/main.cpp
@@ -5,6 +5,7 @@
#include <assert.h>
#include "shaper.h"
+#include "shaper_stat.h"
#include "shaper_marsio.h"
#include "shaper_session.h"
@@ -13,6 +14,7 @@ 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_stat.cpp b/shaping/src/shaper_stat.cpp
index 6b49182..3f4c646 100644
--- a/shaping/src/shaper_stat.cpp
+++ b/shaping/src/shaper_stat.cpp
@@ -91,15 +91,6 @@ struct shaping_stat* shaper_stat_init(int thread_num)
goto ERROR;
}
- tags[TAG_RULE_ID_IDX].key = "rule_id";
- tags[TAG_RULE_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;
-
fieldstat_dynamic_instance_start(stat->instance);
return stat;
@@ -114,6 +105,20 @@ 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_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 rule_id, int profile_id, int priority, int profile_type)
{