[FFmpeg-devel] [PATCH] TLS OPENSSL SSL_get_error

Michael Niedermayer michaelni at gmx.at
Wed Sep 4 04:47:40 CEST 2013


On Mon, Sep 02, 2013 at 12:36:50PM +0200, Mirko Puliafito wrote:
> Sorry tabs again.
> 
> That's the good one!

>  tls.c |   11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> f40e35c870cbebb99be5e3f5168be5b822482294  0001-Openssl-do_tls_poll-syscall-errors-handling.patch
> From e31ff0015957ea03e38794c84f28b6450d71fea4 Mon Sep 17 00:00:00 2001
> From: Mirko Puliafito <mirkpul at mirkpul-Vostro-3360.(none)>
> Date: Mon, 2 Sep 2013 12:35:13 +0200
> Subject: [PATCH] Openssl do_tls_poll syscall errors handling
> 
> ---
>  libavformat/tls.c |   11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/tls.c b/libavformat/tls.c
> index 2c85d1d..538f49c 100644
> --- a/libavformat/tls.c
> +++ b/libavformat/tls.c
> @@ -83,11 +83,16 @@ static int do_tls_poll(URLContext *h, int ret)
>          p.events = POLLIN;
>  #elif CONFIG_OPENSSL
>      ret = SSL_get_error(c->ssl, ret);
> -    if (ret == SSL_ERROR_WANT_READ) {
> +    switch(ret){
> +    case SSL_ERROR_WANT_READ:
>          p.events = POLLIN;
> -    } else if (ret == SSL_ERROR_WANT_WRITE) {
> +        break;
> +    case SSL_ERROR_WANT_WRITE:
>          p.events = POLLOUT;
> -    } else {
> +        break;

please dont mix unrelated changes in the same patch
(changing if/else to switch is unrelated)


> +    case SSL_ERROR_SYSCALL:
> +        return AVERROR(errno);

can errno be 0 here ?
also the code in tls_open() doesnt look like it handles EAGAIN that
this seems to be intended to return
the other callers look like they would busy loop

also make sure your code is tested before posting

Thanks

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130904/c8825568/attachment.asc>


More information about the ffmpeg-devel mailing list