cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl dns cache and dns changes on linux

From: Mathew Hounsell <mathew.hounsell_at_avegasystems.com>
Date: Thu, 10 Jul 2008 10:10:29 +1000

> Oh. Yeah I bet that took a little while figuring out... so how do you deal
> with it in your application? Do you call res_init() when you get (weird)
> libcurl errors?

My solution is very specific. It works but it is not my ideal solution.

I have a function that checks the mtime of the /etc/resolv.conf against the last known mtime (0 for DNE). If the two mtime
differ then I call res_init. This function is periodically called to optionally reload the configuration.

Ideally the call to gethostbyname_r would have to have some sort of check to handle the failures. From the man:
> The variable h_errno can have the following values
> NO_RECOVERY
> A non-recoverable name server error occurred.
> TRY_AGAIN
> A temporary error occurred on an authoritative name server. Try again later.
I suspect that a test of h_errno would have one of these two values and if it did then a call to res_init may be needed; but I
don't know for sure.
Received on 2008-07-10