]> granicus.if.org Git - transmission/commitdiff
(trunk libT) #3921 "no overhead for reads" -- fixed. thanks to jch for reporting...
authorJordan Lee <jordan@transmissionbt.com>
Thu, 20 Jan 2011 00:31:46 +0000 (00:31 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Thu, 20 Jan 2011 00:31:46 +0000 (00:31 +0000)
libtransmission/peer-io.c

index e89fbd2501ad352d815bdc8ff6d7ea8652750c25..88c3271c49f4b66e1e21b6659313d685c0854f8c 100644 (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: