From patchwork Mon Dec 7 10:08:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 24382 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 D11D444B3F9 for ; Mon, 7 Dec 2020 12:09:01 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B5AA8689A09; Mon, 7 Dec 2020 12:09:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7B35E6897E4 for ; Mon, 7 Dec 2020 12:08:54 +0200 (EET) Received: by mail-lf1-f44.google.com with SMTP id u19so17231120lfr.7 for ; Mon, 07 Dec 2020 02:08:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=T57zhgFa/vIKHIGmkdagj2Hh1id67cZt4nTeUAe0UYA=; b=rCxL/gGmOJ+hsDoGn1J8CQmI68jSLIBn5DCLSTVlnmw2jrJnU6a27AJD2sofJtUcj9 D/XfE8567SUxPzxjhQ6Fu8TYa6lxpO//H99poq9E4qyHBilgpGeRP2dSjjBt6+v9N1/h ibqCVIaeV2uj4NavUZlFFH7PoCySUZfA6ZGt91rPHYwsIGITucJLhGvHbu21ZW0YVNPF 4sc2hQoT6PlCzfHQo1Dn02TWcG4QEHaTs1EC0Na53Xw6ajHmNTilyQdr9tzQIkrh8dyd dHBDyxYdkhC1/LofeasGP0vsN0DbGujNcPVBMHC0RLWuBGCGjrI7hilMEL0JMJYPAL2+ wsKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T57zhgFa/vIKHIGmkdagj2Hh1id67cZt4nTeUAe0UYA=; b=TsaaDkd8QKEQuxehPR4TlyQB+zee2RK0iwBk7L1mJsicBgMDGog10/K7FtXE+eqolN pbweO8V2Ld0bqB3W/hY/9jsdgM7qjyhU6IZYYwM34NVGHP3Qe1HW68SCFBeEMOL6R7yt n8VYevNMIMFr/WEJXArYqaWOMLU6Jn09LKiXIwAo4jJia4tp5Uw9aAYIT962N65FJ+AD 6lexoZyah443H9xBxqroyfMYpStqJqo0ING4xM5gBqtvddfJO+k/cF64hXklXDzIUQU8 cT3pBStCRs+xpPuT0nF+jnpcIX3+WULHQSocPTWlnj7C32PldQC1eYxoHrxdAuNdikNp tb/w== X-Gm-Message-State: AOAM532ONZrhUmod33Kb4ohgGmtqHIGopI709IqfrDDjC7d9pfDoqk2t kpQyRRasyYPJ05iA6mhNW0IEuB3aT0bbIQ== X-Google-Smtp-Source: ABdhPJwwtNd36t3z4YTKos537H0IHzSyz1p5Q2MVauLupHN+K0HCZu4NTYz9EWz5cEFHU0CrKzdP7A== X-Received: by 2002:a19:7415:: with SMTP id v21mr1453335lfe.343.1607335732856; Mon, 07 Dec 2020 02:08:52 -0800 (PST) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id v5sm45061ljj.135.2020.12.07.02.08.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 02:08:52 -0800 (PST) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Dec 2020 12:08:44 +0200 Message-Id: <20201207100845.17520-5-jeebjp@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201207100845.17520-1-jeebjp@gmail.com> References: <20201207100845.17520-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] avformat/fifo: close IO in case header writing fails 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Jan Ekström Otherwise each new attempt will leave its connection open. Signed-off-by: Jan Ekström --- libavformat/fifo.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavformat/fifo.c b/libavformat/fifo.c index 9fc524adbdf..bc363e458cd 100644 --- a/libavformat/fifo.c +++ b/libavformat/fifo.c @@ -142,8 +142,14 @@ static int fifo_thread_write_header(FifoThreadContext *ctx) avf2->streams[i]->cur_dts = 0; ret = avformat_write_header(avf2, &format_options); - if (!ret) - ctx->header_written = 1; + if (ret < 0) { + av_log(avf2, AV_LOG_ERROR, + "Failed to write format header: %s\n", av_err2str(ret)); + ff_format_io_close(avf2, &avf2->pb); + goto end; + } + + ctx->header_written = 1; // Check for options unrecognized by underlying muxer if (format_options) {