Changeset 3844


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

speed limit code cleanup

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-io.c

    r3842 r3844  
    3030#define IO_TIMEOUT_SECS 8
    3131
    32 /* arbitrary. */
    33 #define TR_RDBUF (1024*6)
     32#define TR_RDBUF 2048
    3433
    3534/**
  • 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 );
  • trunk/libtransmission/ratecontrol.h

    r3615 r3844  
    3131void             tr_rcSetLimit( tr_ratecontrol *, int );
    3232int              tr_rcGetLimit( const tr_ratecontrol * );
    33 int              tr_rcCanTransfer( const tr_ratecontrol * );
    3433size_t           tr_rcBytesLeft( const tr_ratecontrol * );
    3534void             tr_rcTransferred( tr_ratecontrol *, size_t byteCount );
Note: See TracChangeset for help on using the changeset viewer.