cURL / Mailing Lists / curl-library / Single Mail


DNS Cache issue

From: Inca R <>
Date: Sat, 8 Aug 2015 07:51:18 -0700

I'm using libcurl 7.31.0 and found an interested issue with DNS cache.

We use the CURLOPT_RESOLVE to set the list of HOST:PORT:IPv4 entries into
cUrl internal cache.
We start observing an issue when using Amazon ELB elastic feature.
The ELB will start add/remove IPs from its pool as necessary.

Our problem: cUrl DNS cache doesn't replace entries with same key but
different entry

-- Client 1 resolves to ipv4_1 and sets CURLOPT_RESOLVE

Client 1 continue to work, but ELB reduces its IP pool and remove from the
pool ipv4_1.

Client 1 performs a new DNS request for and gets a
differnt ip, ipv4_2

Client 1 sets CURLOPT_RESOLVE this time with:
But cURl ignores this call and keeps the old entry:

I would expect cUrl DNS cache to be updated with the new entry.

The code resides in lib/hostip.c
*CURLcode Curl_loadhostpairs(struct SessionHandle *data)*

*....* /* See if its already in our dns cache */

      dns = Curl_hash_pick(data->dns.hostcache, entry_id, entry_len+1);

      /* free the allocated entry_id again */


      if(!dns) {

        /* if not in the cache already, put this host in the cache */

        dns = Curl_cache_addr(data, addr, hostname, port);

        if(dns) {

          dns->timestamp = 0; /* mark as added by CURLOPT_RESOLVE */

          /* release the returned reference; the cache itself will keep the

           * entry alive: */





        /* this is a duplicate, free it again */



We tried to fix this issue by first removing the entry with
<>*, but unfortunately this is not implemented in
cUrl 7.31, there is a TODO comment in the code.

We can move to a newer version or patch our current version to support the
entry removal ( with the '-' prefix ), but I think the best solution will
be to update the code and try to update the cache when adding an existing
entry but with a different address.

Thoughts ?


List admin:
Received on 2015-08-08