curl-library
Re: DNS cache time out problems
Date: Fri, 03 Nov 2006 17:26:46 +0100
Daniel Stenberg schrieb:
> On Fri, 3 Nov 2006, Frank Hempel wrote:
>
>> I'm facing the problem that from time to time I get a lot
>> CURLE_COULDNT_RESOLVE_HOST errors despite all easy handles which are
>> used are sharing the same shared handle which is setup for dns cache
>> sharing. I'm initializing the easy handle with the setopt argument
>> CURLOPT_DNS_CACHE_TIMEOUT = -1 in the hope that the once resolved
>> hostnames will survice the live of an easy handle. Nevertheless the
>> resolutions seem to get invalidated sometimes. I should mention that I
>> am querying three host(name)s only all the time.
>
> What libcurl version on what platform? Are you using c-ares? If so, what
> version?
Yes sorry, I forgot:
I'm using c-ares-1.2.1, curl-7-13-0 on a linux platform
>
> You are setting CURLOPT_DNS_CACHE_TIMEOUT in each easy handle, right?
yes.
>
>> I couldnt figure out an explicit interval after which the
>> CURLE_COULDNT_RESOLVE_HOST errors occur because if the dns servers are
>> responding well then I get no error of course. I just took notice of
>> it in the last time when the dns servers I use got a bit lame.
>>
>> Is there any hardwired timeout for the dns cache or did I
>> misunderstood the using of the sharing handle?
>
> It defaults to 60 seconds, but if you set it to -1 it should never prune
> entries from the cache. See curl/lib/hostip.c:Curl_hostcache_prune().
Curl_hostcache_prune() calls Curl_hash_clean_with_criterium() which for
each entry calls back to hostcache_timestamp_remove() to determine
whether to remove it or not. hostcache_timestamp_remove() will only
signal not to remove (by returning Zero) when the time since the
timestamp of the entry is less then the timeout (which should never be
true for a timeout of -1) or the flag 'inuse' is set.
So without digging deeper (or actually higher from this point on),
either Curl_hostcache_prune() is not called for timeouts of -1 or the
cache entries always have the inuse-flag set.
Am I right?
cu, frank
>
Received on 2006-11-03