cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: curl_easy_init() when network is disabled

From: Joshua Kwan <jkwan_at_vmware.com>
Date: Mon, 27 Jul 2009 22:19:55 -0700

The attached patch fixes it for me, but not sure if it will break other things with the behavior that it changes.

-Josh

-----Original Message-----
From: curl-library-bounces_at_cool.haxx.se [mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Joshua Kwan
Sent: Monday, July 27, 2009 6:41 PM
To: libcurl development
Subject: RE: curl_easy_init() when network is disabled

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;
  else
    /* 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",
                     ares_strerror(status)));
  }
  if (status == ARES_SUCCESS) {
    status = init_by_defaults(channel);
    if (status != ARES_SUCCESS)
      DEBUGF(fprintf(stderr, "Error: init_by_defaults failed: %s\n",
                     ares_strerror(status)));
  }

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.

-Josh

Received on 2009-07-28