(trunk libT) #3921 "no overhead for reads" -- fixed. thanks to jch for reporting this.

This commit is contained in:
Jordan Lee 2011-01-20 00:31:46 +00:00
parent 4f6d46cf99
commit bcb83b4577
1 changed files with 5 additions and 3 deletions

View File

@ -146,15 +146,14 @@ canReadWrapper( tr_peerIo * io )
size_t piece = 0;
const size_t oldLen = evbuffer_get_length( io->inbuf );
const int ret = io->canRead( io, io->userData, &piece );
const size_t used = oldLen - evbuffer_get_length( io->inbuf );
const unsigned int overhead = guessPacketOverhead( used );
const uint64_t now = tr_time_msec( );
assert( tr_isPeerIo( io ) );
if( piece || (piece!=used) )
{
const uint64_t now = tr_time_msec( );
if( piece )
tr_bandwidthUsed( &io->bandwidth, TR_DOWN, piece, TRUE, now );
@ -162,6 +161,9 @@ canReadWrapper( tr_peerIo * io )
tr_bandwidthUsed( &io->bandwidth, TR_DOWN, used - piece, FALSE, now );
}
if( overhead > 0 )
tr_bandwidthUsed( &io->bandwidth, TR_UP, overhead, FALSE, now );
switch( ret )
{
case READ_NOW: