Changeset 13361


Ignore:
Timestamp:
Jul 1, 2012, 2:17:35 AM (9 years ago)
Author:
jordan
Message:

(trunk libT) #4402 "Transmission Bandwidth allocation getting overflows" -- use gvdl's patch '4402-uint-bpsoverflow.patch'

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/details.c

    r13192 r13361  
    212212    /* down_limit_spin */
    213213    if( n ) {
    214         const int baseline = tr_torrentGetSpeedLimit_KBps( torrents[0], TR_DOWN );
     214        const unsigned int baseline = tr_torrentGetSpeedLimit_KBps( torrents[0], TR_DOWN );
    215215        int i;
    216216        for( i=1; i<n; ++i )
     
    236236    /* up_limit_sping */
    237237    if( n ) {
    238         const int baseline = tr_torrentGetSpeedLimit_KBps( torrents[0], TR_UP );
     238        const unsigned int baseline = tr_torrentGetSpeedLimit_KBps( torrents[0], TR_UP );
    239239        int i;
    240240        for( i=1; i<n; ++i )
  • trunk/libtransmission/bandwidth.c

    r13034 r13361  
    175175    if( b->band[dir].isLimited )
    176176    {
    177         const unsigned int nextPulseSpeed = b->band[dir].desiredSpeed_Bps;
    178         b->band[dir].bytesLeft = ( nextPulseSpeed * period_msec ) / 1000u;
     177        const uint64_t nextPulseSpeed = b->band[dir].desiredSpeed_Bps;
     178        b->band[dir].bytesLeft = (unsigned int)( nextPulseSpeed * period_msec ) / 1000u;
    179179    }
    180180
  • trunk/libtransmission/peer-mgr.c

    r13360 r13361  
    26772677
    26782678    for( i=0; i<webseedCount; ++i ) {
    2679         int Bps;
     2679        unsigned int Bps;
    26802680        if( tr_webseedGetSpeed_Bps( webseeds[i], now, &Bps ) )
    26812681            ret[i] = Bps / (double)tr_speed_K;
     
    26872687}
    26882688
    2689 int
     2689unsigned int
    26902690tr_peerGetPieceSpeed_Bps( const tr_peer * peer, uint64_t now, tr_direction direction )
    26912691{
     
    30243024getRate( const tr_torrent * tor, struct peer_atom * atom, uint64_t now )
    30253025{
    3026     int Bps;
     3026    unsigned int Bps;
    30273027
    30283028    if( tr_torrentIsSeed( tor ) )
     
    30503050        return false;
    30513051    else {
    3052         const int got = tr_bandwidthGetPieceSpeed_Bps( b, now_msec, dir );
    3053         const int want = tr_bandwidthGetDesiredSpeed_Bps( b, dir );
     3052        const unsigned int got = tr_bandwidthGetPieceSpeed_Bps( b, now_msec, dir );
     3053        const unsigned int want = tr_bandwidthGetDesiredSpeed_Bps( b, dir );
    30543054        return got >= want;
    30553055    }
  • trunk/libtransmission/peer-mgr.h

    r12539 r13361  
    249249
    250250
    251 int tr_peerGetPieceSpeed_Bps( const tr_peer    * peer,
    252                               uint64_t           now,
    253                               tr_direction       direction );
     251unsigned int tr_peerGetPieceSpeed_Bps( const tr_peer    * peer,
     252                                       uint64_t           now,
     253                                       tr_direction       direction );
    254254
    255255void tr_peerMgrClearInterest( tr_torrent * tor );
  • trunk/libtransmission/peer-msgs.c

    r13300 r13361  
    16771677    {
    16781678        int estimatedBlocksInPeriod;
    1679         int rate_Bps;
    1680         int irate_Bps;
     1679        unsigned int rate_Bps;
     1680        unsigned int irate_Bps;
    16811681        const int floor = 4;
    16821682        const int seconds = REQUEST_BUF_SECS;
     
    16901690
    16911691        /* honor the session limits, if enabled */
    1692         if( tr_torrentUsesSessionLimits( torrent ) )
    1693             if( tr_sessionGetActiveSpeedLimit_Bps( torrent->session, TR_PEER_TO_CLIENT, &irate_Bps ) )
     1692        if( tr_torrentUsesSessionLimits( torrent )
     1693        && tr_sessionGetActiveSpeedLimit_Bps( torrent->session, TR_PEER_TO_CLIENT, &irate_Bps ) )
    16941694                rate_Bps = MIN( rate_Bps, irate_Bps );
    16951695
  • trunk/libtransmission/session.c

    r13329 r13361  
    12181218
    12191219bool
    1220 tr_sessionGetActiveSpeedLimit_Bps( const tr_session * session, tr_direction dir, int * setme_Bps )
     1220tr_sessionGetActiveSpeedLimit_Bps( const tr_session * session, tr_direction dir, unsigned int * setme_Bps )
    12211221{
    12221222    int isLimited = true;
     
    12391239                                    double            * setme_KBps )
    12401240{
    1241     int Bps = 0;
     1241    unsigned int Bps = 0;
    12421242    const bool is_active = tr_sessionGetActiveSpeedLimit_Bps( session, dir, &Bps );
    12431243    *setme_KBps = toSpeedKBps( Bps );
     
    12481248updateBandwidth( tr_session * session, tr_direction dir )
    12491249{
    1250     int limit_Bps = 0;
     1250    unsigned int limit_Bps = 0;
    12511251    const bool isLimited = tr_sessionGetActiveSpeedLimit_Bps( session, dir, &limit_Bps );
    12521252    const bool zeroCase = isLimited && !limit_Bps;
     
    13951395
    13961396void
    1397 tr_sessionSetSpeedLimit_Bps( tr_session * s, tr_direction d, int Bps )
     1397tr_sessionSetSpeedLimit_Bps( tr_session * s, tr_direction d, unsigned int Bps )
    13981398{
    13991399    assert( tr_isSession( s ) );
    14001400    assert( tr_isDirection( d ) );
    1401     assert( Bps >= 0 );
    14021401
    14031402    s->speedLimit_Bps[d] = Bps;
     
    14061405}
    14071406void
    1408 tr_sessionSetSpeedLimit_KBps( tr_session * s, tr_direction d, int KBps )
     1407tr_sessionSetSpeedLimit_KBps( tr_session * s, tr_direction d, unsigned int KBps )
    14091408{
    14101409    tr_sessionSetSpeedLimit_Bps( s, d, toSpeedBytes( KBps ) );
    14111410}
    14121411
    1413 int
     1412unsigned int
    14141413tr_sessionGetSpeedLimit_Bps( const tr_session * s, tr_direction d )
    14151414{
     
    14191418    return s->speedLimit_Bps[d];
    14201419}
    1421 int
     1420unsigned int
    14221421tr_sessionGetSpeedLimit_KBps( const tr_session * s, tr_direction d )
    14231422{
     
    14511450
    14521451void
    1453 tr_sessionSetAltSpeed_Bps( tr_session * s, tr_direction d, int Bps )
     1452tr_sessionSetAltSpeed_Bps( tr_session * s, tr_direction d, unsigned int Bps )
    14541453{
    14551454    assert( tr_isSession( s ) );
    14561455    assert( tr_isDirection( d ) );
    1457     assert( Bps >= 0 );
    14581456
    14591457    s->turtle.speedLimit_Bps[d] = Bps;
     
    14631461
    14641462void
    1465 tr_sessionSetAltSpeed_KBps( tr_session * s, tr_direction d, int KBps )
     1463tr_sessionSetAltSpeed_KBps( tr_session * s, tr_direction d, unsigned int KBps )
    14661464{
    14671465    tr_sessionSetAltSpeed_Bps( s, d, toSpeedBytes( KBps ) );
    14681466}
    14691467
    1470 int
     1468unsigned int
    14711469tr_sessionGetAltSpeed_Bps( const tr_session * s, tr_direction d )
    14721470{
     
    14761474    return s->turtle.speedLimit_Bps[d];
    14771475}
    1478 int
     1476unsigned int
    14791477tr_sessionGetAltSpeed_KBps( const tr_session * s, tr_direction d )
    14801478{
     
    16851683***/
    16861684
    1687 int
     1685unsigned int
    16881686tr_sessionGetPieceSpeed_Bps( const tr_session * session, tr_direction dir )
    16891687{
     
    16911689}
    16921690
    1693 int
     1691unsigned int
    16941692tr_sessionGetRawSpeed_Bps( const tr_session * session, tr_direction dir )
    16951693{
  • trunk/libtransmission/session.h

    r12640 r13361  
    5757{
    5858    /* TR_UP and TR_DOWN speed limits */
    59     int speedLimit_Bps[2];
     59    unsigned int speedLimit_Bps[2];
    6060
    6161    /* is turtle mode on right now? */
     
    119119    int                          umask;
    120120
    121     int                          speedLimit_Bps[2];
     121    unsigned int                 speedLimit_Bps[2];
    122122    bool                         speedLimitEnabled[2];
    123123
     
    293293***/
    294294
    295 static inline unsigned int toSpeedBytes ( unsigned int KBps ) { return KBps * tr_speed_K; }
    296 static inline double       toSpeedKBps  ( unsigned int Bps )  { return Bps / (double)tr_speed_K; }
    297 
    298 static inline uint64_t toMemBytes ( unsigned int MB ) { uint64_t B = tr_mem_K * tr_mem_K; B *= MB; return B; }
    299 static inline int      toMemMB    ( uint64_t B )      { return B / ( tr_mem_K * tr_mem_K ); }
     295static inline unsigned int
     296toSpeedBytes ( unsigned int KBps ) { return KBps * tr_speed_K; }
     297static inline double
     298toSpeedKBps  ( unsigned int Bps )  { return Bps / (double)tr_speed_K; }
     299
     300static inline uint64_t
     301toMemBytes ( unsigned int MB ) { uint64_t B = tr_mem_K * tr_mem_K; B *= MB; return B; }
     302static inline int
     303toMemMB    ( uint64_t B )      { return B / ( tr_mem_K * tr_mem_K ); }
    300304
    301305/**
    302306**/
    303307
    304 int  tr_sessionGetSpeedLimit_Bps( const tr_session *, tr_direction );
    305 int  tr_sessionGetAltSpeed_Bps  ( const tr_session *, tr_direction );
    306 int  tr_sessionGetRawSpeed_Bps  ( const tr_session *, tr_direction );
    307 int  tr_sessionGetPieceSpeed_Bps( const tr_session *, tr_direction );
    308 
    309 void tr_sessionSetSpeedLimit_Bps( tr_session *, tr_direction, int Bps );
    310 void tr_sessionSetAltSpeed_Bps  ( tr_session *, tr_direction, int Bps );
     308unsigned int  tr_sessionGetSpeedLimit_Bps( const tr_session *, tr_direction );
     309unsigned int  tr_sessionGetAltSpeed_Bps  ( const tr_session *, tr_direction );
     310unsigned int  tr_sessionGetRawSpeed_Bps  ( const tr_session *, tr_direction );
     311unsigned int  tr_sessionGetPieceSpeed_Bps( const tr_session *, tr_direction );
     312
     313void tr_sessionSetSpeedLimit_Bps( tr_session *, tr_direction, unsigned int Bps );
     314void tr_sessionSetAltSpeed_Bps  ( tr_session *, tr_direction, unsigned int Bps );
    311315
    312316bool  tr_sessionGetActiveSpeedLimit_Bps( const tr_session  * session,
    313317                                         tr_direction        dir,
    314                                          int               * setme );
     318                                         unsigned int      * setme );
    315319
    316320tr_torrent * tr_sessionGetNextQueuedSeed( tr_session * session );
  • trunk/libtransmission/torrent.c

    r13203 r13361  
    154154                                  tr_direction        direction )
    155155{
    156     int limit;
     156    unsigned int limit;
    157157    bool allowed = true;
    158158
     
    174174
    175175void
    176 tr_torrentSetSpeedLimit_Bps( tr_torrent * tor, tr_direction dir, int Bps )
     176tr_torrentSetSpeedLimit_Bps( tr_torrent * tor, tr_direction dir, unsigned int Bps )
    177177{
    178178    assert( tr_isTorrent( tor ) );
    179179    assert( tr_isDirection( dir ) );
    180     assert( Bps >= 0 );
    181180
    182181    if( tr_bandwidthSetDesiredSpeed_Bps( &tor->bandwidth, dir, Bps ) )
     
    184183}
    185184void
    186 tr_torrentSetSpeedLimit_KBps( tr_torrent * tor, tr_direction dir, int KBps )
     185tr_torrentSetSpeedLimit_KBps( tr_torrent * tor, tr_direction dir, unsigned int KBps )
    187186{
    188187    tr_torrentSetSpeedLimit_Bps( tor, dir, toSpeedBytes( KBps ) );
    189188}
    190189
    191 int
     190unsigned int
    192191tr_torrentGetSpeedLimit_Bps( const tr_torrent * tor, tr_direction dir )
    193192{
     
    197196    return tr_bandwidthGetDesiredSpeed_Bps( &tor->bandwidth, dir );
    198197}
    199 int
     198unsigned int
    200199tr_torrentGetSpeedLimit_KBps( const tr_torrent * tor, tr_direction dir )
    201200{
  • trunk/libtransmission/torrent.h

    r12617 r13361  
    415415void tr_torrentGotNewInfoDict( tr_torrent * tor );
    416416
    417 void tr_torrentSetSpeedLimit_Bps  ( tr_torrent *, tr_direction, int Bps );
    418 int tr_torrentGetSpeedLimit_Bps  ( const tr_torrent *, tr_direction );
     417void tr_torrentSetSpeedLimit_Bps  ( tr_torrent *, tr_direction, unsigned int Bps );
     418unsigned int tr_torrentGetSpeedLimit_Bps  ( const tr_torrent *, tr_direction );
    419419
    420420/**
  • trunk/libtransmission/transmission.h

    r13191 r13361  
    653653***/
    654654
    655 void  tr_sessionSetSpeedLimit_KBps ( tr_session *, tr_direction, int KBps );
    656 int  tr_sessionGetSpeedLimit_KBps ( const tr_session *, tr_direction );
     655void         tr_sessionSetSpeedLimit_KBps ( tr_session *, tr_direction, unsigned int KBps );
     656unsigned int tr_sessionGetSpeedLimit_KBps ( const tr_session *, tr_direction );
    657657
    658658void  tr_sessionLimitSpeed         ( tr_session *, tr_direction, bool );
     
    664664***/
    665665
    666 void     tr_sessionSetAltSpeed_KBps   ( tr_session *, tr_direction, int Bps );
    667 int      tr_sessionGetAltSpeed_KBps   ( const tr_session *, tr_direction );
     666void         tr_sessionSetAltSpeed_KBps   ( tr_session *, tr_direction, unsigned int Bps );
     667unsigned int tr_sessionGetAltSpeed_KBps   ( const tr_session *, tr_direction );
    668668
    669669void     tr_sessionUseAltSpeed        ( tr_session *, bool );
     
    12281228***/
    12291229
    1230 void     tr_torrentSetSpeedLimit_KBps  ( tr_torrent *, tr_direction, int KBps );
    1231 int      tr_torrentGetSpeedLimit_KBps  ( const tr_torrent *, tr_direction );
     1230void         tr_torrentSetSpeedLimit_KBps  ( tr_torrent *, tr_direction, unsigned int KBps );
     1231unsigned int tr_torrentGetSpeedLimit_KBps  ( const tr_torrent *, tr_direction );
    12321232
    12331233void     tr_torrentUseSpeedLimit      ( tr_torrent *, tr_direction, bool );
  • trunk/libtransmission/webseed.c

    r13105 r13361  
    513513
    514514bool
    515 tr_webseedGetSpeed_Bps( const tr_webseed * w, uint64_t now, int * setme_Bps )
     515tr_webseedGetSpeed_Bps( const tr_webseed * w,
     516                        uint64_t           now,
     517                        unsigned int     * setme_Bps )
    516518{
    517519    const bool is_active = webseed_has_tasks( w );
     
    523525tr_webseedIsActive( const tr_webseed * w )
    524526{
    525     int Bps = 0;
     527    unsigned int Bps = 0;
    526528    return tr_webseedGetSpeed_Bps( w, tr_time_msec(), &Bps ) && ( Bps > 0 );
    527529}
  • trunk/libtransmission/webseed.h

    r12204 r13361  
    3232bool        tr_webseedGetSpeed_Bps( const tr_webseed * w,
    3333                                    uint64_t           now,
    34                                     int              * setme_Bps );
     34                                    unsigned int     * setme_Bps );
    3535
    3636/** @return true if a request is being processed, or false if idle */
Note: See TracChangeset for help on using the changeset viewer.