From: Stefan Eissing Date: Tue, 21 Apr 2026 13:06:46 +0000 (+0200) Subject: async-ares: fix query counter handling X-Git-Url: http://git.ipfire.org/index.cgi?a=commitdiff_plain;ds=sidebyside;p=thirdparty%2Fcurl.git async-ares: fix query counter handling When starting an c-ares query, the provided callback may be invoked right away, leading to a decrement of `queries_ongoing`. Increment the counter *before* call c-ares. Otherwise, the `async->done` bit is not properly set. Closes #21399 --- diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index 187ffbbe54..31912da400 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -667,9 +667,9 @@ CURLcode Curl_async_getaddrinfo(struct Curl_easy *data, hints.ai_family = PF_INET6; hints.ai_socktype = socktype; hints.ai_flags = ARES_AI_NUMERICSERV; + async->queries_ongoing++; ares_getaddrinfo(ares->channel, async->hostname, service, &hints, async_ares_AAAA_cb, async); - async->queries_ongoing++; } #endif /* CURLRES_IPV6 */ @@ -681,9 +681,9 @@ CURLcode Curl_async_getaddrinfo(struct Curl_easy *data, hints.ai_family = PF_INET; hints.ai_socktype = socktype; hints.ai_flags = ARES_AI_NUMERICSERV; + async->queries_ongoing++; ares_getaddrinfo(ares->channel, async->hostname, service, &hints, async_ares_A_cb, async); - async->queries_ongoing++; } #ifdef USE_HTTPSRR diff --git a/lib/asyn-thrdd.c b/lib/asyn-thrdd.c index f19aab0c2d..900bd27d57 100644 --- a/lib/asyn-thrdd.c +++ b/lib/asyn-thrdd.c @@ -240,11 +240,11 @@ static CURLcode async_rr_start(struct Curl_easy *data, memset(&thrdd->rr.hinfo, 0, sizeof(thrdd->rr.hinfo)); thrdd->rr.hinfo.rrname = rrname; + async->queries_ongoing++; ares_query_dnsrec(thrdd->rr.channel, rrname ? rrname : async->hostname, ARES_CLASS_IN, ARES_REC_TYPE_HTTPS, async_thrdd_rr_done, async, NULL); - async->queries_ongoing++; CURL_TRC_DNS(data, "[HTTPS-RR] initiated request for %s", rrname ? rrname : async->hostname); return CURLE_OK;