[FFmpeg-cvslog] avformat/libsrt: use SRT_EPOLL_IN for waiting for an incoming connection

Marton Balint git at videolan.org
Tue Mar 19 22:17:44 EET 2024


ffmpeg | branch: release/5.1 | Marton Balint <cus at passwd.hu> | Tue Feb 20 22:34:37 2024 +0100| [995e7f43a7a2a10b667df30470384e1c0aba5573] | committer: Marton Balint

avformat/libsrt: use SRT_EPOLL_IN for waiting for an incoming connection

This is the proper poll mode for waiting for an incoming connection according
to the SRT API docs.

Fixes ticket #9142.

Signed-off-by: Marton Balint <cus at passwd.hu>
(cherry picked from commit 87677c2195e86b126c3438439a05d0a46ae5bb50)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=995e7f43a7a2a10b667df30470384e1c0aba5573
---

 libavformat/libsrt.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index cd8f5b1e7d..1fb97392c3 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -249,7 +249,7 @@ static int libsrt_listen(int eid, int fd, const struct sockaddr *addr, socklen_t
     if (srt_listen(fd, 1))
         return libsrt_neterrno(h);
 
-    ret = libsrt_network_wait_fd_timeout(h, eid, 1, timeout, &h->interrupt_callback);
+    ret = libsrt_network_wait_fd_timeout(h, eid, 0, timeout, &h->interrupt_callback);
     if (ret < 0)
         return ret;
 
@@ -390,7 +390,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags)
     char hostname[1024],proto[1024],path[1024];
     char portstr[10];
     int64_t open_timeout = 0;
-    int eid, write_eid;
+    int eid;
 
     av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
         &port, path, sizeof(path), uri);
@@ -454,18 +454,21 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags)
     if (libsrt_socket_nonblock(fd, 1) < 0)
         av_log(h, AV_LOG_DEBUG, "libsrt_socket_nonblock failed\n");
 
-    ret = write_eid = libsrt_epoll_create(h, fd, 1);
-    if (ret < 0)
-        goto fail1;
     if (s->mode == SRT_MODE_LISTENER) {
+        int read_eid = ret = libsrt_epoll_create(h, fd, 0);
+        if (ret < 0)
+            goto fail1;
         // multi-client
-        ret = libsrt_listen(write_eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h, s->listen_timeout);
-        srt_epoll_release(write_eid);
+        ret = libsrt_listen(read_eid, fd, cur_ai->ai_addr, cur_ai->ai_addrlen, h, s->listen_timeout);
+        srt_epoll_release(read_eid);
         if (ret < 0)
             goto fail1;
         srt_close(fd);
         fd = ret;
     } else {
+        int write_eid = ret = libsrt_epoll_create(h, fd, 1);
+        if (ret < 0)
+            goto fail1;
         if (s->mode == SRT_MODE_RENDEZVOUS) {
             if (srt_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen)) {
                 ret = libsrt_neterrno(h);



More information about the ffmpeg-cvslog mailing list