cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: error (6) : name lookup timed out

From: Phil Blundell <pb_at_reciva.com>
Date: Thu, 04 Dec 2008 19:46:40 +0000

On Thu, 2008-12-04 at 11:25 -0800, Dan Fandrich wrote:
> If the DNS servers change after the network reconnection, then that would
> explain why a gethostbyname() would fail. glibc (and probably others) require
> that res_init() be called to reread /etc/resolv.conf and start using the
> new nameservers in that case. An app should probably do that and retry a
> download after it gets a CURLE_COULDNT_RESOLVE_HOST error.

On a vaguely-related subject, one of my colleagues mentioned to me today
that he was experiencing some badness caused by the multi connection
cache keeping easy handles open across network reconfigurations.

What seemed to be happening to him was that he would open a connection
to some remote server, do stuff with it, then at some later point his
DHCP lease would change to a different IP. This of course makes all the
cached connections unusable, but curl doesn't realise this and goes on
trying to send new requests down them for a while before eventually the
sockets time out.

I guess some mechanism should ideally be provided for the application to
tell libcurl that the network environment has changed and it should
flush all its caches. This might include re-calling res_init() in the
case where curl is using gethostbyname() to do name lookups, and it
would presumably involve throwing away all the cached connections. The
latter thing is actually quite similar to that
"curl_multi_reap_idle_connections" patch that I wrote a few months back;
maybe I should dust that off again and try to fix up the missing bits to
make it suitable for merging.

p.
Received on 2008-12-04