cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: DNS Cache on Windows XP

From: Tracy Boehrer <tboehrer_at_calltower.com>
Date: Tue, 22 Jul 2003 06:34:09 -0700

There are actually three requests happening in my test.
 
1) The first request creates a connection and a dns entry (with a ultimate count of 1). This first transfer works OK, and when it's done calls Curl_done, which calls Curl_resolv_unlock, which decrements the inuse counter to 0.
 
2) The second connection reuses the previous connection, but times out. In addition to marking that connection as closed (conn->bits.close = TRUE), it also calls Curl_done, which decrements the inuse counter (now -1).
 
3) The third request creates a new connection, and gets the dns cache entry (which has a count of -1), but increments it to 0.
 
-----Original Message-----
From: Daniel Stenberg [mailto:daniel_at_haxx.se]
Sent: Tue 7/22/2003 2:59 AM
To: libcurl Mailing list
Cc:
Subject: RE: DNS Cache on Windows XP



        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
        
        

-------------------------------------------------------
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