cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: DNS Cache on Windows XP

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 22 Jul 2003 09:59:02 +0200 (CEST)

On Mon, 21 Jul 2003, Tracy Boehrer wrote:

> I single stepped through the code, and while I'm not sure of what it's doing
> yet, here is what I have so far:
>
> In Curl_resolv, line 259:
>
> /* See if its already in our dns cache */
> dns = Curl_hash_pick(data->hostcache, entry_id, entry_len+1);
>
> It returns what appears to be a valid cache entry. However, in that same
> function, after line 289:
>
> /* Remove outdated and unused entries from the hostcache */
> hostcache_prune(data->hostcache,
> data->set.dns_cache_timeout,
> now);
>
> 'dns' appear to have been deleted. 'dns' itself still points to something,
> but the contents (fields) are freed. What is (if anything) supposed to
> happen after that?

What you explain here should not be happening and indicates a bug somewhere.
Again, I trust you're using 7.10.5 here so you're not hunting for bugs in old
versions?

The Curl_hash_pick() function returns an entry from the DNS cache (if there's
a match available). The 'dns' pointer then points to a 'Curl_dns_entry' struct
that contains a 'addr' field which is a pointer to the name resolve info about
the name.

On line 284, the operation 'dns->inuse++' increases the 'inuse' field in the
dns struct, and with a non-zero value there the pruning that is made just
below it, will not remove that particular entry from the cache even if it
otherwise would. (hostcache_prune() calls Curl_hash_clean_with_criterium()
which runs the hostcache_timestamp_remove() function for each hash entry to
figure out if it should be removed or not.)

Even if you've selected to disable the cache completely, it will still contain
this single entry while the 'inuse' is non-zero as that indicates that it is
in fact still in use by libcurl code.

At least, that's the theory.

-- 
 Daniel Stenberg -- curl: been grokking URLs since 1998
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
Received on 2003-07-22