mirror of
https://github.com/transmission/transmission
synced 2025-01-31 19:34:05 +00:00
(trunk libT) make sure that outbound protocol messages don't get blocked by bandwidth limits
This commit is contained in:
parent
43111790d0
commit
fb587a5b30
3 changed files with 35 additions and 8 deletions
|
@ -251,12 +251,17 @@ tr_bandwidthAllocate( tr_bandwidth * b,
|
|||
peers = (struct tr_peerIo**) tr_ptrArrayBase( &tmp );
|
||||
peerCount = tr_ptrArraySize( &tmp );
|
||||
|
||||
for( i=0; i<peerCount; ++i ) {
|
||||
tr_peerIoRef( peers[i] );
|
||||
switch( peers[i]->priority ) {
|
||||
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; i<peerCount; ++i )
|
||||
{
|
||||
tr_peerIo * io = peers[i];
|
||||
tr_peerIoRef( io );
|
||||
|
||||
tr_peerIoFlushOutgoingProtocolMsgs( io );
|
||||
|
||||
switch( io->priority ) {
|
||||
case TR_PRI_HIGH: tr_ptrArrayAppend( &high, io ); break;
|
||||
case TR_PRI_LOW: tr_ptrArrayAppend( &low, io ); break;
|
||||
default: tr_ptrArrayAppend( &normal, io ); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
****
|
||||
****/
|
||||
|
|
|
@ -380,6 +380,8 @@ int tr_peerIoFlush( tr_peerIo * io,
|
|||
tr_direction dir,
|
||||
size_t byteLimit );
|
||||
|
||||
int tr_peerIoFlushOutgoingProtocolMsgs( tr_peerIo * io );
|
||||
|
||||
/**
|
||||
***
|
||||
**/
|
||||
|
|
Loading…
Reference in a new issue