Subject: Re: ares_gethostbyname()

Re: ares_gethostbyname()

From: Gisle Vanem <giva_at_bgnett.no>
Date: Mon, 24 Jul 2006 16:49:09 +0200

> It feels like a bad usage in libcurl so I think c-ares is fine and the fix
> should be done in libcurl. Don't you agree?

Yes. I'm not familar with all the details of CURLRES_*, but this patch
seems to work here:

diff -u -r1.53 hostip.h
--- hostip.h 21 Jul 2006 06:21:46 -0000 1.53
+++ hostip.h 24 Jul 2006 14:44:28 -0000
@@ -51,7 +51,7 @@
 #define CURLRES_IPV4
 #endif

-#ifdef CURLRES_IPV4
+#if defined(CURLRES_IPV4) || defined(USE_ARES)
 #if !defined(HAVE_GETHOSTBYNAME_R) || defined(CURLRES_ASYNCH)
 /* If built for ipv4 and missing gethostbyname_r(), or if using async name
    resolve, we need the Curl_addrinfo_copy() function (which itself needs the

diff -u -r1.34 hostip6.c
--- hostip6.c 21 Jul 2006 06:21:46 -0000 1.34
+++ hostip6.c 24 Jul 2006 14:44:28 -0000
@@ -98,7 +98,7 @@
   freeaddrinfo(p);
 }

-#ifdef CURLRES_ASYNCH
+#if defined(CURLRES_ASYNCH) && !defined(USE_ARES)
 /*
  * Curl_addrinfo_copy() is used by the asynch callback to copy a given
  * address. But this is an ipv6 build and then we don't copy the address, we

-----------------------

Hence Curl_addrinfo_copy() performs a deep copy.

But then something should be done not to call freeaddrinfo() for c-ares:
  freeaddrinfo() without getaddrinfo(): ADDR hostip6.c:98 freeaddrinfo(0xa43078)

--gv
Received on 2006-07-24