diff mbox

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

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

Commit Message

Daniel Kucera June 5, 2017, 7:18 p.m. UTC
Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
---
 libavformat/cache.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Daniel Kucera June 9, 2017, 1:39 p.m. UTC | #1
2017-06-05 21:18 GMT+02:00 Daniel Kucera <daniel.kucera@gmail.com>:
> Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
> ---
>  libavformat/cache.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/cache.c b/libavformat/cache.c
> index 6aabca2e78..66bbbf54c9 100644
> --- a/libavformat/cache.c
> +++ b/libavformat/cache.c
> @@ -201,7 +201,7 @@ static int cache_read(URLContext *h, unsigned char *buf, int size)
>      }
>
>      r = ffurl_read(c->inner, buf, size);
> -    if (r == 0 && size>0) {
> +    if (r == AVERROR_EOF && size>0) {
>          c->is_true_eof = 1;
>          av_assert0(c->end >= c->logical_pos);
>      }
> @@ -263,7 +263,7 @@ resolve_eof:
>                  if (whence == SEEK_SET)
>                      size = FFMIN(sizeof(tmp), pos - c->logical_pos);
>                  ret = cache_read(h, tmp, size);
> -                if (ret == 0 && whence == SEEK_END) {
> +                if (ret == AVERROR_EOF && whence == SEEK_END) {
>                      av_assert0(c->is_true_eof);
>                      goto resolve_eof;
>                  }
> --
> 2.11.0
>

Reminding for review.
Nicolas George June 15, 2017, 8:18 a.m. UTC | #2
Le septidi 17 prairial, an CCXXV, Daniel Kucera a écrit :
> Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
> ---
>  libavformat/cache.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

I think this is correct, but I do not maintain that file and the code
has spaghetti properties.

Regards,
Michael Niedermayer June 21, 2017, 2:06 a.m. UTC | #3
On Fri, Jun 09, 2017 at 03:39:59PM +0200, Daniel Kučera wrote:
> 2017-06-05 21:18 GMT+02:00 Daniel Kucera <daniel.kucera@gmail.com>:
> > Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
> > ---
> >  libavformat/cache.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavformat/cache.c b/libavformat/cache.c
> > index 6aabca2e78..66bbbf54c9 100644
> > --- a/libavformat/cache.c
> > +++ b/libavformat/cache.c
> > @@ -201,7 +201,7 @@ static int cache_read(URLContext *h, unsigned char *buf, int size)
> >      }
> >
> >      r = ffurl_read(c->inner, buf, size);
> > -    if (r == 0 && size>0) {
> > +    if (r == AVERROR_EOF && size>0) {
> >          c->is_true_eof = 1;
> >          av_assert0(c->end >= c->logical_pos);
> >      }
> > @@ -263,7 +263,7 @@ resolve_eof:
> >                  if (whence == SEEK_SET)
> >                      size = FFMIN(sizeof(tmp), pos - c->logical_pos);
> >                  ret = cache_read(h, tmp, size);
> > -                if (ret == 0 && whence == SEEK_END) {
> > +                if (ret == AVERROR_EOF && whence == SEEK_END) {
> >                      av_assert0(c->is_true_eof);
> >                      goto resolve_eof;
> >                  }
> > --
> > 2.11.0
> >
> 
> Reminding for review.

causes infinite loop in fate-seek-cache-pipe

also if 2 patches each require the other they must be in one patch
as neither could be applied first.


[...]
diff mbox

Patch

diff --git a/libavformat/cache.c b/libavformat/cache.c
index 6aabca2e78..66bbbf54c9 100644
--- a/libavformat/cache.c
+++ b/libavformat/cache.c
@@ -201,7 +201,7 @@  static int cache_read(URLContext *h, unsigned char *buf, int size)
     }
 
     r = ffurl_read(c->inner, buf, size);
-    if (r == 0 && size>0) {
+    if (r == AVERROR_EOF && size>0) {
         c->is_true_eof = 1;
         av_assert0(c->end >= c->logical_pos);
     }
@@ -263,7 +263,7 @@  resolve_eof:
                 if (whence == SEEK_SET)
                     size = FFMIN(sizeof(tmp), pos - c->logical_pos);
                 ret = cache_read(h, tmp, size);
-                if (ret == 0 && whence == SEEK_END) {
+                if (ret == AVERROR_EOF && whence == SEEK_END) {
                     av_assert0(c->is_true_eof);
                     goto resolve_eof;
                 }