1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-23 08:38:49 -05:00

transfer: cap retries of "dead connections" to 5

When libcurl retries a connection due to it being "seemingly dead" or by
REFUSED_STREAM, it will now only do it up five times before giving up,
to avoid never-ending loops.

Reported-by: Dima Tisnek
Bug: https://curl.haxx.se/mail/lib-2020-03/0044.html
Closes #5074
This commit is contained in:
Daniel Stenberg 2020-03-10 22:31:47 +01:00
parent 51fde33747
commit f38c7290b1
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 7 additions and 1 deletions

View File

@ -1779,6 +1779,12 @@ CURLcode Curl_retry_request(struct connectdata *conn,
retry = TRUE;
}
if(retry) {
#define CONN_MAX_RETRIES 5
if(conn->retrycount++ >= CONN_MAX_RETRIES) {
failf(data, "Connection died, tried %d times before giving up",
CONN_MAX_RETRIES);
return CURLE_SEND_ERROR;
}
infof(conn->data, "Connection died, retrying a fresh connect\n");
*url = strdup(conn->data->change.url);
if(!*url)

View File

@ -1099,7 +1099,7 @@ struct connectdata {
struct http_connect_state *connect_state; /* for HTTP CONNECT */
struct connectbundle *bundle; /* The bundle we are member of */
int negnpn; /* APLN or NPN TLS negotiated protocol, CURL_HTTP_VERSION* */
int retrycount; /* number of retries on a new connection */
#ifdef USE_UNIX_SOCKETS
char *unix_domain_socket;
BIT(abstract_unix_socket);