]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
urldata: remove 'hostname' from struct Curl_async
authorDaniel Stenberg <daniel@haxx.se>
Mon, 24 Feb 2025 12:58:38 +0000 (13:58 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 27 Feb 2025 16:18:43 +0000 (17:18 +0100)
It is unnecessary duplicated information, as the host name being
resolved is already present in conn->host.

Closes #16451

lib/asyn-ares.c
lib/asyn-thread.c
lib/doh.c
lib/hostasyn.c
lib/hostip.c
lib/urldata.h

index 2aa597f2ba2b03102d678d76e5b198a75306b9d9..3a813fc983f55556d2182429a87868d376ca1de5 100644 (file)
@@ -592,7 +592,7 @@ static void query_completed_cb(void *arg,  /* (struct connectdata *) */
   res->num_pending--;
 
   if(CURL_ASYNC_SUCCESS == status) {
-    struct Curl_addrinfo *ai = Curl_he2ai(hostent, data->state.async.port);
+    struct Curl_addrinfo *ai = Curl_he2ai(hostent, data->conn->localport);
     if(ai) {
       compound_results(res, ai);
     }
@@ -774,8 +774,6 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct Curl_easy *data,
   if(!res->hostname)
     return NULL;
 
-  data->state.async.hostname = res->hostname;
-  data->state.async.port = port;
   data->state.async.done = FALSE;   /* not done */
   data->state.async.dns = NULL;     /* clear */
 
@@ -811,6 +809,7 @@ struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct Curl_easy *data,
                      service, &hints, addrinfo_cb, data);
   }
 #else
+  (void)port;
 
 #ifdef HAVE_CARES_IPV6
   if((data->conn->ip_version != CURL_IPRESOLVE_V4) && Curl_ipv6works(data)) {
index 5982983082646478e5403ac390ea81d37826a06d..7c14d80dad3c94e68fc59fb10eb2465a0d849b9e 100644 (file)
@@ -400,7 +400,7 @@ static void destroy_async_data(struct Curl_easy *data)
 
     td->init = FALSE;
   }
-  Curl_safefree(async->hostname);
+
 }
 
 #ifdef USE_HTTPSRR_ARES
@@ -414,7 +414,7 @@ static CURLcode resolve_httpsrr(struct Curl_easy *data,
   memset(&async->thdata.hinfo, 0, sizeof(struct Curl_https_rrinfo));
   async->thdata.hinfo.port = -1;
   ares_query_dnsrec(async->thdata.channel,
-                    async->hostname, ARES_CLASS_IN,
+                    data->conn->host.name, ARES_CLASS_IN,
                     ARES_REC_TYPE_HTTPS,
                     Curl_dnsrec_done_cb, data, NULL);
 
@@ -436,7 +436,6 @@ static bool init_resolve_thread(struct Curl_easy *data,
   int err = ENOMEM;
   struct Curl_async *async = &data->state.async;
 
-  async->port = port;
   async->done = FALSE;
   async->dns = NULL;
   td->thread_hnd = curl_thread_t_null;
@@ -447,11 +446,6 @@ static bool init_resolve_thread(struct Curl_easy *data,
     goto errno_exit;
   }
 
-  free(async->hostname);
-  async->hostname = strdup(hostname);
-  if(!async->hostname)
-    goto err_exit;
-
   /* The thread will set this TRUE when complete. */
   td->tsd.done = FALSE;
 
index f1d2bbe47eb6004500fbc1dda24a6374b771b88b..26d34b9ffea34b4fc49b9b195a72fc4df711535e 100644 (file)
--- a/lib/doh.c
+++ b/lib/doh.c
@@ -1181,7 +1181,7 @@ CURLcode Curl_doh_is_resolved(struct Curl_easy *data,
 
   if(dohp->probe[DOH_SLOT_IPV4].easy_mid < 0 &&
      dohp->probe[DOH_SLOT_IPV6].easy_mid < 0) {
-    failf(data, "Could not DoH-resolve: %s", data->state.async.hostname);
+    failf(data, "Could not DoH-resolve: %s", dohp->host);
     return CONN_IS_PROXIED(data->conn) ? CURLE_COULDNT_RESOLVE_PROXY :
       CURLE_COULDNT_RESOLVE_HOST;
   }
index effdf8e9e250ad2f8e8c431c90cbaf46860f3e39..8a5a674dfbfcf71f0c9e97eeb884ca95cf51e053 100644 (file)
@@ -76,8 +76,8 @@ CURLcode Curl_addrinfo_callback(struct Curl_easy *data,
         Curl_share_lock(data, CURL_LOCK_DATA_DNS, CURL_LOCK_ACCESS_SINGLE);
 
       dns = Curl_cache_addr(data, ai,
-                            data->state.async.hostname, 0,
-                            data->state.async.port, FALSE);
+                            data->conn->host.dispname, 0,
+                            data->conn->localport, FALSE);
       if(data->share)
         Curl_share_unlock(data, CURL_LOCK_DATA_DNS);
 
index 0eefba628c8b30a028be627fab6fca46a315d284..60697552f46408c4464f5ce969dacd49224b89d4 100644 (file)
@@ -1480,7 +1480,7 @@ CURLcode Curl_resolver_error(struct Curl_easy *data)
   }
 
   failf(data, "Could not resolve %s: %s", host_or_proxy,
-        data->state.async.hostname);
+        data->conn->host.dispname);
 
   return result;
 }
index 69f0628cceeb9afc87972f5b8bf44b8c8590bdea..0f6278e201979504eb3d3a4a4fd5cd408b7b1999 100644 (file)
@@ -565,14 +565,12 @@ struct hostname {
 #if defined(CURLRES_ASYNCH) || !defined(CURL_DISABLE_DOH)
 #define USE_CURL_ASYNC
 struct Curl_async {
-  char *hostname;
   struct Curl_dns_entry *dns;
 #ifdef CURLRES_ASYNCH
   struct thread_data thdata;
 #endif
   void *resolver; /* resolver state, if it is used in the URL state -
                      ares_channel e.g. */
-  int port;
   BIT(done);  /* set TRUE when the lookup is complete */
 };