diff mbox series

[FFmpeg-devel] libavformat/tls_libtls: handle TLS_WANT_{POLLIN, POLLOUT} in read/write functions

Message ID 20220523104433.201414-1-matthieu.bouron@gmail.com
State New
Headers show
Series [FFmpeg-devel] libavformat/tls_libtls: handle TLS_WANT_{POLLIN, POLLOUT} in read/write functions | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Matthieu Bouron May 23, 2022, 10:44 a.m. UTC
According to the tls documentation: tls_read() and tls_write() can
return TLS_WANT_POLLIN and TLS_WANT_POLLOUT which indicates that the
same operation must be repeated immediately.

This commit prevents the libtls backend from failing when libtls returns
TLS_WANT_POLLIN or TLS_WANT_POLLOUT with the following error:

    [tls @ 0x7f6e20005a00] (null)
---
 libavformat/tls_libtls.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Matthieu Bouron May 30, 2022, 2:58 p.m. UTC | #1
On Mon, May 23, 2022 at 12:44:33PM +0200, Matthieu Bouron wrote:
> According to the tls documentation: tls_read() and tls_write() can
> return TLS_WANT_POLLIN and TLS_WANT_POLLOUT which indicates that the
> same operation must be repeated immediately.
> 
> This commit prevents the libtls backend from failing when libtls returns
> TLS_WANT_POLLIN or TLS_WANT_POLLOUT with the following error:
> 
>     [tls @ 0x7f6e20005a00] (null)
> ---
>  libavformat/tls_libtls.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavformat/tls_libtls.c b/libavformat/tls_libtls.c
> index 911c8094b0..22858d4867 100644
> --- a/libavformat/tls_libtls.c
> +++ b/libavformat/tls_libtls.c
> @@ -158,6 +158,8 @@ static int ff_tls_read(URLContext *h, uint8_t *buf, int size)
>          return ret;
>      else if (ret == 0)
>          return AVERROR_EOF;
> +    else if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT)
> +        return AVERROR(EAGAIN);
>      av_log(h, AV_LOG_ERROR, "%s\n", tls_error(p->ctx));
>      return AVERROR(EIO);
>  }
> @@ -171,6 +173,8 @@ static int ff_tls_write(URLContext *h, const uint8_t *buf, int size)
>          return ret;
>      else if (ret == 0)
>          return AVERROR_EOF;
> +    else if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT)
> +        return AVERROR(EAGAIN);
>      av_log(h, AV_LOG_ERROR, "%s\n", tls_error(p->ctx));
>      return AVERROR(EIO);
>  }
> -- 

Ping.
Marton Balint June 8, 2022, 9:16 p.m. UTC | #2
On Mon, 30 May 2022, Matthieu Bouron wrote:

> On Mon, May 23, 2022 at 12:44:33PM +0200, Matthieu Bouron wrote:
>> According to the tls documentation: tls_read() and tls_write() can
>> return TLS_WANT_POLLIN and TLS_WANT_POLLOUT which indicates that the
>> same operation must be repeated immediately.
>>
>> This commit prevents the libtls backend from failing when libtls returns
>> TLS_WANT_POLLIN or TLS_WANT_POLLOUT with the following error:
>>
>>     [tls @ 0x7f6e20005a00] (null)
>> ---
>>  libavformat/tls_libtls.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/libavformat/tls_libtls.c b/libavformat/tls_libtls.c
>> index 911c8094b0..22858d4867 100644
>> --- a/libavformat/tls_libtls.c
>> +++ b/libavformat/tls_libtls.c
>> @@ -158,6 +158,8 @@ static int ff_tls_read(URLContext *h, uint8_t *buf, int size)
>>          return ret;
>>      else if (ret == 0)
>>          return AVERROR_EOF;
>> +    else if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT)
>> +        return AVERROR(EAGAIN);
>>      av_log(h, AV_LOG_ERROR, "%s\n", tls_error(p->ctx));
>>      return AVERROR(EIO);
>>  }
>> @@ -171,6 +173,8 @@ static int ff_tls_write(URLContext *h, const uint8_t *buf, int size)
>>          return ret;
>>      else if (ret == 0)
>>          return AVERROR_EOF;
>> +    else if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT)
>> +        return AVERROR(EAGAIN);
>>      av_log(h, AV_LOG_ERROR, "%s\n", tls_error(p->ctx));
>>      return AVERROR(EIO);
>>  }
>> --
>
> Ping.

Thanks, applied.

Regards,
Marton
diff mbox series

Patch

diff --git a/libavformat/tls_libtls.c b/libavformat/tls_libtls.c
index 911c8094b0..22858d4867 100644
--- a/libavformat/tls_libtls.c
+++ b/libavformat/tls_libtls.c
@@ -158,6 +158,8 @@  static int ff_tls_read(URLContext *h, uint8_t *buf, int size)
         return ret;
     else if (ret == 0)
         return AVERROR_EOF;
+    else if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT)
+        return AVERROR(EAGAIN);
     av_log(h, AV_LOG_ERROR, "%s\n", tls_error(p->ctx));
     return AVERROR(EIO);
 }
@@ -171,6 +173,8 @@  static int ff_tls_write(URLContext *h, const uint8_t *buf, int size)
         return ret;
     else if (ret == 0)
         return AVERROR_EOF;
+    else if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT)
+        return AVERROR(EAGAIN);
     av_log(h, AV_LOG_ERROR, "%s\n", tls_error(p->ctx));
     return AVERROR(EIO);
 }