~ubuntu-branches/ubuntu/vivid/curl/vivid

« back to all changes in this revision

Viewing changes to lib/asyn-thread.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2013-05-07 12:16:37 UTC
  • mfrom: (3.4.37 sid)
  • Revision ID: package-import@ubuntu.com-20130507121637-9t3i98qgsyr9dw5d
Tags: 7.30.0-1ubuntu1
* Resynchronize on Debian. Remaining changes:
  - Drop dependencies not in main:
    + Build-Depends: Drop stunnel4 and libssh2-1-dev.
    + Drop libssh2-1-dev from binary package Depends.
  - Add new libcurl3-udeb package.
  - Add new curl-udeb package.
* Add warning to debian/patches/series.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
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
170
170
struct thread_data {
171
171
  curl_thread_t thread_hnd;
172
172
  unsigned int poll_interval;
173
 
  int interval_end;
 
173
  long interval_end;
174
174
  struct thread_sync_data tsd;
175
175
};
176
176
 
387
387
  return FALSE;
388
388
}
389
389
 
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)
395
 
{
396
 
  switch (ecode) {
397
 
  case EAI_AGAIN:
398
 
    return "The name could not be resolved at this time";
399
 
  case EAI_BADFLAGS:
400
 
    return "The flags parameter had an invalid value";
401
 
  case EAI_FAIL:
402
 
    return "A non-recoverable error occurred when attempting to "
403
 
      "resolve the name";
404
 
  case EAI_FAMILY:
405
 
    return "The address family was not recognized";
406
 
  case EAI_MEMORY:
407
 
    return "Out of memory";
408
 
  case EAI_NONAME:
409
 
    return "The name does not resolve for the supplied parameters";
410
 
  case EAI_SERVICE:
411
 
    return "The service passed was not recognized for the "
412
 
      "specified socket type"
413
 
  case EAI_SOCKTYPE:
414
 
    return "The intended socket type was not recognized"
415
 
  case EAI_SYSTEM:
416
 
    return "A system error occurred";
417
 
  case EAI_OVERFLOW:
418
 
    return "An argument buffer overflowed";
419
 
  default:
420
 
    return "Unknown error";
421
 
 
422
 
/* define this now as this is a private implementation of said function */
423
 
#define HAVE_GAI_STRERROR
424
 
}
425
 
#endif
426
 
 
427
 
 
428
390
/*
429
391
 * resolver_error() calls failf() with the appropriate message after a resolve
430
392
 * error
431
393
 */
432
394
 
433
 
static void resolver_error(struct connectdata *conn, const char *host_or_proxy)
 
395
static CURLcode resolver_error(struct connectdata *conn)
434
396
{
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
439
 
           thread-safe */
440
 
        gai_strerror(conn->async.status)
441
 
#else
442
 
        Curl_strerror(conn, conn->async.status)
443
 
#endif
444
 
    );
 
397
  const char *host_or_proxy;
 
398
  CURLcode rc;
 
399
  if(conn->bits.httpproxy) {
 
400
    host_or_proxy = "proxy";
 
401
    rc = CURLE_COULDNT_RESOLVE_PROXY;
 
402
  }
 
403
  else {
 
404
    host_or_proxy = "host";
 
405
    rc = CURLE_COULDNT_RESOLVE_HOST;
 
406
  }
 
407
 
 
408
  failf(conn->data, "Could not resolve %s: %s", host_or_proxy,
 
409
        conn->async.hostname);
 
410
  return rc;
445
411
}
446
412
 
447
413
/*
473
439
  if(entry)
474
440
    *entry = conn->async.dns;
475
441
 
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;
481
 
    }
482
 
    else {
483
 
      resolver_error(conn, "host");
484
 
      rc = CURLE_COULDNT_RESOLVE_HOST;
485
 
    }
486
 
  }
 
442
  if(!conn->async.dns)
 
443
    /* a name was not resolved, report error */
 
444
    rc = resolver_error(conn);
487
445
 
488
446
  destroy_async_data(&conn->async);
489
447
 
518
476
 
519
477
  if(done) {
520
478
    getaddrinfo_complete(conn);
 
479
 
 
480
    if(!conn->async.dns) {
 
481
      CURLcode rc = resolver_error(conn);
 
482
      destroy_async_data(&conn->async);
 
483
      return rc;
 
484
    }
521
485
    destroy_async_data(&conn->async);
522
 
 
523
 
    if(!conn->async.dns) {
524
 
      resolver_error(conn, "host");
525
 
      return CURLE_COULDNT_RESOLVE_HOST;
526
 
    }
527
486
    *entry = conn->async.dns;
528
487
  }
529
488
  else {
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);
532
491
    if(elapsed < 0)
533
492
      elapsed = 0;
534
493