[FFmpeg-devel] [PATCH] http connect: retry five times before reporting about error

Carl Eugen Hoyos ceffmpeg at gmail.com
Sun Sep 16 20:57:22 EEST 2018


2018-09-16 17:41 GMT+02:00, Artjom Vejsel <akawolf0 at gmail.com>:
> Signed-off-by: Artjom Vejsel <akawolf0 at gmail.com>
> ---
>
> Hello.
>
> I've faced an error while playing when downloading just stopped. It can be
> even few times at one film.
> After digging into source I've finished with knowledge that HTTP connection
> made only once and if it was not successfull, HTTP interface just report
> with an error.
> I tried to change this behaviour to try few times and that solve my problem.
>
>  libavformat/http.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/http.c b/libavformat/http.c
> index 4fdb2f13f2..9afa885423 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -259,11 +259,19 @@ redo:
>      cur_auth_type       = s->auth_state.auth_type;
>      cur_proxy_auth_type = s->auth_state.auth_type;
>
> +    attempts++;

Maybe this is just me but I believe the code gets clearer
if you move this into the if() below.

> +
>      location_changed = http_open_cnx_internal(h, options);
> -    if (location_changed < 0)
> -        goto fail;
> +    if (location_changed < 0) {
> +        if (attempts < 5) {

> +            av_log(h, AV_LOG_ERROR, "Couldn't get HTTP resource,
> retrying...\n");

Should be a warning imo.

> +            if (s->hd)
> +                ffurl_closep(&s->hd);
> +            goto redo;
> +        } else
> +            goto fail;
> +    }
>
> -    attempts++;

Carl Eugen


More information about the ffmpeg-devel mailing list