Changeset 1320


Ignore:
Timestamp:
Jan 8, 2007, 9:53:55 PM (16 years ago)
Author:
livings124
Message:

global bandwidth limits only apply to transfers that are not set to overide them

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/internal.h

    r1242 r1320  
    140140struct tr_torrent_s
    141141{
     142    tr_handle_t * handle;
    142143    tr_info_t info;
    143144
    144     tr_ratecontrol_t * globalUpload;
    145     tr_ratecontrol_t * globalDownload;
     145    int                customSpeedLimit;
    146146    tr_ratecontrol_t * upload;
    147147    tr_ratecontrol_t * download;
     
    202202    tr_torrent_t * torrentList;
    203203
    204     tr_ratecontrol_t * upload;
    205     tr_ratecontrol_t * download;
     204    int            uploadLimit;
     205    int            downloadLimit;
    206206    tr_fd_t      * fdlimit;
    207207    tr_choking_t * choking;
  • trunk/libtransmission/peer.c

    r1288 r1320  
    267267    for( ;; )
    268268    {
    269         if( tor && (!tr_rcCanTransfer( tor->globalDownload )
    270                     || !tr_rcCanTransfer( tor->download ) ) )
     269        if( tor && ( ( !tor->customSpeedLimit && !tr_rcCanGlobalTransfer( tor->handle, 0 ) )
     270            || ( tor->customSpeedLimit && !tr_rcCanTransfer( tor->download ) ) ) )
    271271        {
    272272            break;
     
    302302            tr_rcTransferred( peer->download, ret );
    303303            tr_rcTransferred( tor->download, ret );
    304             tr_rcTransferred( tor->globalDownload, ret );
    305304            if( parseBuf( tor, peer ) )
    306305            {
     
    438437        while( ( p = blockPending( tor, peer, &size ) ) )
    439438        {
    440             if( !tr_rcCanTransfer( tor->globalUpload )
    441                 || !tr_rcCanTransfer( tor->upload ) )
     439            if( ( !tor->customSpeedLimit && !tr_rcCanGlobalTransfer( tor->handle, 1 ) )
     440                    || ( tor->customSpeedLimit && !tr_rcCanTransfer( tor->upload ) ) )
    442441            {
    443442                break;
     
    457456            tr_rcTransferred( peer->upload, ret );
    458457            tr_rcTransferred( tor->upload, ret );
    459             tr_rcTransferred( tor->globalUpload, ret );
    460458
    461459            tor->uploadedCur += ret;
  • trunk/libtransmission/ratecontrol.c

    r261 r1320  
    9191}
    9292
     93int tr_rcCanGlobalTransfer( tr_handle_t * h, int isUpload )
     94{
     95    tr_torrent_t * tor;
     96    tr_ratecontrol_t * r;
     97    float rate = 0;
     98    int limit = isUpload ? h->uploadLimit : h->downloadLimit;
     99   
     100    if( limit < 0 )
     101    {
     102        return 1;
     103    }
     104   
     105    for( tor = h->torrentList; tor && rate < (float)limit; tor = tor->next )
     106    {
     107        if( !tor->customSpeedLimit )
     108        {
     109            r = isUpload ? tor->upload : tor->download;
     110            tr_lockLock( &r->lock );
     111            rate += rateForInterval( r, 1000 );
     112            tr_lockUnlock( &r->lock );
     113        }
     114    }
     115   
     116    return rate < (float)limit;
     117}
     118
    93119void tr_rcSetLimit( tr_ratecontrol_t * r, int limit )
    94120{
  • trunk/libtransmission/ratecontrol.h

    r261 r1320  
    2626
    2727tr_ratecontrol_t * tr_rcInit();
     28int                tr_rcCanGlobalTransfer( tr_handle_t * h, int isUpload );
    2829void               tr_rcSetLimit( tr_ratecontrol_t *, int );
    2930int                tr_rcCanTransfer( tr_ratecontrol_t * );
  • trunk/libtransmission/transmission.c

    r1302 r1320  
    7171
    7272    /* Initialize rate and file descripts controls */
    73     h->upload   = tr_rcInit();
    74     h->download = tr_rcInit();
     73    h->uploadLimit   = -1;
     74    h->downloadLimit = -1;
     75   
    7576    h->fdlimit  = tr_fdInit();
    7677    h->choking  = tr_chokingInit( h );
     
    193194void tr_setGlobalUploadLimit( tr_handle_t * h, int limit )
    194195{
    195     tr_rcSetLimit( h->upload, limit );
     196    h->uploadLimit = limit;
    196197    tr_chokingSetLimit( h->choking, limit );
    197198}
     
    199200void tr_setGlobalDownloadLimit( tr_handle_t * h, int limit )
    200201{
    201     tr_rcSetLimit( h->download, limit );
     202    h->downloadLimit = limit;
     203}
     204
     205void tr_setUseCustomLimit( tr_torrent_t * tor, int limit )
     206{
     207    tor->customSpeedLimit = limit;
    202208}
    203209
     
    273279    tr_info_t     * inf;
    274280    int             i;
    275 
     281   
    276282    inf        = &tor->info;
    277283    inf->flags = flags;
     
    290296    }
    291297
     298    tor->handle = h;
    292299    tor->status = TR_STATUS_PAUSE;
    293300    tor->id     = h->id;
     
    310317    tr_lockInit( &tor->lock );
    311318
    312     tor->globalUpload   = h->upload;
    313     tor->globalDownload = h->download;
    314319    tor->fdlimit        = h->fdlimit;
    315320    tor->upload         = tr_rcInit();
     
    739744    tr_chokingClose( h->choking );
    740745    tr_fdClose( h->fdlimit );
    741     tr_rcClose( h->upload );
    742     tr_rcClose( h->download );
    743746    free( h );
    744747
  • trunk/libtransmission/transmission.h

    r1302 r1320  
    161161void tr_torrentIterate( tr_handle_t *, tr_callback_t, void * );
    162162
     163void tr_setUseCustomLimit( tr_torrent_t * tor, int limit );
     164void tr_setUploadLimit( tr_torrent_t * tor, int limit );
     165void tr_setDownloadLimit( tr_torrent_t * tor, int limit );
     166
    163167/***********************************************************************
    164168 * tr_torrentRates
  • trunk/macosx/Torrent.m

    r1319 r1320  
    593593- (void) updateSpeedSetting
    594594{
    595     tr_setUploadLimit(fHandle, fLimitCustom && fCheckUpload ? fUploadLimit : -1);
    596     tr_setDownloadLimit(fHandle, fLimitCustom && fCheckDownload ? fDownloadLimit : -1);
     595    tr_setUseCustomLimit(fHandle, fLimitCustom);
     596    tr_setUploadLimit(fHandle, fCheckUpload ? fUploadLimit : -1);
     597    tr_setDownloadLimit(fHandle, fCheckDownload ? fDownloadLimit : -1);
    597598}
    598599
Note: See TracChangeset for help on using the changeset viewer.