diff mbox

[FFmpeg-devel] lavf/libssh: translate a read of 0 to EOF

Message ID 20180528002135.24401-1-jeebjp@gmail.com
State Accepted
Commit 26892c7615395f331f6143535f03a2957973e2e0
Headers show

Commit Message

Jan Ekström May 28, 2018, 12:21 a.m. UTC
Yet another case of forgotten 0 =! EOF translation.

While the documentation for this specific synchronous read
function does not mention it, the documentation for
`sftp_async_read` documents it, as well as looking at the
implementation of this function leads one to find
`if (handle->eof) { return 0; }`.

Reported by stnutt on IRC.
---
 libavformat/libssh.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Ekström May 28, 2018, 10:29 a.m. UTC | #1
On Mon, May 28, 2018, 03:21 Jan Ekström <jeebjp@gmail.com> wrote:

> Yet another case of forgotten 0 =! EOF translation.
>
> While the documentation for this specific synchronous read
> function does not mention it, the documentation for
> `sftp_async_read` documents it, as well as looking at the
> implementation of this function leads one to find
> `if (handle->eof) { return 0; }`.
>
> Reported by stnutt on IRC.
> ---
>  libavformat/libssh.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/libssh.c b/libavformat/libssh.c
> index 9e3d4da45e..21474f0f0a 100644
> --- a/libavformat/libssh.c
> +++ b/libavformat/libssh.c
> @@ -295,7 +295,7 @@ static int libssh_read(URLContext *h, unsigned char
> *buf, int size)
>          av_log(libssh, AV_LOG_ERROR, "Read error.\n");
>          return AVERROR(EIO);
>      }
> -    return bytes_read;
> +    return bytes_read ? bytes_read : AVERROR_EOF;
>  }
>
>  static int libssh_write(URLContext *h, const unsigned char *buf, int size)
> --
> 2.17.0
>


During the time while I was sleeping I got a confirnation from the user
that this indeed fixes the issues with seeming freezing+constant cpu usage
with the sftp protocol.

In other words, if this looks OK to people, feel free to merge while I'm at
work and back-port to release/4.0


Jan

>
Nicolas George May 28, 2018, 11:16 a.m. UTC | #2
Jan Ekström (2018-05-28):
> Yet another case of forgotten 0 =! EOF translation.
> 
> While the documentation for this specific synchronous read
> function does not mention it, the documentation for
> `sftp_async_read` documents it, as well as looking at the
> implementation of this function leads one to find
> `if (handle->eof) { return 0; }`.
> 
> Reported by stnutt on IRC.

LGTM.
Jan Ekström May 28, 2018, 5:36 p.m. UTC | #3
On Mon, May 28, 2018 at 2:16 PM, Nicolas George <george@nsup.org> wrote:
> Jan Ekström (2018-05-28):
>> Yet another case of forgotten 0 =! EOF translation.
>>
>> While the documentation for this specific synchronous read
>> function does not mention it, the documentation for
>> `sftp_async_read` documents it, as well as looking at the
>> implementation of this function leads one to find
>> `if (handle->eof) { return 0; }`.
>>
>> Reported by stnutt on IRC.
>
> LGTM.
>
> --
>   Nicolas George

Cheers.

Pushed and back-ported to release/4.0.

Jan
diff mbox

Patch

diff --git a/libavformat/libssh.c b/libavformat/libssh.c
index 9e3d4da45e..21474f0f0a 100644
--- a/libavformat/libssh.c
+++ b/libavformat/libssh.c
@@ -295,7 +295,7 @@  static int libssh_read(URLContext *h, unsigned char *buf, int size)
         av_log(libssh, AV_LOG_ERROR, "Read error.\n");
         return AVERROR(EIO);
     }
-    return bytes_read;
+    return bytes_read ? bytes_read : AVERROR_EOF;
 }
 
 static int libssh_write(URLContext *h, const unsigned char *buf, int size)