From 17d5382ab7faca277269ca4cdc382442eda835f7 Mon Sep 17 00:00:00 2001 From: Lorenzo Miniero Date: Wed, 11 Jan 2023 15:20:47 +0100 Subject: [PATCH] Close mountpoint sockets when leaving relay thread (see #3143, fixes #3111) --- plugins/janus_streaming.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/plugins/janus_streaming.c b/plugins/janus_streaming.c index fec9078d3c..3fde74ff76 100644 --- a/plugins/janus_streaming.c +++ b/plugins/janus_streaming.c @@ -8402,6 +8402,44 @@ static void *janus_streaming_relay_thread(void *data) { } } + /* Close the ports we bound to */ + if(source->audio_fd > -1) { + close(source->audio_fd); + source->audio_fd = -1; + } + if(source->video_fd[0] > -1) { + close(source->video_fd[0]); + source->video_fd[0] = -1; + } + if(source->video_fd[1] > -1) { + close(source->video_fd[1]); + source->video_fd[1] = -1; + } + if(source->video_fd[2] > -1) { + close(source->video_fd[2]); + source->video_fd[2] = -1; + } + if(source->data_fd > -1) { + close(source->data_fd); + source->data_fd = -1; + } + if(source->audio_rtcp_fd > -1) { + close(source->audio_rtcp_fd); + source->audio_rtcp_fd = -1; + } + if(source->video_rtcp_fd > -1) { + close(source->video_rtcp_fd); + source->video_rtcp_fd = -1; + } + if(source->pipefd[0] > -1) { + close(source->pipefd[0]); + source->pipefd[0] = -1; + } + if(source->pipefd[1] > -1) { + close(source->pipefd[1]); + source->pipefd[1] = -1; + } + /* Notify users this mountpoint is done */ janus_mutex_lock(&mountpoint->mutex); GList *viewer = g_list_first(mountpoint->viewers);