]> granicus.if.org Git - transmission/commitdiff
(trunk libT) don't limit peer bandwidth during the handshake phase. this solves...
authorCharles Kerr <charles@transmissionbt.com>
Sat, 24 Jan 2009 03:17:59 +0000 (03:17 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Sat, 24 Jan 2009 03:17:59 +0000 (03:17 +0000)
libtransmission/bandwidth.c
libtransmission/peer-io.c
libtransmission/peer-io.h

index a584ee3eab86c28482d46991ec3477f7f4eddaf3..57571d4cfa9ca12ecc02c3952d7feb63e792480d 100644 (file)
@@ -208,11 +208,6 @@ tr_bandwidthAllocate( tr_bandwidth  * b,
     for( i=0; i<peerCount; ++i )
         tr_peerIoRef( peers[i] );
 
-    /* Stop all peers from listening for the socket to be ready for IO.
-     * See "Second phase of IO" lower in this function for more info. */
-    for( i=0; i<peerCount; ++i )
-        tr_peerIoSetEnabled( peers[i], dir, FALSE );
-
     /* First phase of IO.  Tries to distribute bandwidth fairly to keep faster
      * peers from starving the others.  Loop through the peers, giving each a
      * small chunk of bandwidth.  Keep looping until we run out of bandwidth
@@ -246,8 +241,7 @@ tr_bandwidthAllocate( tr_bandwidth  * b,
      * This on-demand IO is enabled until (1) the peer runs out of bandwidth,
      * or (2) the next tr_bandwidthAllocate() call, when we start over again. */
     for( i=0; i<peerCount; ++i )
-        if( tr_peerIoHasBandwidthLeft( peers[i], dir ) )
-            tr_peerIoSetEnabled( peers[i], dir, TRUE );
+        tr_peerIoSetEnabled( peers[i], dir, tr_peerIoHasBandwidthLeft( peers[i], dir ) );
 
     for( i=0; i<peerCount; ++i )
         tr_peerIoUnref( peers[i] );
index 54168eeb17c0d9114f121fe71723f34103f1cdd0..7744a61478c75e9c04814feea53f99e0139ac94d 100644 (file)
@@ -823,7 +823,7 @@ tr_peerIoFlush( tr_peerIo  * io, tr_direction dir, size_t limit )
             bytesUsed = tr_peerIoTryWrite( io, limit );
     }
 
-    dbgmsg( io, "flushing peer-io, direction %d, limit %zu, bytesUsed %d", (int)dir, limit, bytesUsed );
+    dbgmsg( io, "flushing peer-io, hasFinishedConnecting %d, direction %d, limit %zu, bytesUsed %d", (int)io->hasFinishedConnecting, (int)dir, limit, bytesUsed );
     return bytesUsed;
 }
 
@@ -834,21 +834,29 @@ tr_peerIoFlush( tr_peerIo  * io, tr_direction dir, size_t limit )
 static void
 event_enable( tr_peerIo * io, short event )
 {
-    if( event & EV_READ )
+    if( event & EV_READ ) {
+        dbgmsg( io, "enabling libevent ready-to-read polling" );
         event_add( &io->event_read, NULL );
+    }
 
-    if( event & EV_WRITE )
+    if( event & EV_WRITE ) {
+        dbgmsg( io, "enabling libevent ready-to-write polling" );
         event_add( &io->event_write, NULL );
+    }
 }
 
 static void
 event_disable( struct tr_peerIo * io, short event )
 {
-    if( event & EV_READ )
+    if( event & EV_READ ) {
+        dbgmsg( io, "disabling libevent ready-to-read polling" );
         event_del( &io->event_read );
+    }
 
-    if( event & EV_WRITE )
+    if( event & EV_WRITE ) {
+        dbgmsg( io, "disabling libevent ready-to-write polling" );
         event_del( &io->event_write );
+    }
 }
 
 
index 3cd1fcd6694b8aaa55e25d6c2595d1320044ff5c..cb0c87d4b1a4f14311644625389cd88c871fd9bd 100644 (file)
@@ -327,7 +327,7 @@ void      tr_peerIoDrain( tr_peerIo        * io,
 size_t    tr_peerIoGetWriteBufferSpace( const tr_peerIo * io, uint64_t now );
 
 static TR_INLINE void tr_peerIoSetParent( tr_peerIo            * io,
-                                       struct tr_bandwidth  * parent )
+                                          struct tr_bandwidth  * parent )
 {
     assert( tr_isPeerIo( io ) );
 
@@ -340,11 +340,12 @@ void      tr_peerIoBandwidthUsed( tr_peerIo           * io,
                                   int                   isPieceData );
 
 static TR_INLINE tr_bool tr_peerIoHasBandwidthLeft( const tr_peerIo  * io,
-                                                 tr_direction       dir )
+                                                    tr_direction       dir )
 {
     assert( tr_isPeerIo( io ) );
 
-    return tr_bandwidthClamp( &io->bandwidth, dir, 1024 ) > 0;
+    return !io->hasFinishedConnecting
+        || ( tr_bandwidthClamp( &io->bandwidth, dir, 1024 ) > 0 );
 }
 
 static TR_INLINE double tr_peerIoGetPieceSpeed( const tr_peerIo * io, uint64_t now, tr_direction dir )