mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 16:18:48 -05:00
hostip: don't prune DNS cache entries that are in use
When adding entries to the DNS cache with CURLOPT_RESOLVE, they are marked 'inuse' forever to prevent them from ever being removed in normal operations. Still, the code that pruned out-of-date DNS entries didn't care for the 'inuse' struct field and pruned it anyway! Reported-by: Romulo A. Ceccon Bug: http://curl.haxx.se/bug/view.cgi?id=1303
This commit is contained in:
parent
edce855943
commit
030a2b8cb8
13
lib/hostip.c
13
lib/hostip.c
@ -291,9 +291,10 @@ remove_entry_if_stale(struct SessionHandle *data, struct Curl_dns_entry *dns)
|
|||||||
{
|
{
|
||||||
struct hostcache_prune_data user;
|
struct hostcache_prune_data user;
|
||||||
|
|
||||||
if(!dns || (data->set.dns_cache_timeout == -1) || !data->dns.hostcache)
|
if(!dns || (data->set.dns_cache_timeout == -1) || !data->dns.hostcache ||
|
||||||
/* cache forever means never prune, and NULL hostcache means
|
dns->inuse)
|
||||||
we can't do it */
|
/* cache forever means never prune, and NULL hostcache means we can't do
|
||||||
|
it, if it still is in use then we leave it */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
time(&user.now);
|
time(&user.now);
|
||||||
@ -428,9 +429,13 @@ int Curl_resolv(struct connectdata *conn,
|
|||||||
/* free the allocated entry_id again */
|
/* free the allocated entry_id again */
|
||||||
free(entry_id);
|
free(entry_id);
|
||||||
|
|
||||||
|
infof(data, "Hostname was %sfound in DNS cache\n", dns?"":"NOT ");
|
||||||
|
|
||||||
/* See whether the returned entry is stale. Done before we release lock */
|
/* See whether the returned entry is stale. Done before we release lock */
|
||||||
if(remove_entry_if_stale(data, dns))
|
if(remove_entry_if_stale(data, dns)) {
|
||||||
|
infof(data, "Hostname in DNS cache was stale, zapped\n");
|
||||||
dns = NULL; /* the memory deallocation is being handled by the hash */
|
dns = NULL; /* the memory deallocation is being handled by the hash */
|
||||||
|
}
|
||||||
|
|
||||||
if(dns) {
|
if(dns) {
|
||||||
dns->inuse++; /* we use it! */
|
dns->inuse++; /* we use it! */
|
||||||
|
Loading…
Reference in New Issue
Block a user