cURL / Mailing Lists / curl-library / Single Mail

curl-library

curl dns cache and dns changes on linux

From: Mathew Hounsell <mathew.hounsell_at_avegasystems.com>
Date: Wed, 09 Jul 2008 17:28:39 +1000

I encountered an error where my DHCP took a while to get a lease but my curl using program had already started. All subsequent
peforms failed with the DNS lookup failed error code.

I tracked it down and it turns out that glibc gethostbyname_r won't automatically reload it's configuration if that
configuration changes. You have to manually call res_init. See Below.

But it took me on a wild goose chase for days thinking it was my curl dns cache.

Please add a warning to the docs for CURLOPT_DNS_CACHE_TIMEOUT to tell developers they may be looking in the wrong spot and to
call res_init instead.

I may prepare a patch for the docs myself but not for the moment.

http://sources.redhat.com/bugzilla/show_bug.cgi?id=3675

libc caches resolv.conf forever
-------
That's what res_init() is for, call it.
Received on 2008-07-09