Message ID | AED01BE40B4CAD41A590B456FC8C4B8E010BA5AB1E@EXMBX-SZMail009.tencent.com |
---|---|
State | New |
Headers | show |
> 在 2019年3月1日,下午5:39,lmzeng(曾令明) <lmzeng@tencent.com> 写道: > > diff --git a/libavformat/http.c b/libavformat/http.c > old mode 100644 > new mode 100755 > index ed0eb1c..400df94 > --- a/libavformat/http.c > +++ b/libavformat/http.c > @@ -253,6 +253,7 @@ static int http_open_cnx(URLContext *h, AVDictionary **options) > HTTPAuthType cur_auth_type, cur_proxy_auth_type; > HTTPContext *s = h->priv_data; > int location_changed, attempts = 0, redirects = 0; > + int retry = 0; > redo: > av_dict_copy(options, s->chained_options, 0); > > @@ -260,9 +261,21 @@ redo: > cur_proxy_auth_type = s->auth_state.auth_type; > > location_changed = http_open_cnx_internal(h, options); > - if (location_changed < 0) > + if (location_changed < 0) { > + if (s->reconnect && retry++ < 3 && why don’t use option looks like ‘retry_times' instead the 3? > + ((location_changed == AVERROR(ECONNRESET)) || (location_changed == AVERROR(EPIPE)) || > + (location_changed == AVERROR(ENETRESET)) || (location_changed == AVERROR(ECONNREFUSED)) || > + (location_changed == AVERROR(ETIMEDOUT)))) { > + if (ff_network_sleep_interruptible(1000U*1000, &h->interrupt_callback) != AVERROR(ETIMEDOUT)) { > + goto fail; > + } > + if (s->hd) { > + ffurl_closep(&s->hd); > + } > + goto redo; > + } > goto fail; > - > + } > attempts++; > if (s->http_code == 401) { > if ((cur_auth_type == HTTP_AUTH_NONE || s->auth_state.stale) && > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
On Fri, Mar 01, 2019 at 09:39:14AM +0000, lmzeng(曾令明) wrote: > diff --git a/libavformat/http.c b/libavformat/http.c > old mode 100644 > new mode 100755 > index ed0eb1c..400df94 > --- a/libavformat/http.c > +++ b/libavformat/http.c > @@ -253,6 +253,7 @@ static int http_open_cnx(URLContext *h, AVDictionary **options) > HTTPAuthType cur_auth_type, cur_proxy_auth_type; > HTTPContext *s = h->priv_data; > int location_changed, attempts = 0, redirects = 0; > + int retry = 0; > redo: > av_dict_copy(options, s->chained_options, 0); > > @@ -260,9 +261,21 @@ redo: > cur_proxy_auth_type = s->auth_state.auth_type; It seems git does not like this patch Applying: avformat/http: reconnect when connect reset by peer error: corrupt patch at line 14 error: could not build fake ancestor Patch failed at 0001 avformat/http: reconnect when connect reset by peer hint: Use 'git am --show-current-patch' to see the failed patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". [...]
diff --git a/libavformat/http.c b/libavformat/http.c old mode 100644 new mode 100755 index ed0eb1c..400df94 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -253,6 +253,7 @@ static int http_open_cnx(URLContext *h, AVDictionary **options) HTTPAuthType cur_auth_type, cur_proxy_auth_type; HTTPContext *s = h->priv_data; int location_changed, attempts = 0, redirects = 0; + int retry = 0; redo: av_dict_copy(options, s->chained_options, 0); @@ -260,9 +261,21 @@ redo: cur_proxy_auth_type = s->auth_state.auth_type; location_changed = http_open_cnx_internal(h, options); - if (location_changed < 0) + if (location_changed < 0) { + if (s->reconnect && retry++ < 3 && + ((location_changed == AVERROR(ECONNRESET)) || (location_changed == AVERROR(EPIPE)) || + (location_changed == AVERROR(ENETRESET)) || (location_changed == AVERROR(ECONNREFUSED)) || + (location_changed == AVERROR(ETIMEDOUT)))) { + if (ff_network_sleep_interruptible(1000U*1000, &h->interrupt_callback) != AVERROR(ETIMEDOUT)) { + goto fail; + } + if (s->hd) { + ffurl_closep(&s->hd); + } + goto redo; + } goto fail; - + } attempts++; if (s->http_code == 401) { if ((cur_auth_type == HTTP_AUTH_NONE || s->auth_state.stale) &&