From: Juliusz Chroboczek Date: Fri, 18 Feb 2011 00:36:02 +0000 (+0000) Subject: Compute accurate overhead for uTP packets. X-Git-Tag: 2.30b1~327 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=80677b37305e8f3849d06a5177946f899dddd1ca;p=transmission Compute accurate overhead for uTP packets. --- diff --git a/libtransmission/peer-io.c b/libtransmission/peer-io.c index 9da78dc79..763cd7624 100644 --- a/libtransmission/peer-io.c +++ b/libtransmission/peer-io.c @@ -100,7 +100,9 @@ didWriteWrapper( tr_peerIo * io, unsigned int bytes_transferred ) struct tr_datatype * next = io->outbuf_datatypes->data; const unsigned int payload = MIN( next->length, bytes_transferred ); - const unsigned int overhead = guessPacketOverhead( payload ); + /* For uTP sockets, the overhead is computed in utp_on_overhead. */ + const unsigned int overhead = + io->socket ? guessPacketOverhead( payload ) : 0; const uint64_t now = tr_sessionGetTimeMsec( io->session ); tr_bandwidthUsed( &io->bandwidth, TR_UP, payload, next->isPieceData, now ); @@ -452,6 +454,8 @@ utp_on_overhead(void *closure, bool send, size_t count, int type) assert( tr_isPeerIo( io ) ); tr_ndbg( "UTP", "On overhead: %d %ld %d", (int)send, (long)count, type ); + tr_bandwidthUsed( &io->bandwidth, send ? TR_UP : TR_DOWN, + count, FALSE, tr_time_msec() ); } static struct UTPFunctionTable utp_function_table = {