Close #77 修正http_half_private结构体未完全释放的问题

This commit is contained in:
Lu Qiuwen
2018-11-14 15:55:51 +08:00
parent ff5cc198a2
commit 6bcd2cb9a6
4 changed files with 67 additions and 2 deletions

View File

@@ -20,7 +20,6 @@ target_link_libraries(tfe pthread dl
target_link_libraries(tfe -Wl,--whole-archive http -Wl,--no-whole-archive) target_link_libraries(tfe -Wl,--whole-archive http -Wl,--no-whole-archive)
target_link_libraries(tfe -Wl,--whole-archive pangu-http -Wl,--no-whole-archive) target_link_libraries(tfe -Wl,--whole-archive pangu-http -Wl,--no-whole-archive)
#target_link_libraries(tfe -Wl,--whole-archive decrypt-mirroring -Wl,--no-whole-archive) #target_link_libraries(tfe -Wl,--whole-archive decrypt-mirroring -Wl,--no-whole-archive)
install(TARGETS tfe RUNTIME DESTINATION ./) install(TARGETS tfe RUNTIME DESTINATION ./)

View File

@@ -35,10 +35,12 @@ void decrypt_mirror_on_close_cb(const struct tfe_stream * stream, unsigned int t
mirror_stream_close(pme, thread_id); mirror_stream_close(pme, thread_id);
return; return;
} }
void decrypt_mirror_deinit(struct tfe_proxy * proxy) void decrypt_mirror_deinit(struct tfe_proxy * proxy)
{ {
return; return;
} }
struct tfe_plugin decrypt_mirror_spec={ struct tfe_plugin decrypt_mirror_spec={
.symbol=NULL, .symbol=NULL,
.type = TFE_PLUGIN_TYPE_BUSINESS, .type = TFE_PLUGIN_TYPE_BUSINESS,

View File

@@ -27,6 +27,7 @@ void hf_content_uncompress_destroy(struct hf_content_uncompress * cv_object)
{ {
(void) inflateEnd(cv_object->z_stream_ptr); (void) inflateEnd(cv_object->z_stream_ptr);
free(cv_object->z_stream_ptr); free(cv_object->z_stream_ptr);
free(cv_object->chunk);
cv_object->z_stream_ptr = NULL; cv_object->z_stream_ptr = NULL;
free(cv_object); free(cv_object);
} }
@@ -196,5 +197,8 @@ int hf_content_compress_write(struct hf_content_compress * cv_object,
void hf_content_compress_destroy(hf_content_compress * cv_object) void hf_content_compress_destroy(hf_content_compress * cv_object)
{ {
return; (void) deflateEnd(cv_object->z_stream_ptr);
free(cv_object->z_stream_ptr);
cv_object->z_stream_ptr = NULL;
free(cv_object);
} }

View File

@@ -693,6 +693,18 @@ void hf_private_destory(struct http_half_private * hf_private)
if (hf_private->parse_object != NULL) if (hf_private->parse_object != NULL)
{ {
free(hf_private->parse_object); free(hf_private->parse_object);
hf_private->parse_object = NULL;
}
struct http_header_private * header_iter = NULL;
struct http_header_private * header_titer = NULL;
TAILQ_FOREACH_SAFE(header_iter, &hf_private->header_list, next, header_titer)
{
TAILQ_REMOVE(&hf_private->header_list, header_iter, next);
free(header_iter->field);
free(header_iter->value);
free(header_iter);
} }
if (hf_private->event_cb_user_deleter != NULL) if (hf_private->event_cb_user_deleter != NULL)
@@ -700,6 +712,54 @@ void hf_private_destory(struct http_half_private * hf_private)
hf_private->event_cb_user_deleter(hf_private->event_cb_user); hf_private->event_cb_user_deleter(hf_private->event_cb_user);
} }
if (hf_private->evbuf_uri != NULL)
{
evbuffer_free(hf_private->evbuf_uri);
hf_private->evbuf_uri = NULL;
}
if (hf_private->url_storage)
{
free(hf_private->url_storage);
hf_private->url_storage = NULL;
}
if (hf_private->cv_uncompress_object)
{
hf_content_uncompress_destroy(hf_private->cv_uncompress_object);
hf_private->cv_uncompress_object = NULL;
}
if (hf_private->cv_compress_object)
{
hf_content_compress_destroy(hf_private->cv_compress_object);
hf_private->cv_compress_object = NULL;
}
if (hf_private->evbuf_header_field)
{
evbuffer_free(hf_private->evbuf_header_field);
hf_private->evbuf_header_field = NULL;
}
if (hf_private->evbuf_header_value)
{
evbuffer_free(hf_private->evbuf_header_value);
hf_private->evbuf_header_value = NULL;
}
if (hf_private->evbuf_body)
{
evbuffer_free(hf_private->evbuf_body);
hf_private->evbuf_body = NULL;
}
if (hf_private->evbuf_raw)
{
evbuffer_free(hf_private->evbuf_raw);
hf_private->evbuf_raw = NULL;
}
free(hf_private); free(hf_private);
} }