]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
transfer: cap retries of "dead connections" to 5
authorDaniel Stenberg <daniel@haxx.se>
Tue, 10 Mar 2020 21:31:47 +0000 (22:31 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 15 Mar 2020 10:43:47 +0000 (11:43 +0100)
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

lib/transfer.c
lib/urldata.h

index e76834eb3432fa102a21594d0fa4f0ff7f6a4a55..d02baa4c3535c5557b7b7b68f82521ba6e9b6f57 100644 (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)
index 4ee568fd61541bdfad59b4907475a0bd768330ab..374bf437125762884c2b3bdce7c5959fc0b8bf87 100644 (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);