diff mbox

[FFmpeg-devel] libavformat/avio: retry_transfer_wrapper: don't treat 0 as EOF

Message ID 20170619203434.7672-1-daniel.kucera@gmail.com
State Superseded
Headers show

Commit Message

Daniel Kucera June 19, 2017, 8:34 p.m. UTC
transfer_func variable passed to retry_transfer_wrapper are
h->prot->url_read and h->prot->url_write functions. These need
to return EOF or other error properly. In case of returning >= 0,
 url_read/url_write is retried until error is returned.

requires patch: libavformat/cache: don't treat 0 as EOF

Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
---
 libavformat/avio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer June 21, 2017, 1:44 a.m. UTC | #1
On Mon, Jun 19, 2017 at 10:34:34PM +0200, Daniel Kucera wrote:
> transfer_func variable passed to retry_transfer_wrapper are
> h->prot->url_read and h->prot->url_write functions. These need
> to return EOF or other error properly. In case of returning >= 0,
>  url_read/url_write is retried until error is returned.
> 
> requires patch: libavformat/cache: don't treat 0 as EOF
> 
> Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
> ---
>  libavformat/avio.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Question from last review, still applies:

(Does this patch requires changes in protocols ? )
If so did you (or someone else) review all protocols to identify which
need to be updated ?

also it seems to infinite loop with the concat protocol
./ffmpeg -i concat:matrixbench_mpeg2.mpg|matrixbench_mpeg2.mpg file.avi

[...]
diff mbox

Patch

diff --git a/libavformat/avio.c b/libavformat/avio.c
index 1e79c9dd5c..d0cee42c39 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -393,8 +393,10 @@  static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf,
                 }
                 av_usleep(1000);
             }
-        } else if (ret < 1)
-            return (ret < 0 && ret != AVERROR_EOF) ? ret : len;
+        } else if (ret == AVERROR_EOF)
+            return len;
+        else if (ret < 0)
+            return ret;
         if (ret) {
             fast_retries = FFMAX(fast_retries, 2);
             wait_since = 0;