cURL / Mailing Lists / curl-library / Single Mail


RE: curl_easy_init() when network is disabled

From: Joshua Kwan <>
Date: Mon, 27 Jul 2009 18:40:41 -0700

Hi Daniel,

More progress. I compiled with CURLDEBUG enabled and got this:

Error: init_by_resolv_conf failed: Error reading file
Error: ares_init failed
Error: Curl_open failed

Looking casually through the source tree, this is probably what's going on:

  if (status == ARES_SUCCESS)
    status = ARES_EOF;
    /* Catch the case when all the above checks fail (which happens when there
       is no network card or the cable is unplugged) */
    status = ARES_EFILE;

In this case, we bubble back up to ares_init_options:

  if (status == ARES_SUCCESS) {
    status = init_by_resolv_conf(channel);
    if (status != ARES_SUCCESS)
      DEBUGF(fprintf(stderr, "Error: init_by_resolv_conf failed: %s\n",
  if (status == ARES_SUCCESS) {
    status = init_by_defaults(channel);
    if (status != ARES_SUCCESS)
      DEBUGF(fprintf(stderr, "Error: init_by_defaults failed: %s\n",

In this case, shouldn't init_by_defaults be called unconditionally to seed the resolver with sane defaults (that won't be used anyway?)

I'll patch it locally and let you know how it goes.

Received on 2009-07-28