asyn-ares: reduce timeout to 2000ms

When UDP packets get lost this makes for slightly faster retries. This
lower timeout is used by @c-ares itself by default starting next
release.

Closes #11753
This commit is contained in:
Daniel Stenberg 2023-08-28 16:07:34 +02:00
parent 7378f9cc32
commit a181b4a053
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -110,7 +110,7 @@ struct thread_data {
};
/* How long we are willing to wait for additional parallel responses after
obtaining a "definitive" one.
obtaining a "definitive" one. For old c-ares without getaddrinfo.
This is intended to equal the c-ares default timeout. cURL always uses that
default value. Unfortunately, c-ares doesn't expose its default timeout in
@ -120,6 +120,8 @@ struct thread_data {
*/
#define HAPPY_EYEBALLS_DNS_TIMEOUT 5000
#define CARES_TIMEOUT_PER_ATTEMPT 2000
/*
* Curl_resolver_global_init() - the generic low-level asynchronous name
* resolve API. Called from curl_global_init() to initialize global resolver
@ -173,6 +175,9 @@ CURLcode Curl_resolver_init(struct Curl_easy *easy, void **resolver)
int optmask = ARES_OPT_SOCK_STATE_CB;
options.sock_state_cb = sock_state_cb;
options.sock_state_cb_data = easy;
options.timeout = CARES_TIMEOUT_PER_ATTEMPT;
optmask |= ARES_OPT_TIMEOUTMS;
status = ares_init_options((ares_channel*)resolver, &options, optmask);
if(status != ARES_SUCCESS) {
if(status == ARES_ENOMEM)