From aaed4400dbf3f9bfcbb196912e0c1514544c992e Mon Sep 17 00:00:00 2001 From: Yalu Zhang <yalu.zhang@iopsys.eu> Date: Thu, 7 Dec 2023 16:01:07 +0000 Subject: [PATCH] Remove the definition of ubus_free_context() which has been moved to Asterisk --- src/channels/chan_voicemngr.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/channels/chan_voicemngr.c b/src/channels/chan_voicemngr.c index ab6af5e..7f5cc20 100644 --- a/src/channels/chan_voicemngr.c +++ b/src/channels/chan_voicemngr.c @@ -251,25 +251,6 @@ typedef struct shared_context { } share_context_t; static struct shared_context ctxs[MAX_CONTEXTS]; -/* - * In libubus, there is global variable defined as below. ubus_free() calls ubus_shutdown() which frees b->buf. - * which can cause memory corrupt when there is more than thread calls ubus_free() at the same time. In order - * to avoid this, ubus_free() shall be called only once when the program is about to exit. In other cases, - * ubus_free_context() shall be called to only free context specific resources but keep global buffer - * b->buf untouched. - * - * struct blob_buf b __hidden = {}; - */ -static void ubus_free_context(struct ubus_context *ctx) -{ - if (!ctx) - return; - close(ctx->sock.fd); - uloop_timeout_cancel(&ctx->pending_timer); - free(ctx->msgbuf.data); - free(ctx); -} - static struct ubus_context *get_shared_context(const char *func) { int tid = ast_get_tid(); @@ -287,7 +268,7 @@ static struct ubus_context *get_shared_context(const char *func) { for(int i=0; i < MAX_CONTEXTS; i++) { if (ctxs[i].tid != 0 && ctxs[i].last_used < time(NULL) - 300) { ast_log(LOG_DEBUG, "tid=%d, expiring context %d", tid, i); - ubus_free_context(ctxs[i].ctx); + ast_ubus_free_context(ctxs[i].ctx); ctxs[i].tid = 0; ctxs[i].last_used = 0; ctxs[i].ctx = NULL; @@ -707,7 +688,7 @@ static int chan_voicemngr_send_ubus_event(char *ev_name, int line) memset(&blob, 0, sizeof(blob)); if(blob_buf_init(&blob, 0)) { - ubus_free_context(ubusctx); + ast_ubus_free_context(ubusctx); return -1; } @@ -719,7 +700,7 @@ static int chan_voicemngr_send_ubus_event(char *ev_name, int line) res = -1; } - ubus_free_context(ubusctx); + ast_ubus_free_context(ubusctx); blob_buf_free(&blob); return res; @@ -4962,7 +4943,7 @@ static int endpt_get_rtp_stats(int line) { ret = ubus_invoke(local_ctx, endpt_id, "rtp_stats", bb.head, ubus_call_answer_rtp_stats, NULL, 500); blob_buf_free(&bb); - ubus_free_context(local_ctx); + ast_ubus_free_context(local_ctx); if (ret != UBUS_STATUS_OK) { ast_log(LOG_DEBUG, "ubus_invoke for rtp_stats failed with return value %d\n", ret); -- GitLab