Changeset 210


Ignore:
Timestamp:
Apr 7, 2006, 12:09:08 PM (16 years ago)
Author:
titer
Message:

Adds download rate limit

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/transmissioncli.c

    r198 r210  
    4242"  -p, --port <int>     Port we should listen on (default = %d)\n" \
    4343"  -u, --upload <int>   Maximum upload rate (-1 = no limit, default = 20)\n" \
     44"  -d, --download <int> Maximum download rate (-1 = no limit, default = -1)\n" \
    4445"  -f, --finish <shell script> Command you wish to run on completion\n"
    4546
    46 static int             showHelp     = 0;
    47 static int             showInfo     = 0;
    48 static int             showScrape   = 0;
    49 static int             verboseLevel = 0;
    50 static int             bindPort     = TR_DEFAULT_PORT;
    51 static int             uploadLimit  = 20;
    52 static char          * torrentPath  = NULL;
    53 static volatile char   mustDie      = 0;
     47static int           showHelp      = 0;
     48static int           showInfo      = 0;
     49static int           showScrape    = 0;
     50static int           verboseLevel  = 0;
     51static int           bindPort      = TR_DEFAULT_PORT;
     52static int           uploadLimit   = 20;
     53static int           downloadLimit = -1;
     54static char          * torrentPath = NULL;
     55static volatile char mustDie       = 0;
    5456
    5557static char          * finishCall   = NULL;
     
    159161    tr_setBindPort( h, bindPort );
    160162    tr_setUploadLimit( h, uploadLimit );
     163    tr_setDownloadLimit( h, downloadLimit );
    161164   
    162165    tr_torrentSetFolder( tor, "." );
     
    241244    {
    242245        static struct option long_options[] =
    243           { { "help",    no_argument,       NULL, 'h' },
    244             { "info",    no_argument,       NULL, 'i' },
    245             { "scrape",  no_argument,       NULL, 's' },
    246             { "verbose", required_argument, NULL, 'v' },
    247             { "port",    required_argument, NULL, 'p' },
    248             { "upload",  required_argument, NULL, 'u' },
    249             { "finish",  required_argument, NULL, 'f' },
     246          { { "help",     no_argument,       NULL, 'h' },
     247            { "info",     no_argument,       NULL, 'i' },
     248            { "scrape",   no_argument,       NULL, 's' },
     249            { "verbose",  required_argument, NULL, 'v' },
     250            { "port",     required_argument, NULL, 'p' },
     251            { "upload",   required_argument, NULL, 'u' },
     252            { "download", required_argument, NULL, 'd' },
     253            { "finish",   required_argument, NULL, 'f' },
    250254            { 0, 0, 0, 0} };
    251255
    252256        int c, optind = 0;
    253         c = getopt_long( argc, argv, "hisv:p:u:f:", long_options, &optind );
     257        c = getopt_long( argc, argv, "hisv:p:u:d:f:", long_options, &optind );
    254258        if( c < 0 )
    255259        {
     
    275279            case 'u':
    276280                uploadLimit = atoi( optarg );
     281                break;
     282            case 'd':
     283                downloadLimit = atoi( optarg );
    277284                break;
    278285            case 'f':
  • trunk/libtransmission/peer.c

    r133 r210  
    220220    for( ;; )
    221221    {
     222        if( tor && !tr_rcCanTransfer( tor->globalDownload ) )
     223        {
     224            break;
     225        }
     226
    222227        if( peer->size < 1 )
    223228        {
     
    230235            peer->buf   = realloc( peer->buf, peer->size );
    231236        }
     237        /* Never read more than 1K each time, otherwise the rate
     238           control is no use */
    232239        ret = tr_netRecv( peer->socket, &peer->buf[peer->pos],
    233                           peer->size - peer->pos );
     240                          MIN( 1024, peer->size - peer->pos ) );
    234241        if( ret & TR_NET_CLOSE )
    235242        {
  • trunk/libtransmission/transmission.c

    r203 r210  
    138138    tr_rcSetLimit( h->upload, limit );
    139139    tr_chokingSetLimit( h->choking, limit );
     140}
     141
     142/***********************************************************************
     143 * tr_setDownloadLimit
     144 ***********************************************************************
     145 *
     146 **********************************************************************/
     147void tr_setDownloadLimit( tr_handle_t * h, int limit )
     148{
     149    tr_rcSetLimit( h->download, limit );
    140150}
    141151
  • trunk/libtransmission/transmission.h

    r162 r210  
    7575
    7676/***********************************************************************
     77 * tr_setDownloadLimit
     78 ***********************************************************************
     79 * Sets the total download rate limit in KB/s
     80 **********************************************************************/
     81void tr_setDownloadLimit( tr_handle_t *, int );
     82
     83/***********************************************************************
    7784 * tr_torrentCount
    7885 ***********************************************************************
Note: See TracChangeset for help on using the changeset viewer.