cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: pycurl initialization while offline fails

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 26 Jun 2006 23:55:00 +0200 (CEST)

On Mon, 26 Jun 2006, ghazel_at_gmail.com wrote:

> I'm certainly willing to spend a little time digging in to fixing it, can
> you point me in the right direction?

Certainly! (Cc'ing the libcurl and c-ares lists as well, so you for you guys:
I'm replying to an original mail posted on the curl-and-python list.)

The problem is (on Windows) that c-ares returns a failure to init when there's
no DNS server found. Since c-ares is a DNS resolver it could be seen like a
proper return code since it can't DNS resolve without a DNS server. It could
however still resolve hosts using the hosts file so this error is probably
subject to get fixed...

libcurl takes that init failure (Curl_open() in lib/url.c) as a fatal error
and returns an error code from the the curl_easy_init() function and no more
fun is to be had...

I believe a better way to deal with the c-ares failure is to keep information
about this lack of currently working c-ares and retry the init on all
subsequent requests to actually resolve host names and if it fails again at
that point, simply act as with other resolve failures. It should still work
fine with numerical addresses (and hosts-based names once c-ares is fixed to
do that).

I hope this sheds some light to the problems involved.

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2006-06-26