summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-03-10 22:31:47 +0100
committerDaniel Stenberg <daniel@haxx.se>2020-03-12 09:32:38 +0100
commit0fa70ba2fac03aa74dedeb5a09b57dda44228d8c (patch)
tree4092beb5f71548bcf125d7bfdbcaed4af806f25a
parentd5c01d779fc46fb25d68aa4cfadb0ef0905e2200 (diff)
downloadcurl-bagder/retrycount.tar.gz
transfer: cap retries of "dead connections" to 5bagder/retrycount
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
-rw-r--r--lib/transfer.c6
-rw-r--r--lib/urldata.h2
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/transfer.c b/lib/transfer.c
index e76834eb3..d02baa4c3 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -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)
diff --git a/lib/urldata.h b/lib/urldata.h
index fbb8b645e..a0e71baca 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -1098,7 +1098,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);