~ubuntu-branches/ubuntu/saucy/curl/saucy-201307251546

« back to all changes in this revision

Viewing changes to lib/url.c

  • Committer: Bazaar Package Importer
  • Author(s): Ramakrishnan Muthukrishnan
  • Date: 2010-10-18 11:13:17 UTC
  • mto: (3.6.1 experimental) (1.3.1)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20101018111317-9rkas34ecwtq0upn
Tags: upstream-7.21.2
ImportĀ upstreamĀ versionĀ 7.21.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
#include "socks.h"
139
139
#include "rtsp.h"
140
140
#include "curl_rtmp.h"
 
141
#include "gopher.h"
141
142
 
142
143
#define _MPRINTF_REPLACE /* use our functions only */
143
144
#include <curl/mprintf.h>
227
228
  &Curl_handler_rtsp,
228
229
#endif
229
230
 
 
231
#ifndef CURL_DISABLE_GOPHER
 
232
  &Curl_handler_gopher,
 
233
#endif
 
234
 
230
235
#ifdef USE_LIBRTMP
231
236
  &Curl_handler_rtmp,
232
237
  &Curl_handler_rtmpt,
476
481
  }
477
482
#endif
478
483
 
 
484
  Curl_expire(data, 0); /* shut off timers */
 
485
 
479
486
  if(m)
480
487
    /* This handle is still part of a multi handle, take care of this first
481
488
       and detach this handle from there. */
482
 
    Curl_multi_rmeasy(data->multi, data);
 
489
    curl_multi_remove_handle(data->multi, data);
 
490
 
 
491
  /* Destroy the timeout list that is held in the easy handle. It is
 
492
     /normally/ done by curl_multi_remove_handle() but this is "just in
 
493
     case" */
 
494
  if(data->state.timeoutlist) {
 
495
    Curl_llist_destroy(data->state.timeoutlist, NULL);
 
496
    data->state.timeoutlist = NULL;
 
497
  }
483
498
 
484
499
  data->magic = 0; /* force a clear AFTER the possibly enforced removal from
485
500
                      the multi handle, since that function uses the magic
2566
2581
                  NULL, Curl_scan_cache_used);
2567
2582
#endif
2568
2583
 
2569
 
  Curl_expire(data, 0); /* shut off timers */
2570
2584
  Curl_hostcache_prune(data); /* kill old DNS cache entries */
2571
2585
 
2572
2586
  {
2685
2699
  }
2686
2700
  else if (sval & CURL_CSELECT_IN) {
2687
2701
    /* readable with no error. could be closed or could be alive */
2688
 
    long connectinfo = 0;
2689
 
    Curl_getconnectinfo(check->data, &connectinfo, &check);
2690
 
    if(connectinfo != -1) {
 
2702
    curl_socket_t connectinfo =
 
2703
      Curl_getconnectinfo(check->data, &check);
 
2704
    if(connectinfo != CURL_SOCKET_BAD)
2691
2705
      ret_val = FALSE;
2692
 
    }
2693
2706
  }
2694
2707
 
2695
2708
  return ret_val;
4307
4320
      *portptr = '\0'; /* cut off the name there */
4308
4321
      conn->remote_port = curlx_ultous(port);
4309
4322
    }
 
4323
    else if(!port)
 
4324
      /* Browser behavior adaptation. If there's a colon with no digits after,
 
4325
         just cut off the name there which makes us ignore the colon and just
 
4326
         use the default port. Firefox and Chrome both do that. */
 
4327
      *portptr = '\0';
4310
4328
  }
4311
4329
  return CURLE_OK;
4312
4330
}
4387
4405
                               bool *async)
4388
4406
{
4389
4407
  CURLcode result=CURLE_OK;
4390
 
  long shortest = 0; /* default to no timeout */
4391
 
 
4392
 
  /*************************************************************
4393
 
   * Set timeout if that is being used
4394
 
   *************************************************************/
4395
 
  if(data->set.timeout || data->set.connecttimeout) {
4396
 
 
4397
 
    /* We set the timeout on the name resolving phase first, separately from
4398
 
     * the download/upload part to allow a maximum time on everything. This is
4399
 
     * a signal-based timeout, why it won't work and shouldn't be used in
4400
 
     * multi-threaded environments. */
4401
 
 
4402
 
    shortest = data->set.timeout; /* default to this timeout value */
4403
 
    if(shortest && data->set.connecttimeout &&
4404
 
       (data->set.connecttimeout < shortest))
4405
 
      /* if both are set, pick the shortest */
4406
 
      shortest = data->set.connecttimeout;
4407
 
    else if(!shortest)
4408
 
      /* if timeout is not set, use the connect timeout */
4409
 
      shortest = data->set.connecttimeout;
4410
 
  /* We can expect the conn->created time to be "now", as that was just
4411
 
     recently set in the beginning of this function and nothing slow
4412
 
     has been done since then until now. */
4413
 
  }
 
4408
  long timeout_ms = Curl_timeleft(conn, NULL, TRUE);
4414
4409
 
4415
4410
  /*************************************************************
4416
4411
   * Resolve the name of the server or proxy
4437
4432
 
4438
4433
      /* Resolve target host right on */
4439
4434
      rc = Curl_resolv_timeout(conn, conn->host.name, (int)conn->port,
4440
 
                               &hostaddr, shortest);
 
4435
                               &hostaddr, timeout_ms);
4441
4436
      if(rc == CURLRESOLV_PENDING)
4442
4437
        *async = TRUE;
4443
4438
 
4458
4453
 
4459
4454
      /* resolve proxy */
4460
4455
      rc = Curl_resolv_timeout(conn, conn->proxy.name, (int)conn->port,
4461
 
                               &hostaddr, shortest);
 
4456
                               &hostaddr, timeout_ms);
4462
4457
 
4463
4458
      if(rc == CURLRESOLV_PENDING)
4464
4459
        *async = TRUE;
5137
5132
  conn = *connp;
5138
5133
  data = conn->data;
5139
5134
 
5140
 
  Curl_expire(data, 0); /* stop timer */
5141
 
 
5142
5135
  if(conn->bits.done)
5143
5136
    /* Stop if Curl_done() has already been called */
5144
5137
    return CURLE_OK;
5292
5285
static void do_complete(struct connectdata *conn)
5293
5286
{
5294
5287
  conn->data->req.chunk=FALSE;
5295
 
  conn->data->req.trailerhdrpresent=FALSE;
5296
 
 
5297
5288
  conn->data->req.maxfd = (conn->sockfd>conn->writesockfd?
5298
 
                               conn->sockfd:conn->writesockfd)+1;
 
5289
                           conn->sockfd:conn->writesockfd)+1;
5299
5290
}
5300
5291
 
5301
5292
CURLcode Curl_do(struct connectdata **connp, bool *done)