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 05:47:57 -0700

I'm sorry... yes it is 7.10.5. What I find curious is that I only see this after a timeout. No timeout -- no problem.
 
What triggered me to induce a timeout is that in production, we've been seeing a problem related to either libcurl or our cache code. We just started looking into it, but the first case happened immediately after a timeout, where the next couple requests where gorped. It could just be coincidence.
 
I'll single step back through, and double check the dns->inuse value. I haven't looked closely at the code that determines if a dns cache entry is stale, but could it be that after a timeout (say 30 seconds), the algorithm can easily see that it's stale, but in the normal case, we're talking about time less than a second? Though the 'inuse' counter should prevent it's removal?

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