From e083fec85105194eb946966e02c4d298b966be00 Mon Sep 17 00:00:00 2001 From: 刘学利 Date: Fri, 11 Jun 2021 01:34:36 +0000 Subject: Bugfix memory leak by return dropme --- src/dns.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src/dns.cpp') diff --git a/src/dns.cpp b/src/dns.cpp index a33b80b..7e2f58d 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -1852,11 +1852,15 @@ char DNS_UDP_ENTRY(struct streaminfo *a_udp, void **pme, int thread_seq, void *a break; case OP_STATE_CLOSE: state=callback_dns_business_plug(a_udp, pme, NULL, DNS_ALL, SESSION_STATE_CLOSE, thread_seq, a_packet); - dictator_free(thread_seq, *pme); - *pme = NULL; break; } + if(state&APP_STATE_DROPME || a_udp->opstate==OP_STATE_CLOSE) + { + dictator_free(thread_seq, *pme); + *pme = NULL; + } + return state; } @@ -1940,12 +1944,16 @@ char DNS_TCP_ENTRY(struct streaminfo *a_tcp, void **pme, int thread_seq, void *a state=parse_dns_protocol(a_tcp, a_tcp->opstate, payload, payload_len, pme, thread_seq, a_packet); break; case OP_STATE_CLOSE: - state=callback_dns_business_plug(a_tcp, pme, NULL, DNS_UNKOWN, SESSION_STATE_CLOSE, thread_seq, a_packet); - dictator_free(thread_seq, *pme); - *pme = NULL; + state=callback_dns_business_plug(a_tcp, pme, NULL, DNS_UNKOWN, SESSION_STATE_CLOSE, thread_seq, a_packet); break; } + if(state&APP_STATE_DROPME || a_tcp->opstate==OP_STATE_CLOSE) + { + dictator_free(thread_seq, *pme); + *pme = NULL; + } + return state; } @@ -1985,8 +1993,8 @@ int DNS_INIT() FS_set_para(g_dns_proto_info.stat_handle, STAT_CYCLE, &g_dns_proto_info.cycle_time, sizeof(g_dns_proto_info.cycle_time)); - for(i = 0; DNS_STATIS_INFO[i].str != NULL && i == (int)DNS_STATIS_INFO[i].id && i < DNS_MAX_FIELD_ID_NUM; i++) - { + for(i = 0; i