From e71a9b488fc17a7b659ef6c2ed347e3d18881dd4 Mon Sep 17 00:00:00 2001 From: bsergean Date: Mon, 10 Oct 2022 16:24:43 -0700 Subject: [PATCH] asyn-ares: set hint flags when calling ares_getaddrinfo The hint flag is ARES_AI_NUMERICSERV, and it will save a call to getservbyname or getservbyname_r to set it. Closes #9694 --- .mailmap | 3 ++- lib/asyn-ares.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index 639806ca67..5092131dd9 100644 --- a/.mailmap +++ b/.mailmap @@ -97,4 +97,5 @@ opensignature on github Cering on github a1346054 on github <36859588+a1346054@users.noreply.github.com> zhanghu on xiaomi -Philip Heiduck <47042125+pheiduck@users.noreply.github.com> \ No newline at end of file +Philip Heiduck <47042125+pheiduck@users.noreply.github.com> +bsergean on github diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index cbc0e2ea77..33edba1395 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -786,6 +786,10 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct Curl_easy *data, hints.ai_family = pf; hints.ai_socktype = (data->conn->transport == TRNSPRT_TCP)? SOCK_STREAM : SOCK_DGRAM; + /* Since the service is a numerical one, set the hint flags + * accordingly to save a call to getservbyname in inside C-Ares + */ + hints.ai_flags = ARES_AI_NUMERICSERV; msnprintf(service, sizeof(service), "%d", port); res->num_pending = 1; ares_getaddrinfo((ares_channel)data->state.async.resolver, hostname, -- 2.47.3