Ignore:
Timestamp:
Jul 3, 2010, 12:25:22 AM (11 years ago)
Author:
charles
Message:

(trunk) #3045 "make libtransmission's API byte-oriented instead of KiB-oriented." -- implemented. This is a largish commit and will break the mac build for a little while.

File:
1 edited

Legend:

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

    r10913 r10931  
    6767    const double assumed_payload_data_rate = 94.0;
    6868
    69     return (size_t)( d * ( 100.0 / assumed_payload_data_rate ) - d );
     69    return (unsigned int)( d * ( 100.0 / assumed_payload_data_rate ) - d );
    7070}
    7171
     
    9191
    9292static void
    93 didWriteWrapper( tr_peerIo * io, size_t bytes_transferred )
     93didWriteWrapper( tr_peerIo * io, unsigned int bytes_transferred )
    9494{
    9595     while( bytes_transferred && tr_isPeerIo( io ) )
     
    9797        struct tr_datatype * next = io->outbuf_datatypes->data;
    9898
    99         const size_t payload = MIN( next->length, bytes_transferred );
    100         const size_t overhead = guessPacketOverhead( payload );
     99        const unsigned int payload = MIN( next->length, bytes_transferred );
     100        const unsigned int overhead = guessPacketOverhead( payload );
    101101
    102102        tr_bandwidthUsed( &io->bandwidth, TR_UP, payload, next->isPieceData );
     
    207207
    208208    /* Limit the input buffer to 256K, so it doesn't grow too large */
    209     size_t howmuch;
     209    unsigned int howmuch;
     210    unsigned int curlen;
    210211    const tr_direction dir = TR_DOWN;
    211     const size_t max = 256 * 1024;
    212     size_t curlen;
     212    const unsigned int max = 256 * 1024;
    213213
    214214    assert( tr_isPeerIo( io ) );
     
    230230
    231231    EVUTIL_SET_SOCKET_ERROR( 0 );
    232     res = evbuffer_read( io->inbuf, fd, howmuch );
     232    res = evbuffer_read( io->inbuf, fd, (int)howmuch );
    233233    e = EVUTIL_SOCKET_ERROR( );
    234234
     
    283283
    284284    if( n > 0 )
    285         evbuffer_drain( buffer, n );
     285        evbuffer_drain( buffer, (size_t)n );
    286286
    287287    /* keep the iobuf's excess capacity from growing too large */
     
    717717**/
    718718
    719 static size_t
     719static unsigned int
    720720getDesiredOutputBufferSize( const tr_peerIo * io, uint64_t now )
    721721{
     
    724724     * or a few blocks, whichever is bigger.
    725725     * It's okay to tweak this as needed */
    726     const double currentSpeed = tr_bandwidthGetPieceSpeed( &io->bandwidth, now, TR_UP );
    727     const double period = 15; /* arbitrary */
    728     const double numBlocks = 3.5; /* the 3 is arbitrary; the .5 is to leave room for messages */
    729     return MAX( MAX_BLOCK_SIZE*numBlocks, currentSpeed*1024*period );
     726    const unsigned int currentSpeed_Bps = tr_bandwidthGetPieceSpeed_Bps( &io->bandwidth, now, TR_UP );
     727    const unsigned int period = 15u; /* arbitrary */
     728    /* the 3 is arbitrary; the .5 is to leave room for messages */
     729    static const unsigned int ceiling =  (unsigned int)( MAX_BLOCK_SIZE * 3.5 );
     730    return MAX( ceiling, currentSpeed_Bps*period );
    730731}
    731732
     
    883884
    884885        EVUTIL_SET_SOCKET_ERROR( 0 );
    885         res = evbuffer_read( io->inbuf, io->socket, howmuch );
     886        res = evbuffer_read( io->inbuf, io->socket, (int)howmuch );
    886887        e = EVUTIL_SOCKET_ERROR( );
    887888
Note: See TracChangeset for help on using the changeset viewer.