]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
transfer: reset retry count on each request
authorEmre Çalışkan <bilgi@emrecaliskan.com.tr>
Tue, 14 Oct 2025 18:35:54 +0000 (21:35 +0300)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 15 Oct 2025 08:39:31 +0000 (10:39 +0200)
Reported-by: plv1313 on github
Fixes #18926
Closes #19066

lib/easy.c
lib/transfer.c

index 877cf13b9baf7836277005668fd77b33371f992f..793a18f33eb88090ca72bcb56479d19ade337ce0 100644 (file)
@@ -1119,7 +1119,6 @@ void curl_easy_reset(CURL *d)
 
   data->progress.hide = TRUE;
   data->state.current_speed = -1; /* init to negative == impossible */
-  data->state.retrycount = 0;     /* reset the retry counter */
   data->state.recent_conn_id = -1; /* clear remembered connection id */
 
   /* zero out authentication data: */
index d20440fec744ca6281dc01f62a504b8e3cd0e905..d7014aab87e5951a4fdf4d2e552e8a1a4f8d8a4a 100644 (file)
@@ -481,6 +481,14 @@ CURLcode Curl_pretransfer(struct Curl_easy *data)
 {
   CURLcode result = CURLE_OK;
 
+  /* Reset the retry count at the start of each request.
+   * If the retry count is not reset, when the connection drops,
+   * it will not enter the retry mechanism on CONN_MAX_RETRIES + 1 attempts
+   * and will immediately throw
+   * "Connection died, tried CONN_MAX_RETRIES times before giving up".
+   * By resetting it here, we ensure each new request starts fresh. */
+  data->state.retrycount = 0;
+
   if(!data->set.str[STRING_SET_URL] && !data->set.uh) {
     /* we cannot do anything without URL */
     failf(data, "No URL set");