5
5
* | (__| |_| | _ <| |___
6
6
* \___|\___/|_| \_\_____|
8
* Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
8
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
10
10
* This software is licensed as described in the file COPYING, which
11
11
* you should have received as part of this distribution. The terms
390
#if defined(HAVE_GETADDRINFO) && !defined(HAVE_GAI_STRERROR) && !defined(WIN32)
391
/* NetWare has getaddrinfo but lacks gai_strerror.
392
Windows has a gai_strerror but it is bad (not thread-safe) and the generic
393
socket error string function can be used for this pupose. */
394
static const char *gai_strerror(int ecode)
398
return "The name could not be resolved at this time";
400
return "The flags parameter had an invalid value";
402
return "A non-recoverable error occurred when attempting to "
405
return "The address family was not recognized";
407
return "Out of memory";
409
return "The name does not resolve for the supplied parameters";
411
return "The service passed was not recognized for the "
412
"specified socket type"
414
return "The intended socket type was not recognized"
416
return "A system error occurred";
418
return "An argument buffer overflowed";
420
return "Unknown error";
422
/* define this now as this is a private implementation of said function */
423
#define HAVE_GAI_STRERROR
429
391
* resolver_error() calls failf() with the appropriate message after a resolve
433
static void resolver_error(struct connectdata *conn, const char *host_or_proxy)
395
static CURLcode resolver_error(struct connectdata *conn)
435
failf(conn->data, "Could not resolve %s: %s; %s", host_or_proxy,
436
conn->async.hostname,
437
#ifdef HAVE_GAI_STRERROR
438
/* NetWare doesn't have gai_strerror and on Windows it isn't deemed
440
gai_strerror(conn->async.status)
442
Curl_strerror(conn, conn->async.status)
397
const char *host_or_proxy;
399
if(conn->bits.httpproxy) {
400
host_or_proxy = "proxy";
401
rc = CURLE_COULDNT_RESOLVE_PROXY;
404
host_or_proxy = "host";
405
rc = CURLE_COULDNT_RESOLVE_HOST;
408
failf(conn->data, "Could not resolve %s: %s", host_or_proxy,
409
conn->async.hostname);
474
440
*entry = conn->async.dns;
476
if(!conn->async.dns) {
477
/* a name was not resolved */
478
if(conn->bits.httpproxy) {
479
resolver_error(conn, "proxy");
480
rc = CURLE_COULDNT_RESOLVE_PROXY;
483
resolver_error(conn, "host");
484
rc = CURLE_COULDNT_RESOLVE_HOST;
443
/* a name was not resolved, report error */
444
rc = resolver_error(conn);
488
446
destroy_async_data(&conn->async);
520
478
getaddrinfo_complete(conn);
480
if(!conn->async.dns) {
481
CURLcode rc = resolver_error(conn);
482
destroy_async_data(&conn->async);
521
485
destroy_async_data(&conn->async);
523
if(!conn->async.dns) {
524
resolver_error(conn, "host");
525
return CURLE_COULDNT_RESOLVE_HOST;
527
486
*entry = conn->async.dns;
530
489
/* poll for name lookup done with exponential backoff up to 250ms */
531
int elapsed = Curl_tvdiff(Curl_tvnow(), data->progress.t_startsingle);
490
long elapsed = Curl_tvdiff(Curl_tvnow(), data->progress.t_startsingle);