From bcb83b4577e16f9de31bbeea7aba46c11aa0442f Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Thu, 20 Jan 2011 00:31:46 +0000 Subject: [PATCH] (trunk libT) #3921 "no overhead for reads" -- fixed. thanks to jch for reporting this. --- libtransmission/peer-io.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libtransmission/peer-io.c b/libtransmission/peer-io.c index e89fbd250..88c3271c4 100644 --- a/libtransmission/peer-io.c +++ b/libtransmission/peer-io.c @@ -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: