diff options
| author | lijia <[email protected]> | 2021-09-29 18:11:21 +0800 |
|---|---|---|
| committer | lijia <[email protected]> | 2021-09-29 18:11:21 +0800 |
| commit | 79582b3cfaca5d1db0ffd0131d95eb71e6c95c03 (patch) | |
| tree | f39dd3af7397b6cf320dbdef3eb372c324b56e31 /src | |
| parent | 86156ab004072179dfc34fb63c3ba437d5688db3 (diff) | |
TSG-7425, 修复gdev_keepalive线程未销毁问题; 修复pcap dumpfile模式缓存队列数据包未free问题; 修复g_entryname_info未free问题; 修复well_known_ports_array未free问题;
Diffstat (limited to 'src')
| -rw-r--r-- | src/config/config_parse.cpp | 3 | ||||
| -rw-r--r-- | src/dealpkt/callapp.c | 4 | ||||
| -rw-r--r-- | src/dealpkt/deal_ipv4.c | 8 | ||||
| -rw-r--r-- | src/dealpkt/deal_ipv6.c | 7 | ||||
| -rw-r--r-- | src/dealpkt/duplicate_pkt_distinguish.c | 12 | ||||
| -rw-r--r-- | src/inner_plug/g_device_plug.cpp | 28 | ||||
| -rw-r--r-- | src/packet_io/packet_io.c | 15 | ||||
| -rw-r--r-- | src/packet_io/packet_io_device.c | 14 | ||||
| -rw-r--r-- | src/packet_io/packet_io_lib_load.c | 2 | ||||
| -rw-r--r-- | src/packet_io/packet_io_pcap.c | 34 | ||||
| -rw-r--r-- | src/packet_io/sendpacket.c | 12 | ||||
| -rw-r--r-- | src/plugin/src/plugin.c | 7 | ||||
| -rw-r--r-- | src/plugin/src/plugin_manage.c | 3 | ||||
| -rw-r--r-- | src/sapp_dev/sapp_global_val.c | 7 | ||||
| -rw-r--r-- | src/timer/sapp_timer.c | 2 |
15 files changed, 133 insertions, 25 deletions
diff --git a/src/config/config_parse.cpp b/src/config/config_parse.cpp index 9dc97f3..cd82efc 100644 --- a/src/config/config_parse.cpp +++ b/src/config/config_parse.cpp @@ -2270,8 +2270,7 @@ done: void sapp_log_handle_destroy(void) { - //�˴�����, double free, �ݲ�ȷ�����ĵ����� - //MESA_destroy_runtime_log_handle(sapp_global_val->individual_fixed.log_handle); + MESA_destroy_runtime_log_handle(sapp_global_val->individual_fixed.log_handle); sapp_global_val->individual_fixed.log_handle = NULL; } diff --git a/src/dealpkt/callapp.c b/src/dealpkt/callapp.c index de981ae..a62cccc 100644 --- a/src/dealpkt/callapp.c +++ b/src/dealpkt/callapp.c @@ -70,7 +70,9 @@ extern "C" char callIpApp_old(struct streaminfo *pstream,int routedir, int threa extern void timestamp_record(enum timestamp_level level, const raw_pkt_t *raw_pkt, int thread_seq);
-/* 2014-12-31 lqy add */
+/* 2014-12-31 lqy add
+ TODO, ��Щ���ò��û��destroy�ӿ�.
+*/
int stream_register_funtoArray(int funtype,char (*x)(void),stFunArray *pArrary,int *pNum, int plug_entry_id)
{
if(*pNum>=MAX_FUN_NUM)
diff --git a/src/dealpkt/deal_ipv4.c b/src/dealpkt/deal_ipv4.c index 79cfe87..5561ecc 100644 --- a/src/dealpkt/deal_ipv4.c +++ b/src/dealpkt/deal_ipv4.c @@ -905,12 +905,8 @@ void ipv4_frag_per_thread_exit(int thread_seq) void ipv4_frag_exit(void)
{
-#if USE_MESA_STREAM_HASH
- int i;
-
- for(i = 0; i < g_packet_io_thread_num; i++){
- MESA_htable_destroy(g_ipv4_frag_manage[i].frag_hash_table, NULL);
- }
+#if USE_MESA_STREAM_HASH
+ SAPP_GLOBAL_FREE(g_ipv4_frag_manage);
#endif
}
diff --git a/src/dealpkt/deal_ipv6.c b/src/dealpkt/deal_ipv6.c index 2b280ac..5e5a3be 100644 --- a/src/dealpkt/deal_ipv6.c +++ b/src/dealpkt/deal_ipv6.c @@ -1093,12 +1093,9 @@ void ipv6_frag_per_thread_exit(int thread_seq) void ipv6_frag_exit(void)
{
#if USE_MESA_STREAM_HASH
- int i;
-
- for(i = 0; i < g_packet_io_thread_num; i++){
- MESA_htable_destroy(g_ipv6_frag_manage[i].frag_hash_table, NULL);
- }
+ SAPP_GLOBAL_FREE(g_ipv6_frag_manage);
#endif
+
}
#ifdef __cplusplus
diff --git a/src/dealpkt/duplicate_pkt_distinguish.c b/src/dealpkt/duplicate_pkt_distinguish.c index ab6b58a..f91efba 100644 --- a/src/dealpkt/duplicate_pkt_distinguish.c +++ b/src/dealpkt/duplicate_pkt_distinguish.c @@ -129,6 +129,18 @@ int sapp_dup_pkt_init(void) return 0; } +void sapp_dup_pkt_destroy(void) +{ + int i; + + for(i = 0; i < sapp_global_val->config.cpu.worker_threads; i++){ + if(sapp_global_val->mthread_volatile[i]->dup_pkt_distinguish_handle){ + expiry_dablooms_destroy(sapp_global_val->mthread_volatile[i]->dup_pkt_distinguish_handle); + } + } + +} + #ifdef __cplusplus } #endif diff --git a/src/inner_plug/g_device_plug.cpp b/src/inner_plug/g_device_plug.cpp index 4caf767..2c7290b 100644 --- a/src/inner_plug/g_device_plug.cpp +++ b/src/inner_plug/g_device_plug.cpp @@ -625,7 +625,7 @@ static void *gdev_keepalive_log_thread(void *arg) sapp_usleep(100); } - while(1){ + while(sapp_get_current_state() == SAPP_STATE_PROCESSING){ while(last_op_time == time(NULL)){ sapp_usleep(100); } @@ -1037,13 +1037,35 @@ int gdev_keepalive_plug_init(void) return -1; } - pthread_t log_pid; - pthread_create(&log_pid, NULL, gdev_keepalive_log_thread, NULL); + pthread_create(&sapp_global_val->individual_fixed.gdev_keepalive_log_thread_id, NULL, gdev_keepalive_log_thread, NULL); return 0; } +void gdev_keepalive_plug_destroy(void) +{ + if(DEPOLYMENT_MODE_INLINE != sapp_global_val->config.packet_io.depolyment_mode_bin){ + return; + } + + if(sapp_global_val->individual_fixed.gdev_keepalive_log_thread_id){ + pthread_join(sapp_global_val->individual_fixed.gdev_keepalive_log_thread_id, NULL); + sapp_global_val->individual_fixed.gdev_keepalive_log_thread_id = 0; + } + + if(gdev_keepalive_fs2_handle){ + FS_stop(&gdev_keepalive_fs2_handle); + gdev_keepalive_fs2_handle = NULL; + } + + memset(GDEV_KEEPALIVE_STAT, 0, sizeof(GDEV_KEEPALIVE_STAT)); + memset(g_dev_keepalive_service_ctrl_array, 0, sizeof(g_dev_keepalive_service_ctrl_array)); + g_dev_keepalive_flag = 1; + g_dev_keepalive_default_action = 1; +} + + #ifdef __cplusplus } #endif diff --git a/src/packet_io/packet_io.c b/src/packet_io/packet_io.c index de63620..48a7410 100644 --- a/src/packet_io/packet_io.c +++ b/src/packet_io/packet_io.c @@ -1345,7 +1345,7 @@ int packet_io_init(int argc, char *argv[]) } for(i = 0; i < MAX_THREAD_NUM; i++){ - g_send_buf_pool[i] = (UINT8 *)malloc(SENDPACKET_BUF_LEN); + g_send_buf_pool[i] = (UINT8 *)SAPP_GLOBAL_ALLOC(SENDPACKET_BUF_LEN); } if(sendpacket_init_new(g_packet_io_thread_num) < 0){ @@ -1385,6 +1385,8 @@ int packet_io_init(int argc, char *argv[]) void packet_io_exit(void) { + int i; + /* ����ģʽ��, ��������IO�߳�һЩʱ��, ����δ�������, �����첽������־, field_statˢ��ͳ�����ݵȵ�. */ sapp_set_current_state(SAPP_STATE_READY_TO_EXIT); //sleep(sapp_global_val->config.packet_io.dumpfile_sleep_time_before_exit); @@ -1392,16 +1394,23 @@ void packet_io_exit(void) sysinfo_output(); /* ���һ��дͳ����Ϣ, �رձ�־λ, ��Ϊ�����������, ��д��û������ */ update_packet_io_status_sw = 0; + for(i = 0; i < MAX_THREAD_NUM; i++){ + SAPP_GLOBAL_FREE(g_send_buf_pool[i]); + } + global_sapp_timer_destroy(); - + gdev_keepalive_plug_destroy(); plugctrl_destroy_all_plug(); sendpacket_destroy(g_packet_io_thread_num); packet_io_lib_destroy(); + packet_io_device_alias_destroy(); sapp_log_handle_destroy(); sapp_fs2_destroy(); packet_io_under_ddos_destroy(); + ipv4_frag_exit(); + ipv6_frag_exit(); plugin_manage_destroy(); global_project_req_destroy(); @@ -1413,6 +1422,8 @@ void packet_io_exit(void) stream_destroy_plugin(); global_stream_destroy(); + + sapp_dup_pkt_destroy(); sapp_gval_destroy(); diff --git a/src/packet_io/packet_io_device.c b/src/packet_io/packet_io_device.c index 77bd199..e235e7b 100644 --- a/src/packet_io/packet_io_device.c +++ b/src/packet_io/packet_io_device.c @@ -116,6 +116,20 @@ int packet_io_device_alias_init(void) return 0;
}
+void packet_io_device_alias_destroy(void)
+{
+ int i;
+
+ for(i = 0; i < packet_device_alias_num; i++){
+ SAPP_GLOBAL_FREE(g_packet_device_alias[i].device_args);
+ if(dl_io_fun_list.dl_io_device_alias_free){
+ (*dl_io_fun_list.dl_io_device_alias_free)(g_packet_device_alias[i].target_id, g_packet_device_alias[i].dl_io_param);
+ }
+ }
+ SAPP_GLOBAL_FREE(g_packet_device_alias);
+ packet_device_alias_num = 0;
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/src/packet_io/packet_io_lib_load.c b/src/packet_io/packet_io_lib_load.c index 6ad5861..b589199 100644 --- a/src/packet_io/packet_io_lib_load.c +++ b/src/packet_io/packet_io_lib_load.c @@ -95,6 +95,7 @@ static int packet_io_lib_load_by_mode(int cap_mode, const char *full_lib_path) dl_io_fun_list.dl_io_free_send_handle = (void (*dl_io_free_send_handle)(int thread_seq, void *handle))packet_io_symbol_load_by_mode(io_lib_handle, cap_mode, "dl_io_free_send_handle"); dl_io_fun_list.dl_io_destroy = (void (*dl_io_destroy)(void))packet_io_symbol_load_by_mode(io_lib_handle, cap_mode, "dl_io_destroy"); + dl_io_fun_list.dl_io_device_alias_free = (void (*)(unsigned int target_id, char *device_args))packet_io_symbol_load_by_mode(io_lib_handle, cap_mode, "dl_io_device_alias_free"); return 0; } #else @@ -128,6 +129,7 @@ static int packet_io_lib_load_by_mode(int cap_mode, const char *no_use) dl_io_fun_list_static_link[cap_mode].dl_io_send_only_thread_init = NULL; dl_io_fun_list_static_link[cap_mode].dl_io_free_send_handle = pcap_dl_io_free_send_handle; dl_io_fun_list_static_link[cap_mode].dl_io_destroy = pcap_dl_io_destroy; + dl_io_fun_list_static_link[cap_mode].dl_io_device_alias_free = pcap_dl_io_device_alias_free; } #endif diff --git a/src/packet_io/packet_io_pcap.c b/src/packet_io/packet_io_pcap.c index 2cda969..7f77f95 100644 --- a/src/packet_io/packet_io_pcap.c +++ b/src/packet_io/packet_io_pcap.c @@ -535,6 +535,13 @@ void * pcap_dl_io_device_alias(unsigned int target_id, char *device_args) return (void *)sapp_strdup(device_args);
}
+void pcap_dl_io_device_alias_free(unsigned int target_id, char *device_args)
+{
+ /* ����pcapģʽ��˵, �����豸���� eth1, eth2, etc. */
+ SAPP_GLOBAL_FREE(device_args);
+}
+
+
int pcap_dl_io_register_cb(PACKET_IO_CB_T fun)
{
g_pcap_work_fun = fun;
@@ -774,6 +781,26 @@ send_again: return (ret);
}
+
+static void pcap_clear_pkt_queue_left(int thread_index)
+{
+ int ret;
+ pkt_queue_t pkt_queue_node;
+ long recv_len;
+
+ while(MESA_lqueue_get_count(work_thread_pool[thread_index].pkt_queue)){
+ pthread_mutex_lock(&work_thread_pool[thread_index].mutex);
+ recv_len = sizeof(pkt_queue_t);
+ ret = MESA_lqueue_get_head(work_thread_pool[thread_index].pkt_queue, &pkt_queue_node, &recv_len);
+ pthread_mutex_unlock(&work_thread_pool[thread_index].mutex);
+ if(ret < 0){
+ continue;
+ }
+
+ PCAP_FREE((void *)(pkt_queue_node.raw_pkt.__lib_raw_pkt_data));
+ }
+}
+
static void *__pcap_work_thread(void *arg)
{
int thread_num = (int)(*((short *)arg));
@@ -1550,6 +1577,13 @@ void pcap_dl_io_destroy(void) }
for(i = 0; i < g_pcap_work_thread_num; i++){
+ //pcap work threads �� wait_for_all_io_threads() �����л����߳���Դ.
+ //pthread_join(work_thread_pool[i].work_tid, NULL);
+
+ /* �����п��ܻ���δ���������� */
+ pcap_clear_pkt_queue_left(i);
+ MESA_lqueue_destroy(work_thread_pool[i].pkt_queue, NULL, NULL);
+
pthread_cond_destroy(&work_thread_pool[i].cond);
pthread_mutex_destroy(&work_thread_pool[i].mutex);
close(work_thread_pool[i].sd_raw_eth);
diff --git a/src/packet_io/sendpacket.c b/src/packet_io/sendpacket.c index df1d924..37b7233 100644 --- a/src/packet_io/sendpacket.c +++ b/src/packet_io/sendpacket.c @@ -3063,10 +3063,14 @@ int __do_inject_pkt(struct streaminfo *stream, const char *payload, int payload_ //assert(0); } - if((ADDR_TYPE_IPV4 == stream->addr.addrtype) - || (ADDR_TYPE_TCP == stream->addr.addrtype)){ - set_build_layer_tcp_args(thread_num, TH_PUSH|TH_ACK, MESA_rand_range(1000, 1460), 0); - } + /* + 2021-09-18 fix bug: + ԭ����Ipv4����build-args, ԭ������ipv4��tcp��ͷ����ָ��, + ��Ϊipv6Ҳ�� build_args, + ������build_net_layer_tcp()ʱ�ж�build_tcp_args��NULL, ��ʹ��������, �����Ͳ�����!! + */ + + set_build_layer_tcp_args(thread_num, TH_PUSH|TH_ACK, MESA_rand_range(1000, 1460), 0); send_handle->send_buf = packet_io_get_sendbuf(SEND_TYPE_LINK_INJECT, thread_num); diff --git a/src/plugin/src/plugin.c b/src/plugin/src/plugin.c index f731488..1e1affb 100644 --- a/src/plugin/src/plugin.c +++ b/src/plugin/src/plugin.c @@ -2026,6 +2026,7 @@ void plugctrl_destroy_all_plug(void) { stBusinessPlugInfo *plug_info; stProtocolPlugInfo *pro_plug_info; + int i; plug_info = g_platform_plug_info; while(plug_info){ @@ -2050,6 +2051,12 @@ void plugctrl_destroy_all_plug(void) } plug_info = plug_info->next; } + + SAPP_GLOBAL_FREE(g_entryname_info->entryname); + SAPP_GLOBAL_FREE(g_entryname_info); + + MESA_destroy_runtime_log_handle(g_plugin_runtime_handle); + g_plugin_runtime_handle = NULL; } diff --git a/src/plugin/src/plugin_manage.c b/src/plugin/src/plugin_manage.c index 088f5ad..ab8edb7 100644 --- a/src/plugin/src/plugin_manage.c +++ b/src/plugin/src/plugin_manage.c @@ -231,6 +231,7 @@ static void plug_manage_key_free_cb(uchar *key, uint key_size) sapp_mem_free(SAPP_MEM_FIX_PLUG_CTRL, MEM_STAT_GLOBAL_THREAD_ID, (void *)raw_mg_key->plug_name); sapp_mem_free(SAPP_MEM_FIX_PLUG_CTRL, MEM_STAT_GLOBAL_THREAD_ID, (void *)raw_mg_key->plug_entry_type); + sapp_mem_free(SAPP_MEM_FIX_PLUG_CTRL, MEM_STAT_GLOBAL_THREAD_ID, (void *)raw_mg_key); } @@ -266,7 +267,7 @@ static MESA_htable_handle create_plug_manage_htable(void) MESA_htable_set_opt(htable, MHO_CBFUN_COMPLEX_KEY_DUP, (void *)&plug_manage_key_dup_cb, sizeof(void *)); - MESA_htable_set_opt(htable, MHO_CBFUN_COMPLEX_KEY_FREE, (void *)plug_manage_key_free_cb, sizeof(void *)); + MESA_htable_set_opt(htable, MHO_CBFUN_COMPLEX_KEY_FREE, (void *)&plug_manage_key_free_cb, sizeof(void *)); /* 注意: plug_manage的data是dlopen的函数地址, 不能注册free callback */ //MESA_htable_set_opt(htable, MHO_CBFUN_DATA_FREE, NULL, sizeof(void *)); diff --git a/src/sapp_dev/sapp_global_val.c b/src/sapp_dev/sapp_global_val.c index d81d2c8..6605f07 100644 --- a/src/sapp_dev/sapp_global_val.c +++ b/src/sapp_dev/sapp_global_val.c @@ -265,6 +265,9 @@ void sapp_gval_destroy(void) SAPP_GLOBAL_FREE(sapp_global_val->cla.cmd_args_array);//�˴�ʹ����realloc��, Ҫ��sapp_mem_free() } + SAPP_GLOBAL_FREE(sapp_global_val->config.stream.tcp.well_known_ports_array); + SAPP_GLOBAL_FREE(sapp_global_val->config.stream.udp.well_known_ports_array); + sapp_config_file_link_t *pconfig = &sapp_global_val->config.cfg_file_path; SAPP_GLOBAL_FREE(pconfig->cfg_files_root_dir); SAPP_GLOBAL_FREE(pconfig->cfg_main_entry_relative); @@ -275,6 +278,8 @@ void sapp_gval_destroy(void) SAPP_GLOBAL_FREE(pconfig->cfg_plug_list_absolute); SAPP_GLOBAL_FREE(pconfig->cfg_project_list_relative); SAPP_GLOBAL_FREE(pconfig->cfg_project_list_absolute); + SAPP_GLOBAL_FREE(pconfig->cfg_entry_list_relative); + SAPP_GLOBAL_FREE(pconfig->cfg_entry_list_absolute); SAPP_GLOBAL_FREE(pconfig->cfg_file_send_raw_pkt_relative); SAPP_GLOBAL_FREE(pconfig->cfg_file_send_raw_pkt_absolute); SAPP_GLOBAL_FREE(pconfig->cfg_file_vxlan_sport_map_relative); @@ -308,6 +313,8 @@ void sapp_gval_destroy(void) SAPP_GLOBAL_FREE(pdata->data_memory_stat_log_absolute); SAPP_GLOBAL_FREE(sapp_global_val->config.library_file_path.libmarsio_file_path); + SAPP_GLOBAL_FREE(sapp_global_val->config.tools.pkt_dump.bpf_filter); + SAPP_GLOBAL_FREE(sapp_global_val->config.tools.pkt_dump.storge_path); /* individual_volatile, sapp_global_val���free */ if(sapp_global_val->individual_volatile){ diff --git a/src/timer/sapp_timer.c b/src/timer/sapp_timer.c index 12fbfb2..e61fe55 100644 --- a/src/timer/sapp_timer.c +++ b/src/timer/sapp_timer.c @@ -484,7 +484,7 @@ int sapp_timer_destroy(sapp_timer_handle h) sapp_usleep(100); pthread_join(inner_h->effective_thread_pid, NULL); - //free �ڴ���global_sapp_timer_destroy()ʵ�� + //free �ڴ��� global_sapp_timer_destroy() ʵ�� //free(h); return ST_RET_SUCC; |
