From patchwork Sun Feb 7 13:18:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 25480 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 184B544AE1F for ; Sun, 7 Feb 2021 15:19:09 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0302E689E50; Sun, 7 Feb 2021 15:19:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from qq.com (out203-205-221-149.mail.qq.com [203.205.221.149]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AA323689ADA for ; Sun, 7 Feb 2021 15:19:00 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1612703934; bh=cy8Y23w9UyJZsJwHGh9gCNkLqjtTGG4iK5XO0AnJrUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=R/cJqlqVQgPYWi+yrO4S3rsMK3+lbiNqfi+9mjU+dr7MpDVjd1hRmBEPFUPOrG7Gh TjXD2ySD/Ar/ATFQ1SLSwh2zkZ2sbjugB3ok4coUdHKo2nZAph3o+jlGaE1SNx/A+8 qhD1zMUcOrgxRKUrZXNMT38Bz/45afoaQ5tu3EP8= Received: from ZHILIZHAO-MB2.tencent.com ([59.37.125.48]) by newxmesmtplogicsvrsza9.qq.com (NewEsmtp) with SMTP id 4B3B4AFE; Sun, 07 Feb 2021 21:18:51 +0800 X-QQ-mid: xmsmtpt1612703932ts6jxhjup Message-ID: X-QQ-XMAILINFO: NgCnwGR1L6mrujFdWQWO7lxYvywdtp6TVN+S4Jrdfedq4xBOHiqTpFe81lTfTH JJL5LnX/SLfK0NxAD3kC2SBOYD6QiIdvA9TydX5NMNkHQgrb75toF/Do2N6yg+m/QpuLwmK3Yvrk 9gwHxPUCWg5nzcZpwMMJJSQT8tWc1VY4wg5TqeZJ2VMoXpDYQgZX8kKB6UdOF+79tpLjulJ0weHw 7QJClBhIWnKG5vUFpUQEBjLV38UqoppyKCFIHbc16cG9SOVFo2GfQLSRqQZVFRAoqYNBoZo8xKtM Zns6et0djeTg91M3eJcqb+8weUYVfvrUJMSdORPXD9+JV4koLYm7gw1f7z61rWx3pRgPsCyWm77k I28i15BJYPXm3n+RmzEhNz9MS6y2oOfZFi8yMU0llYigmskjZrFvZpuCvuDW5qqu7Hsv9wUmF7Wm ffyphR7ZFLwHG6gW9PrudP4z4GJab9cFLTK409FASvCHfQDrYjNBP+bH8PyAe32afZuZAB1i5Uj/ xFXyz6i1GaRCI9vM/2JR0zLst07ezpIUNIb5FZ1wrv3WydLsYbIGx0U6ka7fxLSMxnZpmbtXzXQx uJRj5HbE0v+6pmss4w8sftxyV9VsJIpLzy9Jtaq2OYQLl7U7J41GatVEiOOInyKRyeQS9ZETc7Uv 01OKBNELIGGFepON3/bjVe6czYk/XWe8mhnkRJkPBvUSjo87fYlH0OKBEDeFc2+Ug/VrEf3YqSpE WqM7OUz5EKrnh56ln/JZurnsZE7FRJlBN/IdLyDi2U56bcPV59xQozhKAxaFy5gfJBcRsx4G3S8I mNbMwT0WCeMv58btjtchC3 From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 Feb 2021 21:18:50 +0800 X-OQ-MSGID: <20210207131850.44995-2-quinkblack@foxmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210207131850.44995-1-quinkblack@foxmail.com> References: <20210207131850.44995-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avformat/libsrt: fix timeout inaccurate in wait_fd_timeout 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: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The wait_start was about POLLING_TIME larger which leads to timeout 100ms late than the option setting. --- libavformat/libsrt.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index d3c661d9d8..d08634b71a 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -196,7 +196,10 @@ static int libsrt_network_wait_fd(URLContext *h, int eid, int fd, int write) static int libsrt_network_wait_fd_timeout(URLContext *h, int eid, int fd, int write, int64_t timeout, AVIOInterruptCB *int_cb) { int ret; - int64_t wait_start = 0; + int64_t wait_start; + + if (timeout > 0) + wait_start = av_gettime_relative(); while (1) { if (ff_check_interrupt(int_cb)) @@ -204,12 +207,8 @@ static int libsrt_network_wait_fd_timeout(URLContext *h, int eid, int fd, int wr ret = libsrt_network_wait_fd(h, eid, fd, write); if (ret != AVERROR(EAGAIN)) return ret; - if (timeout > 0) { - if (!wait_start) - wait_start = av_gettime_relative(); - else if (av_gettime_relative() - wait_start > timeout) - return AVERROR(ETIMEDOUT); - } + if (timeout > 0 && (av_gettime_relative() - wait_start > timeout)) + return AVERROR(ETIMEDOUT); } }