c-ares: really lazy init channel

Only initialize the c-ares channel when we start resolving and not
alreads when the application sets `CURLOPT_DNS_SERVERS` and friends.

Creating an ares channel takes considerable time and when we have the
DNS information for a transfer already cached, we do not need it.

Closes #17167
This commit is contained in:
Stefan Eissing 2025-04-24 12:18:33 +02:00 committed by Daniel Stenberg
parent 437c72fbba
commit 7bf576064c
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 86 additions and 115 deletions

View file

@ -1050,28 +1050,6 @@ CURL *curl_easy_duphandle(CURL *d)
}
#endif
#ifdef CURLRES_ARES
{
CURLcode rc;
rc = Curl_set_dns_servers(outcurl, data->set.str[STRING_DNS_SERVERS]);
if(rc && rc != CURLE_NOT_BUILT_IN)
goto fail;
rc = Curl_set_dns_interface(outcurl, data->set.str[STRING_DNS_INTERFACE]);
if(rc && rc != CURLE_NOT_BUILT_IN)
goto fail;
rc = Curl_set_dns_local_ip4(outcurl, data->set.str[STRING_DNS_LOCAL_IP4]);
if(rc && rc != CURLE_NOT_BUILT_IN)
goto fail;
rc = Curl_set_dns_local_ip6(outcurl, data->set.str[STRING_DNS_LOCAL_IP6]);
if(rc && rc != CURLE_NOT_BUILT_IN)
goto fail;
}
#endif /* USE_ARES */
outcurl->magic = CURLEASY_MAGIC_NUMBER;
/* we reach this point and thus we are OK */