From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 291984A92F for ; Wed, 24 Apr 2024 11:08:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 320CB68D2F1; Wed, 24 Apr 2024 14:08:48 +0300 (EEST) Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C8E7D68CD39 for ; Wed, 24 Apr 2024 14:08:41 +0300 (EEST) Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-5193363d255so8911210e87.3 for ; Wed, 24 Apr 2024 04:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20230601.gappssmtp.com; s=20230601; t=1713956921; x=1714561721; darn=ffmpeg.org; h=mime-version:references:message-id:in-reply-to:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=w4768vjM7+OjIV4Citc2wx8PYPw2JDMb2Cum00As/jg=; b=YU0tY8hJHhBVk4KF6WluADqaMWzFgVlzfLTnxO/jzVL6ZMesHczQn3yL9wqs9ipIu9 WMUvB+TqO0zxRtLLyGWYyLACM0cxFmOAsVQy0NcGy7eu9JcImMlhBt+ZqLMyXQwRQCT0 SulxD7HJE2xZLXym0T/QlS7PwDuZe5ENKlCLw7yqC7TT6FtXf/72QA6RDPg5D9/nwqd5 +rWi4aajkOSNdMSQv55WDU3219ykG3vms21KZsHxJg/FrJ5tr+f3Zc8Vs/rW9AnGbfv0 UVbNXPfXOi275EYO+JRLZ8JQqlEvI+iPIORhYopoNhIV4N2I/NLP+N2Z90Ry5456zSXj zx1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713956921; x=1714561721; h=mime-version:references:message-id:in-reply-to:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=w4768vjM7+OjIV4Citc2wx8PYPw2JDMb2Cum00As/jg=; b=F7SHFJlrLD1oeYiubCqx1/X32SyrkZN28Ku2Eda9zpicANHFqbteAyE6LuygxN3ii2 /m5IrrR9bOm0RvLBt6aJWPMPiZgxHSoUezItdydpRTwuVJ/Bnj6fvQfrbXqkkWGg1qMd RaPkuzK5sCD8HJIdCWbE2MTPSKw+fJ6gDnMyMv+wvkq91MbS5WwkHr8/CHcNrCOJazD3 B4LUjJr3DTNo2/2He1N0pM8GX9QL14daOzkgmnOf3ByRKbUpN5VBCLy8rQrzucFtzZwX 5+tapEGtjjb+KYxdBN1qB0Yh+l6DQvfp/jKGavdiuAPMiwUmsrnbdPQgHmSa2fjwlYDZ C8AA== X-Gm-Message-State: AOJu0YzdGc15cMD3gLZ5ij2HsqXikzHALJevRsQgMmwVQpj7nMaEGkTO xuwTriv79CD80j7cluOR0jx4ftJrQ1bY3dft3gSTUdayFfJi+E8zae5C1yryJ1lj11UjPhQnE1q k2g== X-Google-Smtp-Source: AGHT+IG0ruvu4O6Q+xWRk4gk+MJf6wUMShJAF1bd47RRItIx7Oed9kAvDdsxPUTAcjrzaYMmvRBfLQ== X-Received: by 2002:a05:6512:3f16:b0:518:c057:6ab1 with SMTP id y22-20020a0565123f1600b00518c0576ab1mr1816377lfa.66.1713956920919; Wed, 24 Apr 2024 04:08:40 -0700 (PDT) Received: from tunnel335574-pt.tunnel.tserv24.sto1.ipv6.he.net (tunnel335574-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:11::2]) by smtp.gmail.com with ESMTPSA id v24-20020ac258f8000000b00515cd2dce3csm2354369lfo.54.2024.04.24.04.08.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 04:08:40 -0700 (PDT) Date: Wed, 24 Apr 2024 14:08:39 +0300 (EEST) From: =?ISO-8859-15?Q?Martin_Storsj=F6?= To: FFmpeg development discussions and patches In-Reply-To: <20240422142547.281064-7-derek.buitenhuis@gmail.com> Message-ID: <11ad7ea9-a576-f51f-898e-21cb57334db0@martin.st> References: <20240422142547.281064-1-derek.buitenhuis@gmail.com> <20240422142547.281064-7-derek.buitenhuis@gmail.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v2 6/9] avformat/http: Add options to set the max number of connection retries X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Mon, 22 Apr 2024, Derek Buitenhuis wrote: > Not every use case benefits from setting retries in terms of the backoff. > > Signed-off-by: Derek Buitenhuis > --- > libavformat/http.c | 12 +++++++++--- > libavformat/version.h | 2 +- > 2 files changed, 10 insertions(+), 4 deletions(-) > > diff --git a/libavformat/http.c b/libavformat/http.c > index 6927fea2fb..06bd3e340e 100644 > --- a/libavformat/http.c > +++ b/libavformat/http.c > @@ -140,6 +140,7 @@ typedef struct HTTPContext { > uint64_t filesize_from_content_range; > int respect_retry_after; > unsigned int retry_after; > + int reconnect_max_retries; > } HTTPContext; > > #define OFFSET(x) offsetof(HTTPContext, x) > @@ -178,6 +179,7 @@ static const AVOption options[] = { > { "reconnect_on_http_error", "list of http status codes to reconnect on", OFFSET(reconnect_on_http_error), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D }, > { "reconnect_streamed", "auto reconnect streamed / non seekable streams", OFFSET(reconnect_streamed), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, D }, > { "reconnect_delay_max", "max reconnect delay in seconds after which to give up", OFFSET(reconnect_delay_max), AV_OPT_TYPE_INT, { .i64 = 120 }, 0, UINT_MAX/1000/1000, D }, > + { "reconnect_max_retries", "the max number of times to retry a connection", OFFSET(reconnect_max_retries), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, D }, > { "respect_retry_after", "respect the Retry-After header when retrying connections", OFFSET(respect_retry_after), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, D }, > { "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, D | E }, > { "resource", "The resource requested by a client", OFFSET(resource), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E }, > @@ -359,7 +361,7 @@ static int http_open_cnx(URLContext *h, AVDictionary **options) > { > HTTPAuthType cur_auth_type, cur_proxy_auth_type; > HTTPContext *s = h->priv_data; > - int ret, auth_attempts = 0, redirects = 0; > + int ret, conn_attempts = 1, auth_attempts = 0, redirects = 0; > int reconnect_delay = 0; > uint64_t off; > char *cached; > @@ -386,7 +388,8 @@ redo: > ret = http_open_cnx_internal(h, options); > if (ret < 0) { > if (!http_should_reconnect(s, ret) || > - reconnect_delay > s->reconnect_delay_max) > + reconnect_delay > s->reconnect_delay_max || > + (s->reconnect_max_retries >= 0 && conn_attempts > s->reconnect_max_retries)) > goto fail; > > if (s->respect_retry_after && s->retry_after > 0) { > @@ -401,6 +404,7 @@ redo: > if (ret != AVERROR(ETIMEDOUT)) > goto fail; > reconnect_delay = 1 + 2 * reconnect_delay; > + conn_attempts++; > > /* restore the offset (http_connect resets it) */ > s->off = off; > @@ -1706,6 +1710,7 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size) > int err, read_ret; > int64_t seek_ret; > int reconnect_delay = 0; > + int conn_attempt = 1; Minor inconsistency; the corresponding variable in the other function was called conn_attempts, as a plural. // Martin _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".