summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author姜鹏辉 <[email protected]>2020-12-04 19:15:42 +0800
committer姜鹏辉 <[email protected]>2020-12-04 19:15:42 +0800
commitb3b1a604f5227ab9e4485d872ec1ed314ba1b227 (patch)
tree9b1327e83249206bb2ddd6696b19a0119ae766dd
parent96f8bbc1ae251339f47b9821192a3e9fd563d75f (diff)
处理了一部分内存泄漏
-rw-r--r--qq_file_send.c42
1 files changed, 34 insertions, 8 deletions
diff --git a/qq_file_send.c b/qq_file_send.c
index f345b95..cdfb8bc 100644
--- a/qq_file_send.c
+++ b/qq_file_send.c
@@ -263,6 +263,7 @@ void free_fileinfo(void *thisfile)
#ifdef NIRVANA
nirvana_streaming_update_end(p->ctx);
#endif
+ free(p->file_len);
if (p->send_type == OFFLINE_SEND)
MESA_handle_runtime_log(runtime_log,RLOG_LV_INFO,"offline","save file %d , size: %lld bytes",p->id, *(p->file_len));
else
@@ -364,7 +365,7 @@ int match_uuid(qq_pme_info **pme)
void free_pme(qq_pme_info **pme)
{
qq_pme_info_p qq_pme = *pme;
- free(qq_pme->ctx);
+ //free(qq_pme->ctx);
free(qq_pme);
}
@@ -373,8 +374,8 @@ uchar qq_file_send_entry(stSessionInfo* session_info,void **pme,int thread_seq,s
{
int res,url_decoded_len;
- char bmd5[33];
char *url_decoded = NULL;
+ uchar rec = PROT_STATE_GIVEME;
//int payload_len = tcp_detail->datalen;
//char *payload =(char *)tcp_detail->pdata;
@@ -387,7 +388,7 @@ uchar qq_file_send_entry(stSessionInfo* session_info,void **pme,int thread_seq,s
case HTTP_REQ_LINE:
if(a_http->method!=HTTP_METHOD_POST)
{
- return PROT_STATE_DROPME;
+ rec = PROT_STATE_DROPME;
}
if (*pme == NULL)
{
@@ -399,10 +400,12 @@ uchar qq_file_send_entry(stSessionInfo* session_info,void **pme,int thread_seq,s
case HTTP_RES_LINE:
if (qq_pme == NULL)
{
- return PROT_STATE_DROPME;
+ rec = PROT_STATE_DROPME;
}
break;
case HTTP_MESSAGE_URL:
+ {
+ char bmd5[33];
url_decoded_len = session_info->buflen;
url_decoded = (char*)malloc(url_decoded_len*sizeof(char));
memcpy(url_decoded, session_info->buf, session_info->buflen);
@@ -415,14 +418,16 @@ uchar qq_file_send_entry(stSessionInfo* session_info,void **pme,int thread_seq,s
}
else
{
- return PROT_STATE_DROPME;
+ rec = PROT_STATE_DROPME;
}
break;
+ }
case HTTP_CONTENT:
{
int content_len = session_info->buflen;
char *content = (char *)malloc(content_len);
memcpy(content,session_info->buf,content_len);
+ char *origin_content = content;
if (content_len==0)
break;
if (qq_pme->curdir != a_http->curdir)
@@ -458,7 +463,7 @@ uchar qq_file_send_entry(stSessionInfo* session_info,void **pme,int thread_seq,s
// if the current http stream is transferring a file with a half,and the rule matches fail
// there will be a streamctx still open and no way to close
// but this situation seems won't happen
- return PROT_STATE_DROPME;
+ rec = PROT_STATE_DROPME;
}
else
MESA_handle_runtime_log(runtime_log,RLOG_LV_DEBUG,"match","online feature success,uuid:%s",qq_pme->uuid);
@@ -484,10 +489,19 @@ uchar qq_file_send_entry(stSessionInfo* session_info,void **pme,int thread_seq,s
nirvana_streaming_update_data(qq_pme->ctx, content, content_len);
#endif
}
+ free(origin_content);
break;
}
}
+
+ if(session_info->session_state&SESSION_STATE_CLOSE || rec == PROT_STATE_DROPME)
+ {
+ if(pme != NULL)
+ {
+ free_pme((qq_pme_info **)pme);
+ }
+ }
return PROT_STATE_GIVEME;
}
@@ -511,6 +525,18 @@ void nirvana_client_init()
//assert(instance_asyn!=NULL);
}
+void QQ_FILE_SEND_DESTROY()
+{
+ free(online_feature.separator_header);
+ free(offline_feature.separator_header);
+
+ free(online_feature.uuid_suffix);
+ free(offline_feature.uuid_suffix);
+
+ free(online_feature.end_suffix);
+ free(offline_feature.end_suffix);
+}
+
void qq_file_send_init()
{
printf("qq_file_send init\n");
@@ -518,7 +544,7 @@ void qq_file_send_init()
runtime_log = MESA_create_runtime_log_handle(LOG_PATH, 20);
- const char *inf_file = "./plug/business/qq_file_send/qq_file_send.inf";
+ char *inf_file = "./plug/business/qq_file_send/qq_file_send.inf";
read_res += read_profile_of_separator(inf_file,&online_feature,"ONLINE_FEATURE",ONLINE_SEND);
read_res += read_profile_of_separator(inf_file,&offline_feature,"OFFLINE_FEATURE",OFFLINE_SEND);
@@ -532,7 +558,7 @@ void qq_file_send_init()
MESA_handle_runtime_log(runtime_log,RLOG_LV_FATAL,"init","load save directory failed");
}
}
-
+ //free(inf_file);
if(read_res == 0)
MESA_handle_runtime_log(runtime_log,RLOG_LV_INFO,"init","------------load feature success------------");
else