curl-library
DNS Cache issue
Date: Sat, 8 Aug 2015 07:51:18 -0700
Hi;
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
example:
-- Client 1 resolves host1.server.com to ipv4_1 and sets CURLOPT_RESOLVE
with:
host1.server.com:80:ipv4_1
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 host1.server.com and gets a
differnt ip, ipv4_2
Client 1 sets CURLOPT_RESOLVE this time with: host1.server.com:80:ipv4_2
But cURl ignores this call and keeps the old entry:
*host1.server.com:80:ipv4_1*
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 */
free(entry_id);
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: */
dns->inuse--;
}
}
else
/* this is a duplicate, free it again */
Curl_freeaddrinfo(addr);
....
We tried to fix this issue by first removing the entry with
*-host1.server.com:80
<http://host1.server.com:80>*, 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 ?
Thanks
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-08-08