Changeset 7789


Ignore:
Timestamp:
Jan 24, 2009, 3:17:59 AM (12 years ago)
Author:
charles
Message:

(trunk libT) don't limit peer bandwidth during the handshake phase. this solves a bug that made it difficult to connect to peers when the upload bandwidth is saturated.

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bandwidth.c

    r7748 r7789  
    209209        tr_peerIoRef( peers[i] );
    210210
    211     /* Stop all peers from listening for the socket to be ready for IO.
    212      * See "Second phase of IO" lower in this function for more info. */
    213     for( i=0; i<peerCount; ++i )
    214         tr_peerIoSetEnabled( peers[i], dir, FALSE );
    215 
    216211    /* First phase of IO.  Tries to distribute bandwidth fairly to keep faster
    217212     * peers from starving the others.  Loop through the peers, giving each a
     
    247242     * or (2) the next tr_bandwidthAllocate() call, when we start over again. */
    248243    for( i=0; i<peerCount; ++i )
    249         if( tr_peerIoHasBandwidthLeft( peers[i], dir ) )
    250             tr_peerIoSetEnabled( peers[i], dir, TRUE );
     244        tr_peerIoSetEnabled( peers[i], dir, tr_peerIoHasBandwidthLeft( peers[i], dir ) );
    251245
    252246    for( i=0; i<peerCount; ++i )
  • trunk/libtransmission/peer-io.c

    r7770 r7789  
    824824    }
    825825
    826     dbgmsg( io, "flushing peer-io, direction %d, limit %zu, bytesUsed %d", (int)dir, limit, bytesUsed );
     826    dbgmsg( io, "flushing peer-io, hasFinishedConnecting %d, direction %d, limit %zu, bytesUsed %d", (int)io->hasFinishedConnecting, (int)dir, limit, bytesUsed );
    827827    return bytesUsed;
    828828}
     
    835835event_enable( tr_peerIo * io, short event )
    836836{
    837     if( event & EV_READ )
     837    if( event & EV_READ ) {
     838        dbgmsg( io, "enabling libevent ready-to-read polling" );
    838839        event_add( &io->event_read, NULL );
    839 
    840     if( event & EV_WRITE )
     840    }
     841
     842    if( event & EV_WRITE ) {
     843        dbgmsg( io, "enabling libevent ready-to-write polling" );
    841844        event_add( &io->event_write, NULL );
     845    }
    842846}
    843847
     
    845849event_disable( struct tr_peerIo * io, short event )
    846850{
    847     if( event & EV_READ )
     851    if( event & EV_READ ) {
     852        dbgmsg( io, "disabling libevent ready-to-read polling" );
    848853        event_del( &io->event_read );
    849 
    850     if( event & EV_WRITE )
     854    }
     855
     856    if( event & EV_WRITE ) {
     857        dbgmsg( io, "disabling libevent ready-to-write polling" );
    851858        event_del( &io->event_write );
     859    }
    852860}
    853861
  • trunk/libtransmission/peer-io.h

    r7770 r7789  
    328328
    329329static TR_INLINE void tr_peerIoSetParent( tr_peerIo            * io,
    330                                        struct tr_bandwidth  * parent )
     330                                          struct tr_bandwidth  * parent )
    331331{
    332332    assert( tr_isPeerIo( io ) );
     
    341341
    342342static TR_INLINE tr_bool tr_peerIoHasBandwidthLeft( const tr_peerIo  * io,
    343                                                  tr_direction       dir )
    344 {
    345     assert( tr_isPeerIo( io ) );
    346 
    347     return tr_bandwidthClamp( &io->bandwidth, dir, 1024 ) > 0;
     343                                                    tr_direction       dir )
     344{
     345    assert( tr_isPeerIo( io ) );
     346
     347    return !io->hasFinishedConnecting
     348        || ( tr_bandwidthClamp( &io->bandwidth, dir, 1024 ) > 0 );
    348349}
    349350
Note: See TracChangeset for help on using the changeset viewer.