Changeset 11930


Ignore:
Timestamp:
Feb 18, 2011, 12:36:09 AM (11 years ago)
Author:
jch
Message:

Implement pacing of reads.

This should cause uTP sockets to respect read bandwidth limits. I'm not so
sure about the values we return for the read buffer size -- perhaps we
should allow some slack for network latency?

File:
1 edited

Legend:

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

    r11929 r11930  
    409409{
    410410    tr_peerIo *io = (tr_peerIo *)closure;
    411     assert( tr_isPeerIo( io ) );
    412 
    413     tr_ndbg( "UTP", "Get RB size" );
    414     return 0;
     411    size_t bytes;
     412    assert( tr_isPeerIo( io ) );
     413
     414    if( io->read_enabled )
     415        bytes =
     416            tr_bandwidthClamp( &io->bandwidth, TR_DOWN, UTP_READ_BUFFER_SIZE );
     417    else
     418        bytes = 0;
     419
     420    tr_ndbg( "UTP", "Get RB size %ld", (long)bytes);
     421
     422    return UTP_READ_BUFFER_SIZE - bytes;
    415423}
    416424
     
    707715    if( dir == TR_UP )
    708716        io->write_enabled = isEnabled;
    709     else if( dir == TR_DOWN )
     717    else if( dir == TR_DOWN ) {
    710718        io->read_enabled = isEnabled;
     719        if( io->utp_socket && isEnabled )
     720            UTP_RBDrained(io->utp_socket);
     721    }
    711722}
    712723
Note: See TracChangeset for help on using the changeset viewer.