From patchwork Tue Feb 20 21:44:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 46400 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dda5:b0:19e:cdac:8cce with SMTP id kw37csp2129508pzb; Tue, 20 Feb 2024 13:45:01 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUGPIZgQWR893YBqxA41dHAZVxRqFtajEB5sQzPSVttMeQU7n4iyPDcG0IOJpvmFAK1xWdV4NSb+RVqufpbg5hAGXFfPXPhk1EfPw== X-Google-Smtp-Source: AGHT+IEgwSNbIPmFNg+jBSNSaHt4vHoZO4hBWCfET8VH3ikmiNPlR4p8Mb2BW+MVGux4EvBV1fa7 X-Received: by 2002:a05:6402:2055:b0:564:f3c2:85b2 with SMTP id bc21-20020a056402205500b00564f3c285b2mr112048edb.25.1708465500941; Tue, 20 Feb 2024 13:45:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708465500; cv=none; d=google.com; s=arc-20160816; b=FGi/G6/ElLT4EkI6NXRWx9FbkumzKLR9z1H+dnPVnRNl5AQqZMClMKdi5hWppTr3vq Z6atODEjsMdzbVWz5qfdgapsAWeHQdBl+S2bPoQL6y+sji+BONk/0SKBEmf7NMbUR6rw vmyGTGtY45Xgra4WVltSSxccLSvOssZRDcOrTdys5JIz6zYWjhms0NSofeJBEdCRDPuZ wnCgc6YiQwH6Uu0ybWUPbxuS9NxTb72iHEPcRvbdccq6CER+vpm/0Oh9NOeNZMmP7vUd LpLxbUI4gT2zwxayj6yvkGtdnFD3ezyGP1zwsGmCXC6H/JSlcGlqgH08hS0Ee8/hSt3A naIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=ITQ/+WCZyOy/XmIDcfhNq4Lr6EFqllwc5olOOsHj598=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=NRFtsd6nUYz8d9/DtEO2TzV/WOxQPXE5yXqo97l2VIjXJ0YSEKm0UkTdsRcrbsPNZ4 A0+AXqao9He6dV61XTymiv0areg2d7o8+tTFOhR2HpWlZ3bIwW2xKe4hkR98XbgriFot fUMf9wP3YNoWchWZV83zW5xvFZE0NT5CRxZycOEv4LbktyITVfzV5lKgRWeU81jEMnqf EiKVyAg2DWkPgBQoLwe+LBWZoXekM+azXNFtaY/FqugZn2SIvzPuhXmEg/afJ2zXW9nl yIUL2SnrFwJukEwJU5LDpyeATUZDA9IfjRha2LVixE6waXNnKtcsrdrsY0tIveblYqYd 4BBg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id cw3-20020a056402228300b00564da04dc30si563351edb.349.2024.02.20.13.45.00; Tue, 20 Feb 2024 13:45:00 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7345968D13B; Tue, 20 Feb 2024 23:44:57 +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 C7C1568CE0F for ; Tue, 20 Feb 2024 23:44:50 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 3F523E9FDD; Tue, 20 Feb 2024 22:44:50 +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 QwJrTOCCDNa7; Tue, 20 Feb 2024 22:44:48 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D57FDE9E85; Tue, 20 Feb 2024 22:44:47 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Tue, 20 Feb 2024 22:44:42 +0100 Message-Id: <20240220214442.19325-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/libsrt: use SRT_EPOLL_IN for waiting for an incoming connection X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: fSveAFgIvNUN 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 --- libavformat/libsrt.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index 56acb6e741..0edea9266d 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -250,7 +250,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; @@ -391,7 +391,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); @@ -455,18 +455,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);