From patchwork Sun Jan 31 18:32:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 25286 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4C76F44A299 for ; Sun, 31 Jan 2021 20:32:32 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 18D44689A63; Sun, 31 Jan 2021 20:32:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D96FB68990E for ; Sun, 31 Jan 2021 20:32:25 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A0FE4E4CDF; Sun, 31 Jan 2021 19:32:25 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wU_VWmiqwGz8; Sun, 31 Jan 2021 19:32:24 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 2C95BE4CD4; Sun, 31 Jan 2021 19:32:24 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 31 Jan 2021 19:32:17 +0100 Message-Id: <20210131183219.27814-1-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avformat/libsrt: close listen fd immediately after accept X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" There is no reason to keep it open. Signed-off-by: Marton Balint --- libavformat/libsrt.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index f73e7dbfa5..28c06f130e 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -53,7 +53,6 @@ enum SRTMode { typedef struct SRTContext { const AVClass *class; int fd; - int listen_fd; int eid; int64_t rw_timeout; int64_t listen_timeout; @@ -363,7 +362,7 @@ static int libsrt_set_options_pre(URLContext *h, int fd) static int libsrt_setup(URLContext *h, const char *uri, int flags) { struct addrinfo hints = { 0 }, *ai, *cur_ai; - int port, fd = -1, listen_fd = -1; + int port, fd = -1; SRTContext *s = h->priv_data; const char *p; char buf[256]; @@ -440,7 +439,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) // multi-client if ((ret = libsrt_listen(s->eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h, s->listen_timeout)) < 0) goto fail1; - listen_fd = fd; + srt_close(fd); fd = ret; } else { if (s->mode == SRT_MODE_RENDEZVOUS) { @@ -473,7 +472,6 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) h->is_streamed = 1; s->fd = fd; - s->listen_fd = listen_fd; freeaddrinfo(ai); return 0; @@ -484,16 +482,12 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) cur_ai = cur_ai->ai_next; if (fd >= 0) srt_close(fd); - if (listen_fd >= 0) - srt_close(listen_fd); ret = 0; goto restart; } fail1: if (fd >= 0) srt_close(fd); - if (listen_fd >= 0) - srt_close(listen_fd); freeaddrinfo(ai); srt_epoll_release(s->eid); return ret; @@ -689,10 +683,6 @@ static int libsrt_close(URLContext *h) SRTContext *s = h->priv_data; srt_close(s->fd); - - if (s->listen_fd >= 0) - srt_close(s->listen_fd); - srt_epoll_release(s->eid); srt_cleanup();