Message ID | 20210131183219.27814-1-cus@passwd.hu |
---|---|
State | Accepted |
Commit | d4e4ffd348ca39b66c79007ad1961f3303781d52 |
Headers | show |
Series | [FFmpeg-devel,1/3] avformat/libsrt: close listen fd immediately after accept | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
andriy/PPC64_make | success | Make finished |
andriy/PPC64_make_fate | success | Make fate finished |
On Sun, 31 Jan 2021, Marton Balint wrote: > There is no reason to keep it open. Will apply the series. Regards, Marton > > Signed-off-by: Marton Balint <cus@passwd.hu> > --- > 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(); > -- > 2.26.2 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
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();
There is no reason to keep it open. Signed-off-by: Marton Balint <cus@passwd.hu> --- libavformat/libsrt.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)