From: Charles Kerr Date: Tue, 21 Apr 2009 16:18:51 +0000 (+0000) Subject: (trunk libT) make sure that outbound protocol messages don't get blocked by bandwidth... X-Git-Tag: 1.60~67 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fb587a5b30f8128d72b8db172677e0410dcf6a08;p=transmission (trunk libT) make sure that outbound protocol messages don't get blocked by bandwidth limits --- diff --git a/libtransmission/bandwidth.c b/libtransmission/bandwidth.c index 50cc144fd..4672cfdde 100644 --- a/libtransmission/bandwidth.c +++ b/libtransmission/bandwidth.c @@ -251,12 +251,17 @@ tr_bandwidthAllocate( tr_bandwidth * b, peers = (struct tr_peerIo**) tr_ptrArrayBase( &tmp ); peerCount = tr_ptrArraySize( &tmp ); - for( i=0; ipriority ) { - case TR_PRI_HIGH: tr_ptrArrayAppend( &high, peers[i] ); break; - case TR_PRI_LOW: tr_ptrArrayAppend( &low, peers[i] ); break; - default: tr_ptrArrayAppend( &normal, peers[i] ); break; + for( i=0; ipriority ) { + case TR_PRI_HIGH: tr_ptrArrayAppend( &high, io ); break; + case TR_PRI_LOW: tr_ptrArrayAppend( &low, io ); break; + default: tr_ptrArrayAppend( &normal, io ); break; } } diff --git a/libtransmission/peer-io.c b/libtransmission/peer-io.c index 9877c551a..5e4b73b26 100644 --- a/libtransmission/peer-io.c +++ b/libtransmission/peer-io.c @@ -39,7 +39,7 @@ #define MAGIC_NUMBER 206745 static size_t -getPacketOverhead( size_t d ) +guessPacketOverhead( size_t d ) { /** * http://sd.wareonearth.com/~phil/net/overhead/ @@ -90,7 +90,7 @@ didWriteWrapper( tr_peerIo * io, size_t bytes_transferred ) { struct tr_datatype * next = __tr_list_entry( io->outbuf_datatypes.next, struct tr_datatype, head ); const size_t payload = MIN( next->length, bytes_transferred ); - const size_t overhead = getPacketOverhead( payload ); + const size_t overhead = guessPacketOverhead( payload ); tr_bandwidthUsed( &io->bandwidth, TR_UP, payload, next->isPieceData ); @@ -847,6 +847,26 @@ tr_peerIoFlush( tr_peerIo * io, tr_direction dir, size_t limit ) return bytesUsed; } +int +tr_peerIoFlushOutgoingProtocolMsgs( tr_peerIo * io ) +{ + size_t byteCount = 0; + struct __tr_list * walk; + struct __tr_list * fencepost = &io->outbuf_datatypes; + + /* count up how many bytes are used by non-piece-data messages + at the front of our outbound queue */ + for( walk=fencepost->next; walk!=fencepost; walk=walk->next ) { + struct tr_datatype * d = __tr_list_entry( walk, struct tr_datatype, head ); + if( d->isPieceData ) + break; + byteCount += d->length; + } + + return tr_peerIoFlush( io, TR_UP, byteCount ); +} + + /*** **** ****/ diff --git a/libtransmission/peer-io.h b/libtransmission/peer-io.h index 7a45061b8..adb9afcb6 100644 --- a/libtransmission/peer-io.h +++ b/libtransmission/peer-io.h @@ -380,6 +380,8 @@ int tr_peerIoFlush( tr_peerIo * io, tr_direction dir, size_t byteLimit ); +int tr_peerIoFlushOutgoingProtocolMsgs( tr_peerIo * io ); + /** *** **/