From ea288deccd43d547aa0c4fc7924218c830a3468c Mon Sep 17 00:00:00 2001 From: ChenGH Date: Mon, 21 Nov 2022 23:49:38 +0800 Subject: [PATCH] Asan: Try to fix st_memory_leak for asan check (#3264) * asan: try to fix st_memory_leak for asan check * asan: srs_st_unit should be call in hybrid server stop * Rename st_uninit to st_destroy. v5.0.91 Co-authored-by: winlin --- trunk/src/app/srs_app_hybrid.cpp | 2 ++ trunk/src/protocol/srs_protocol_st.cpp | 5 +++++ trunk/src/protocol/srs_protocol_st.hpp | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/trunk/src/app/srs_app_hybrid.cpp b/trunk/src/app/srs_app_hybrid.cpp index 0f285b4874a..0f6f6d438c8 100644 --- a/trunk/src/app/srs_app_hybrid.cpp +++ b/trunk/src/app/srs_app_hybrid.cpp @@ -232,6 +232,8 @@ void SrsHybridServer::stop() ISrsHybridServer* server = *it; server->stop(); } + + srs_st_destroy(); } SrsServerAdapter* SrsHybridServer::srs() diff --git a/trunk/src/protocol/srs_protocol_st.cpp b/trunk/src/protocol/srs_protocol_st.cpp index 73d2ed10ada..88a6470dcf4 100644 --- a/trunk/src/protocol/srs_protocol_st.cpp +++ b/trunk/src/protocol/srs_protocol_st.cpp @@ -70,6 +70,11 @@ srs_error_t srs_st_init() return srs_success; } +void srs_st_destroy(void) +{ + st_destroy(); +} + void srs_close_stfd(srs_netfd_t& stfd) { if (stfd) { diff --git a/trunk/src/protocol/srs_protocol_st.hpp b/trunk/src/protocol/srs_protocol_st.hpp index 5603f02e4ea..aa02839c986 100644 --- a/trunk/src/protocol/srs_protocol_st.hpp +++ b/trunk/src/protocol/srs_protocol_st.hpp @@ -19,8 +19,10 @@ typedef void* srs_thread_t; typedef void* srs_cond_t; typedef void* srs_mutex_t; -// Initialize st, requires epoll. +// Initialize ST, requires epoll for linux. extern srs_error_t srs_st_init(); +// Destroy ST, free resources for asan detecting. +extern void srs_st_destroy(void); // Close the netfd, and close the underlayer fd. // @remark when close, user must ensure io completed.