From 96e04792bdb8aa2235f6a8b5b1a3e4204b78eacf Mon Sep 17 00:00:00 2001 From: Russell Bryant <russell@russellbryant.com> Date: Tue, 4 Mar 2008 22:28:03 +0000 Subject: [PATCH] add a destroy API call for a server instance git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@105804 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 2 +- include/asterisk/tcptls.h | 7 +++++++ main/http.c | 2 +- main/manager.c | 2 +- main/tcptls.c | 6 ++++++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 9fc627f222..a239e3d149 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2238,7 +2238,7 @@ cleanup: ast_free(me); cleanup2: fclose(ser->f); - ast_free(ser); + ser = ast_tcptls_server_instance_destroy(ser); if (req.socket.lock) { ast_mutex_destroy(req.socket.lock); diff --git a/include/asterisk/tcptls.h b/include/asterisk/tcptls.h index 3d7a2c9793..814e433a1a 100644 --- a/include/asterisk/tcptls.h +++ b/include/asterisk/tcptls.h @@ -166,4 +166,11 @@ void *ast_make_file_from_fd(void *data); HOOK_T ast_tcptls_server_read(struct ast_tcptls_server_instance *ser, void *buf, size_t count); HOOK_T ast_tcptls_server_write(struct ast_tcptls_server_instance *ser, void *buf, size_t count); +/*! + * \brief Destroy a server instance + * + * \return NULL for convenience + */ +struct ast_tcptls_server_instance *ast_tcptls_server_instance_destroy(struct ast_tcptls_server_instance *i); + #endif /* _ASTERISK_SERVER_H */ diff --git a/main/http.c b/main/http.c index 11db1779c8..7588461e21 100644 --- a/main/http.c +++ b/main/http.c @@ -827,7 +827,7 @@ static void *httpd_helper_thread(void *data) done: fclose(ser->f); - ast_free(ser); + ser = ast_tcptls_server_instance_destroy(ser); return NULL; } diff --git a/main/manager.c b/main/manager.c index ec8362b088..f8267a4ca4 100644 --- a/main/manager.c +++ b/main/manager.c @@ -2882,7 +2882,7 @@ static void *session_do(void *data) destroy_session(s); done: - ast_free(ser); + ser = ast_tcptls_server_instance_destroy(ser); return NULL; } diff --git a/main/tcptls.c b/main/tcptls.c index d623420a50..658ab25ee5 100644 --- a/main/tcptls.c +++ b/main/tcptls.c @@ -446,3 +446,9 @@ void *ast_make_file_from_fd(void *data) else return ser; } + +struct ast_tcptls_server_instance *ast_tcptls_server_instance_destroy(struct ast_tcptls_server_instance *i) +{ + ast_free(i); + return NULL; +} -- GitLab