]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
hostip: only store negative response for CURLE_COULDNT_RESOLVE_HOST
authorDaniel Stenberg <daniel@haxx.se>
Tue, 25 Nov 2025 22:03:33 +0000 (23:03 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 25 Nov 2025 22:36:31 +0000 (23:36 +0100)
Follow-up from ce06fe77710525

This allows us to drop the 'keep_negative' variable completely.

Closes #19701

lib/hostip.c

index 4c1bb9236776f5a5c9fe3941f0e71548dd33d54e..58a7712cf485a0f97c9c1edc3de5d92dc8a623fe 100644 (file)
@@ -806,7 +806,6 @@ CURLcode Curl_resolv(struct Curl_easy *data,
   struct Curl_addrinfo *addr = NULL;
   bool respwait = FALSE;
   size_t hostname_len;
-  bool keep_negative = TRUE; /* cache a negative result */
   CURLcode result = CURLE_COULDNT_RESOLVE_HOST;
 
   *entry = NULL;
@@ -858,7 +857,6 @@ CURLcode Curl_resolv(struct Curl_easy *data,
                                   data->set.resolver_start_client);
     Curl_set_in_callback(data, FALSE);
     if(st) {
-      keep_negative = FALSE;
       result = CURLE_ABORTED_BY_CALLBACK;
       goto error;
     }
@@ -928,7 +926,6 @@ out:
       if(dns)
         /* avoid a dangling pointer to addr in the dying dns entry */
         dns->addr = NULL;
-      keep_negative = FALSE;
       result = CURLE_OUT_OF_MEMORY;
       goto error;
     }
@@ -947,7 +944,7 @@ error:
   if(dns)
     Curl_resolv_unlink(data, &dns);
   Curl_async_shutdown(data);
-  if(keep_negative)
+  if(result == CURLE_COULDNT_RESOLVE_HOST)
     store_negative_resolve(data, hostname, port);
   DEBUGASSERT(result);
   return result;