~ubuntu-branches/ubuntu/hardy/curl/hardy-updates

« back to all changes in this revision

Viewing changes to lib/transfer.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-10-30 10:56:48 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20061030105648-uo8q8w9xklb40b4k
Tags: 7.15.5-1ubuntu1
* Merge from debian unstable. Remaining Ubuntu changes:
  - debian/control: Drop libdb4.2 build dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: transfer.c,v 1.299 2006-06-09 07:08:34 bagder Exp $
 
21
 * $Id: transfer.c,v 1.303 2006-07-31 17:46:28 yangtse Exp $
22
22
 ***************************************************************************/
23
23
 
24
24
#include "setup.h"
285
285
 
286
286
  curl_socket_t fd_read;
287
287
  curl_socket_t fd_write;
288
 
  curl_socket_t select_res;
 
288
  int select_res;
289
289
 
290
290
  curl_off_t contentlength;
291
291
 
1419
1419
 
1420
1420
  if (data->set.timeout &&
1421
1421
      ((Curl_tvdiff(k->now, k->start)/1000) >= data->set.timeout)) {
1422
 
    failf(data, "Operation timed out with %" FORMAT_OFF_T
1423
 
          " out of %" FORMAT_OFF_T " bytes received",
1424
 
          k->bytecount, conn->size);
 
1422
    if (conn->size != -1) {
 
1423
      failf(data, "Operation timed out after %d seconds with %"
 
1424
            FORMAT_OFF_T " out of %" FORMAT_OFF_T " bytes received",
 
1425
            data->set.timeout, k->bytecount, conn->size);
 
1426
    } else {
 
1427
      failf(data, "Operation timed out after %d seconds with %"
 
1428
            FORMAT_OFF_T " bytes received",
 
1429
            data->set.timeout, k->bytecount);
 
1430
    }
1425
1431
    return CURLE_OPERATION_TIMEOUTED;
1426
1432
  }
1427
1433
 
1628
1634
 
1629
1635
    interval_ms = 1 * 1000;
1630
1636
 
1631
 
    if(k->keepon & KEEP_READ)
1632
 
      fd_read = conn->sockfd;
1633
 
    else
 
1637
    /* limit-rate logic: if speed exceeds threshold, then do not include fd in
 
1638
       select set */
 
1639
    if ( (conn->data->set.max_send_speed > 0) &&
 
1640
         (conn->data->progress.ulspeed > conn->data->set.max_send_speed) )  {
 
1641
      fd_write = CURL_SOCKET_BAD;
 
1642
      Curl_pgrsUpdate(conn);
 
1643
    }
 
1644
    else {
 
1645
      if(k->keepon & KEEP_WRITE)
 
1646
        fd_write = conn->writesockfd;
 
1647
      else
 
1648
        fd_write = CURL_SOCKET_BAD;
 
1649
    }
 
1650
 
 
1651
    if ( (conn->data->set.max_recv_speed > 0) &&
 
1652
         (conn->data->progress.dlspeed > conn->data->set.max_recv_speed) ) {
1634
1653
      fd_read = CURL_SOCKET_BAD;
1635
 
 
1636
 
    if(k->keepon & KEEP_WRITE)
1637
 
      fd_write = conn->writesockfd;
1638
 
    else
1639
 
      fd_write = CURL_SOCKET_BAD;
 
1654
      Curl_pgrsUpdate(conn);
 
1655
    }
 
1656
    else {
 
1657
      if(k->keepon & KEEP_READ)
 
1658
        fd_read = conn->sockfd;
 
1659
      else
 
1660
        fd_read = CURL_SOCKET_BAD;
 
1661
    }
1640
1662
 
1641
1663
    switch (Curl_select(fd_read, fd_write, interval_ms)) {
1642
1664
    case -1: /* select() error, stop reading */
1651
1673
      continue;
1652
1674
    case 0:  /* timeout */
1653
1675
    default: /* readable descriptors */
 
1676
 
1654
1677
      result = Curl_readwrite(conn, &done);
1655
1678
      break;
1656
1679
    }
1691
1714
  data->state.authproxy.want = data->set.proxyauth;
1692
1715
 
1693
1716
  /* If there is a list of cookie files to read, do it now! */
1694
 
  if(data->change.cookielist)
 
1717
  if(data->change.cookielist) {
1695
1718
    Curl_cookie_loadfiles(data);
 
1719
  }
1696
1720
 
1697
1721
 /* Allow data->set.use_port to set which port to use. This needs to be
1698
1722
  * disabled for example when we follow Location: headers to URLs using