cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Turning off DNS Caching of Failed Connections

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Wed, 13 Oct 2010 13:36:45 -0700

On Wed, Oct 13, 2010 at 01:29:44PM -0400, Matt Marken wrote:
>    I am running into an issue where failed name resolutions are being cached by
> curl even though I have DNS_CACHE_TIMEOUT set to not cache results.
> (and have tried all other permutations and all options that looked even vaguely
> DNS related).

Which libcurl version? There were some bugs with DNS in older versions.

> For example, I can be running my application, pull the network cable, and have
> name resolution fail for one of my requests and all future requests for that
> host even when the cable is reconnected.  The behavior needed is, once the
> network cable is reconnected, future requests to the host that failed earlier
> should resolve.  Resolving via getaddrinfo outside of curl produces the desired
> behavior.  Calling res_init() before each curl request results in the desired
> behavior.  It seems like I am missing what is required to achieve this behavior
> directly in libcurl, however.   Is this sort of behavior possible via libcurl?

The fact that res_init() fixes the problem tells me the caching is happening
in your DNS resolver library, not in libcurl. Are you running nscd? If you
use a c-ares enabled libcurl, I'll bet the problem will go away.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-10-13