Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Tomas Härdin" <git@haerdin.se>
To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH 1/8] avformat/http: Return EIO for prematurely broken connection
Date: Wed, 05 Feb 2025 15:18:39 +0100
Message-ID: <f4713629c8248e1c33e109b919d6149a3a1f4c82.camel@haerdin.se> (raw)

[-- Attachment #1: Type: text/plain, Size: 143 bytes --]

Rebased and trimmed down Spotify patchset. Does not include the mfra or
ID3v2 stuff since those are turning out to be bigger tasks

/Tomas

[-- Attachment #2: 0001-avformat-http-Return-EIO-for-prematurely-broken-conn.patch --]
[-- Type: text/x-patch, Size: 2087 bytes --]

From c808ca473529ca952c42f00d12aa50ade38850d8 Mon Sep 17 00:00:00 2001
From: Ulrik <ulrikm@spotify.com>
Date: Mon, 27 Jul 2020 11:46:56 +0200
Subject: [PATCH 1/8] avformat/http: Return EIO for prematurely broken
 connection

Currently, a prematurely broken connection normally leads to the same
EOF, as a completed successful transfer. However, enabling reconnect
changes this logic, and leads to the return of EIO.

This patch unifies that logic, leading to the return of EIO for premature
disconnect, regardless of setting of "reconnect".
---
 libavformat/http.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index ec60bc0b17..65ea5d993c 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stdbool.h>
+
 #include "config.h"
 #include "config_components.h"
 
@@ -1747,6 +1749,7 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size)
     read_ret = http_buf_read(h, buf, size);
     while (read_ret < 0) {
         uint64_t target = h->is_streamed ? 0 : s->off;
+        bool is_premature = s->filesize > 0 && s->off < s->filesize;
 
         if (read_ret == AVERROR_EXIT)
             break;
@@ -1754,9 +1757,13 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size)
         if (h->is_streamed && !s->reconnect_streamed)
             break;
 
-        if (!(s->reconnect && s->filesize > 0 && s->off < s->filesize) &&
-            !(s->reconnect_at_eof && read_ret == AVERROR_EOF))
-            break;
+        if (!(s->reconnect && is_premature) &&
+            !(s->reconnect_at_eof && read_ret == AVERROR_EOF)) {
+            if (is_premature)
+                return AVERROR(EIO);
+            else
+                break;
+        }
 
         if (reconnect_delay > s->reconnect_delay_max || (s->reconnect_max_retries >= 0 && conn_attempts > s->reconnect_max_retries) ||
             reconnect_delay_total > s->reconnect_delay_total_max)
-- 
2.39.5


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

             reply	other threads:[~2025-02-05 14:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 14:18 Tomas Härdin [this message]
2025-02-05 14:19 ` [FFmpeg-devel] [PATCH 2/8] libavcodec/wmadec: Return AVERROR_INVALIDDATA on decoding errors Tomas Härdin
2025-02-05 16:28   ` Marth64
2025-02-05 14:20 ` [FFmpeg-devel] [PATCH 3/8] libavformat/flacdec: Export samples md5 as metadata Tomas Härdin
2025-02-05 14:20 ` [FFmpeg-devel] [PATCH 4/8] avformat/flacdec: Return correct error-codes on read-failure Tomas Härdin
2025-02-05 14:21 ` [FFmpeg-devel] [PATCH 5/8] rtmp: Set correct message stream id when writing as server Tomas Härdin
2025-02-05 14:22 ` [FFmpeg-devel] [PATCH 6/8] GOL-1361: Remove invalid CTTS sample_offset check Tomas Härdin
2025-02-05 14:23 ` [FFmpeg-devel] [PATCH 7/8] avformat/mp3dec: Subtract known padding from duration Tomas Härdin
2025-02-05 14:24 ` [FFmpeg-devel] [PATCH 8/8] Make mime-type award a bonus probe score Tomas Härdin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f4713629c8248e1c33e109b919d6149a3a1f4c82.camel@haerdin.se \
    --to=git@haerdin.se \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git