summaryrefslogtreecommitdiff
path: root/src/tsg_statistic.cpp
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2019-12-26 10:41:06 +0800
committerliuxueli <[email protected]>2019-12-26 10:41:06 +0800
commit4235b37036f8adfd5cc73a563a144daf983ebb1e (patch)
treeaf56d3b1720cfad8b5634409a9c1333dbdb42182 /src/tsg_statistic.cpp
parentae555ab98b27c33ebbc77edb6aff146c4f9bae97 (diff)
修复笔误,流量统计数组下标使用错误导致统计异常
Diffstat (limited to 'src/tsg_statistic.cpp')
-rw-r--r--src/tsg_statistic.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/tsg_statistic.cpp b/src/tsg_statistic.cpp
index bb47c42..dccd4d6 100644
--- a/src/tsg_statistic.cpp
+++ b/src/tsg_statistic.cpp
@@ -26,7 +26,7 @@ int tsg_set_policy_flow(struct streaminfo *a_stream, Maat_rule_t *p_result, int
return -1;
}
- traffic_info=&g_tsg_statis_para.traffic_info[thread_seq][(int)p_result->action];
+ traffic_info=&(g_tsg_statis_para.traffic_info[(int)p_result->action][thread_seq]);
traffic_info->con_num++;
traffic_info->in_bytes+=a_stream->ptcpdetail->clientbytes;
@@ -204,6 +204,12 @@ int tsg_statistic_init(const char *conffile, void *logger)
memset(&g_tsg_statis_para, 0, sizeof(g_tsg_statis_para));
+ thread_num=get_thread_count();
+ for(i=0; i<TSG_ACTION_MAX; i++)
+ {
+ g_tsg_statis_para.traffic_info[i]=(struct _traffic_info *)calloc(1, sizeof(struct _traffic_info)*thread_num);
+ }
+
MESA_load_profile_int_def(conffile, "STATISTIC", "CYCLE", &g_tsg_statis_para.cycle, 30);
if(g_tsg_statis_para.cycle<=0)
{
@@ -211,14 +217,6 @@ int tsg_statistic_init(const char *conffile, void *logger)
return 0;
}
-
- thread_num=get_thread_count();
- for(i=0; i<TSG_ACTION_MAX; i++)
- {
- g_tsg_statis_para.traffic_info[i]=(struct _traffic_info *)calloc(1, sizeof(struct _traffic_info)*thread_num);
- }
-
- MESA_load_profile_int_def(conffile, "STATISTIC", "CYCLE", &g_tsg_statis_para.cycle, 30);
MESA_load_profile_short_nodef(conffile, "STATISTIC", "TELEGRAF_PORT", (short *)&(fs_server_port));
MESA_load_profile_string_nodef(conffile,"STATISTIC", "TELEGRAF_IP",fs_server_ip, sizeof(fs_server_ip));
MESA_load_profile_string_def(conffile,"STATISTIC", "OUTPUT_PATH",fs_output_path, sizeof(fs_output_path), "statistic.log");