Changeset 8266


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

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

Location:
branches/1.5x/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/1.5x/libtransmission/bandwidth.c

    r7813 r8266  
    206206    peerCount = tr_ptrArraySize( &tmp );
    207207
    208     for( i=0; i<peerCount; ++i )
    209         tr_peerIoRef( peers[i] );
     208    for( i=0; i<peerCount; ++i ) {
     209        tr_peerIo * io = peers[i];
     210        tr_peerIoRef( io );
     211        tr_peerIoFlushOutgoingProtocolMsgs( io );
     212    }
    210213
    211214    /* First phase of IO.  Tries to distribute bandwidth fairly to keep faster
  • branches/1.5x/libtransmission/peer-io.c

    r8218 r8266  
    4040
    4141static size_t
    42 getPacketOverhead( size_t d )
     42guessPacketOverhead( size_t d )
    4343{
    4444    /**
     
    8787didWriteWrapper( tr_peerIo * io, size_t bytes_transferred )
    8888{
    89     while( bytes_transferred )
    90     {
     89     while( bytes_transferred && tr_isPeerIo( io ) )
     90     {
    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 );
     
    100100        if( io->didWrite )
    101101            io->didWrite( io, payload, next->isPieceData, io->userData );
    102 
    103         bytes_transferred -= payload;
    104         next->length -= payload;
    105         if( !next->length ) {
    106             __tr_list_remove( io->outbuf_datatypes.next );
    107             tr_free( next );
    108         }
     102       
     103        if( tr_isPeerIo( io ) )
     104        {
     105            bytes_transferred -= payload;
     106            next->length -= payload;
     107            if( !next->length ) {
     108                __tr_list_remove( io->outbuf_datatypes.next );
     109                tr_free( next );
     110            }
     111        }
    109112    }
    110113}
     
    845848}
    846849
     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
    847870/***
    848871****
  • branches/1.5x/libtransmission/peer-io.h

    r7813 r8266  
    379379                          size_t          byteLimit );
    380380
     381int       tr_peerIoFlushOutgoingProtocolMsgs( tr_peerIo * io );
     382
    381383/**
    382384***
Note: See TracChangeset for help on using the changeset viewer.