Changeset 8265


Ignore:
Timestamp:
Apr 21, 2009, 4:18:51 PM (13 years ago)
Author:
charles
Message:

(trunk libT) make sure that outbound protocol messages don't get blocked by bandwidth limits

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bandwidth.c

    r8254 r8265  
    252252    peerCount = tr_ptrArraySize( &tmp );
    253253
    254     for( i=0; i<peerCount; ++i ) {
    255         tr_peerIoRef( peers[i] );
    256         switch( peers[i]->priority ) {
    257             case TR_PRI_HIGH: tr_ptrArrayAppend( &high,   peers[i] ); break;
    258             case TR_PRI_LOW:  tr_ptrArrayAppend( &low,    peers[i] ); break;
    259             default:          tr_ptrArrayAppend( &normal, peers[i] ); break;
     254    for( i=0; i<peerCount; ++i )
     255    {
     256        tr_peerIo * io = peers[i];
     257        tr_peerIoRef( io );
     258
     259        tr_peerIoFlushOutgoingProtocolMsgs( io );
     260
     261        switch( io->priority ) {
     262            case TR_PRI_HIGH: tr_ptrArrayAppend( &high,   io ); break;
     263            case TR_PRI_LOW:  tr_ptrArrayAppend( &low,    io ); break;
     264            default:          tr_ptrArrayAppend( &normal, io ); break;
    260265        }
    261266    }
  • trunk/libtransmission/peer-io.c

    r8217 r8265  
    4040
    4141static size_t
    42 getPacketOverhead( size_t d )
     42guessPacketOverhead( size_t d )
    4343{
    4444    /**
     
    9191        struct tr_datatype * next = __tr_list_entry( io->outbuf_datatypes.next, struct tr_datatype, head );
    9292        const size_t payload = MIN( next->length, bytes_transferred );
    93         const size_t overhead = getPacketOverhead( payload );
     93        const size_t overhead = guessPacketOverhead( payload );
    9494
    9595        tr_bandwidthUsed( &io->bandwidth, TR_UP, payload, next->isPieceData );
     
    848848}
    849849
     850int
     851tr_peerIoFlushOutgoingProtocolMsgs( tr_peerIo * io )
     852{
     853    size_t byteCount = 0;
     854    struct __tr_list * walk;
     855    struct __tr_list * fencepost = &io->outbuf_datatypes;
     856
     857    /* count up how many bytes are used by non-piece-data messages
     858       at the front of our outbound queue */
     859    for( walk=fencepost->next; walk!=fencepost; walk=walk->next ) {
     860        struct tr_datatype * d = __tr_list_entry( walk, struct tr_datatype, head );
     861        if( d->isPieceData )
     862            break;
     863        byteCount += d->length;
     864    }
     865
     866    return tr_peerIoFlush( io, TR_UP, byteCount );
     867}
     868
     869
    850870/***
    851871****
  • trunk/libtransmission/peer-io.h

    r8254 r8265  
    381381                          size_t          byteLimit );
    382382
     383int       tr_peerIoFlushOutgoingProtocolMsgs( tr_peerIo * io );
     384
    383385/**
    384386***
Note: See TracChangeset for help on using the changeset viewer.