From cbf52aee8e4a924a26aa79da92c5916a13a89cf9 Mon Sep 17 00:00:00 2001 From: topworldcoder <63830798+topworldcoder@users.noreply.github.com> Date: Wed, 11 Dec 2024 16:35:24 +0800 Subject: [PATCH] Add memory release and thread release 1. Call usrsctp_finish to release the sctp thread 2. Call ssl_transport_disconnect to release the memory of g_ps.net_ctx --- src/peer_signaling.c | 2 ++ src/sctp.c | 1 + 2 files changed, 3 insertions(+) diff --git a/src/peer_signaling.c b/src/peer_signaling.c index bd0fa53..822a069 100644 --- a/src/peer_signaling.c +++ b/src/peer_signaling.c @@ -471,6 +471,8 @@ void peer_signaling_leave_channel() { if (status != MQTTSuccess) { LOGE("Failed to disconnect with broker: %s", MQTT_Status_strerror(status)); } + + ssl_transport_disconnect(&g_ps.net_ctx); } } diff --git a/src/sctp.c b/src/sctp.c index 76ebeaa..c59a300 100644 --- a/src/sctp.c +++ b/src/sctp.c @@ -576,6 +576,7 @@ void sctp_destroy_socket(Sctp* sctp) { if (sctp && sctp->sock) { usrsctp_shutdown(sctp->sock, SHUT_RDWR); usrsctp_close(sctp->sock); + usrsctp_finish(); sctp->sock = NULL; } #endif