Ignore:
Timestamp:
Nov 7, 2008, 4:10:27 AM (14 years ago)
Author:
charles
Message:

#1429 (libT) cleaner handling of the special case where the upload or download speed limit is zero

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r7056 r7064  
    147147{
    148148    tr_speedlimit * limit = direction == TR_UP ? &tor->uploadLimitMode
    149                             : &tor->downloadLimitMode;
     149                                               : &tor->downloadLimitMode;
    150150
    151151    *limit = mode;
     
    157157{
    158158    return direction == TR_UP ? tor->uploadLimitMode
    159            : tor->downloadLimitMode;
     159                              : tor->downloadLimitMode;
    160160}
    161161
     
    193193            assert( 0 );
    194194    }
     195}
     196
     197int
     198tr_torrentPieceTransferIsAllowed( const tr_torrent  * tor,
     199                                  tr_direction        direction )
     200{
     201    int isEnabled = FALSE;
     202
     203    switch( tr_torrentGetSpeedMode( tor, direction ) )
     204    {
     205        case TR_SPEEDLIMIT_GLOBAL:
     206            isEnabled = tr_sessionGetSpeedLimit( tor->session, direction ) > 0;
     207            break;
     208
     209        case TR_SPEEDLIMIT_SINGLE:
     210            isEnabled = tr_torrentGetSpeedLimit( tor, direction ) > 0;
     211            break;
     212
     213        case TR_SPEEDLIMIT_UNLIMITED:
     214            isEnabled = TRUE;
     215            break;
     216
     217        default:
     218            assert( 0 && "unhandled speed mode" );
     219            break;
     220    }
     221
     222    return isEnabled;
    195223}
    196224
Note: See TracChangeset for help on using the changeset viewer.