diff options
| author | 李仁杰 <[email protected]> | 2020-08-03 18:58:22 +0800 |
|---|---|---|
| committer | 李仁杰 <[email protected]> | 2020-08-03 18:58:22 +0800 |
| commit | 89c5b1184efb62e0d390cdc83ff7f90bdc3cd1ac (patch) | |
| tree | e7c085d06e38f2648cc00f2886c1edd5327cfdd0 | |
| parent | 72dcadb53e40bf50f54f8f9262bc791696eeffd1 (diff) | |
Update lirenjie_vxlan_sapp_20200803.c 发现了两处free的bug,添加了#define ENABLE_COUNT_THREAD 来控制是否进行统计
| -rw-r--r-- | lirenjie_vxlan_sapp_20200803.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/lirenjie_vxlan_sapp_20200803.c b/lirenjie_vxlan_sapp_20200803.c index 77c648e..e7c85b3 100644 --- a/lirenjie_vxlan_sapp_20200803.c +++ b/lirenjie_vxlan_sapp_20200803.c @@ -31,6 +31,7 @@ extern unsigned char vxlan_id_map_to_service_id(int vxlan_id_host_order); extern int platform_register_action_judge(char (*action_cb_fun)(int net_conn_mode, char plug_action)); extern int g_business_plug_type; +#define ENABLE_COUNT_THREAD 0 //是否启用统计功能.added by lrj at 20200803 #define MAX_LOG_INFO_LEN 256 #define MAX_VPN_ID_NUM 512 #define MAX_TRAFFIC_INFO_LEN 1024 @@ -686,9 +687,9 @@ char TCP_ENTRY(struct streaminfo *pstream, void **pme, int thread_seq, const voi struct traffic_info *tinfo; time_t *time_old; struct traffic_info *tinfo_new; - +#if ENABLE_COUNT_THREAD all_stream_pkt_num[thread_seq]++; - +#endif if (-1 == tcp_flow_id) { tcp_flow_id = project_customer_register("tcp_flow_stat", "struct"); @@ -802,11 +803,11 @@ char TCP_ENTRY(struct streaminfo *pstream, void **pme, int thread_seq, const voi tinfo->C2S_bytes = 0; tinfo->S2C_bytes = 0; } - +#if ENABLE_COUNT_THREAD close_stream_pkt_num[thread_seq] += tinfo->C2S_pkt_num; close_stream_pkt_num[thread_seq] += tinfo->S2C_pkt_num; push_count[thread_seq]++; - +#endif /* layer_addr */ tinfo->addr = pstream->addr; /* STAT_TIME */ @@ -862,16 +863,19 @@ char TCP_ENTRY(struct streaminfo *pstream, void **pme, int thread_seq, const voi tinfo_new->S2C_bytes = tflow->S2C_all_byte; } - free(time_new); + // free(time_new); time(time_old); } + free(time_new); } return DEFAULT_RETURN_VALUE; error_drop: +#if ENABLE_COUNT_THREAD error_count[thread_seq]++; +#endif free(tinfo); free(tinfo_new); free(time_old); @@ -913,9 +917,9 @@ char UDP_ENTRY(struct streaminfo *pstream, void **pme, int thread_seq, const voi struct traffic_info *tinfo; time_t *time_old; struct traffic_info *tinfo_new; - +#if ENABLE_COUNT_THREAD all_stream_pkt_num[thread_seq]++; - +#endif if (is_gdev_keepalive_pkt((const struct ip *)raw_pkt) != 0) { //add by lijia 20190604, drop BFD keepalive packet. return APP_STATE_DROPME; @@ -1030,11 +1034,11 @@ char UDP_ENTRY(struct streaminfo *pstream, void **pme, int thread_seq, const voi tinfo->C2S_bytes = 0; tinfo->S2C_bytes = 0; } - +#if ENABLE_COUNT_THREAD close_stream_pkt_num[thread_seq] += tinfo->C2S_pkt_num; close_stream_pkt_num[thread_seq] += tinfo->S2C_pkt_num; push_count[thread_seq]++; - +#endif /* layer_addr */ tinfo->addr = pstream->addr; /* STAT_TIME */ @@ -1089,16 +1093,19 @@ char UDP_ENTRY(struct streaminfo *pstream, void **pme, int thread_seq, const voi tinfo_new->S2C_bytes = tflow->S2C_byte; } - free(time_new); + // free(time_new); time(time_old); } + free(time_new); } return DEFAULT_RETURN_VALUE; error_drop: +#if ENABLE_COUNT_THREAD error_count[thread_seq]++; +#endif free(tinfo); free(tinfo_new); free(time_old); @@ -1230,7 +1237,7 @@ int CHAR_INIT() { MESA_handle_runtime_log(runtime_log_handler, RLOG_LV_FATAL, module_name, "GSJ thread start failed\n"); } - +#if ENABLE_COUNT_THREAD int count_thread; count_thread = pthread_create(&count, NULL, (void *)count_work, NULL); if (count_thread == 0) @@ -1242,7 +1249,7 @@ int CHAR_INIT() { MESA_handle_runtime_log(runtime_log_handler, RLOG_LV_FATAL, module_name, "count thread start failed\n"); } - +#endif // 函数实现自定义 // 只要求函数返回值为插件ID //printf("INIT SUCCESS!!!\n"); return demo_plugid; } |
