Ignore:
Timestamp:
Nov 17, 2007, 12:16:26 AM (15 years ago)
Author:
charles
Message:

speed limit code cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/ratecontrol.c

    r3842 r3844  
    3030#include "utils.h"
    3131
    32 #define GRANULARITY_MSEC 250
     32#define GRANULARITY_MSEC 200
    3333#define SHORT_INTERVAL_MSEC 2000
    34 #define LONG_INTERVAL_MSEC 10000
     34#define LONG_INTERVAL_MSEC 8000
    3535#define HISTORY_SIZE (LONG_INTERVAL_MSEC / GRANULARITY_MSEC)
    3636
     
    9595***/
    9696
    97 int
    98 tr_rcCanTransfer( const tr_ratecontrol * r )
    99 {
    100     int ret;
    101 
    102     if( r == NULL )
    103         ret = 0;
    104     else {
    105         tr_lockLock( (tr_lock*)r->lock );
    106         ret = rateForInterval( r, SHORT_INTERVAL_MSEC ) < r->limit;
    107         tr_lockUnlock( (tr_lock*)r->lock );
    108     }
    109 
    110     return ret;
    111 }
    112 
    11397size_t
    11498tr_rcBytesLeft( const tr_ratecontrol * r )
     
    118102    if( r != NULL )
    119103    {
    120         float cur, max;
    121         size_t kb;
     104        float cur, max, kb;
    122105 
    123106        tr_lockLock( (tr_lock*)r->lock );
     
    126109        max = r->limit;
    127110        kb = max>cur ? max-cur : 0;
    128         bytes = kb * 1024u;
     111        bytes = (size_t)(kb * 1024u);
    129112
    130113        tr_lockUnlock( (tr_lock*)r->lock );
Note: See TracChangeset for help on using the changeset viewer.