← Commit list

b0db5f12b1

Daniel Stenberg
Daniel Stenberg
2025-10-09
SUCCESS Duration: 155s

Subject

hostip: don't store negative resolves due unrelated errors

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/hostip.c+12 -6
@@ -846,6 +846,7 @@ CURLcode Curl_resolv(struct Curl_easy *data,
int respwait = 0;
bool is_ipaddr;
size_t hostname_len;
+ bool keep_negative = TRUE; /* cache a negative result */
#ifndef CURL_DISABLE_DOH
data->conn->bits.doh = FALSE; /* default is not */
@@ -887,8 +888,10 @@ CURLcode Curl_resolv(struct Curl_easy *data,
st = data->set.resolver_start(resolver, NULL,
data->set.resolver_start_client);
Curl_set_in_callback(data, FALSE);
- if(st)
+ if(st) {
+ keep_negative = FALSE;
goto error;
+ }
}
/* shortcut literal IP addresses, if we are not told to resolve them. */
@@ -947,10 +950,11 @@ out:
else if(addr) {
/* we got a response, create a dns entry, add to cache, return */
dns = Curl_dnscache_mk_entry(data, addr, hostname, 0, port, FALSE);
- if(!dns)
- goto error;
- if(Curl_dnscache_add(data, dns))
+ if(!dns || Curl_dnscache_add(data, dns)) {
+ /* this is OOM or similar, don't store such negative resolves */
+ keep_negative = FALSE;
goto error;
+ }
show_resolve_info(data, dns);
*entry = dns;
return CURLE_OK;
@@ -966,7 +970,8 @@ error:
Curl_resolv_unlink(data, &dns);
*entry = NULL;
Curl_async_shutdown(data);
- store_negative_resolve(data, hostname, port);
+ if(keep_negative)
+ store_negative_resolve(data, hostname, port);
return CURLE_COULDNT_RESOLVE_HOST;
}
@@ -1550,7 +1555,8 @@ CURLcode Curl_resolv_check(struct Curl_easy *data,
result = Curl_async_is_resolved(data, dns);
if(*dns)
show_resolve_info(data, *dns);
- if(result)
+ if((result == CURLE_COULDNT_RESOLVE_HOST) ||
+ (result == CURLE_COULDNT_RESOLVE_PROXY))
store_negative_resolve(data, data->state.async.hostname,
data->state.async.port);
return result;