]> granicus.if.org Git - transmission/commitdiff
(trunk libT) closeBadPeers() part 1 of 2: don't bother sorting these peers by activit...
authorJordan Lee <jordan@transmissionbt.com>
Sat, 19 Feb 2011 12:24:00 +0000 (12:24 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Sat, 19 Feb 2011 12:24:00 +0000 (12:24 +0000)
libtransmission/peer-mgr.c

index 27d24385321b307cc27c89f2e3a60b7445a73dd9..19e7c668be14c3b1c7836aa915261e4bbb0a3ead 100644 (file)
@@ -3161,11 +3161,9 @@ shouldPeerBeClosed( const Torrent    * t,
     return TR_CAN_KEEP;
 }
 
-static void sortPeersByLivelinessReverse( tr_peer ** peers, void ** clientData, int n, uint64_t now );
-
 static tr_peer **
 getPeersToClose( Torrent * t, tr_close_type_t closeType,
-                 const uint64_t now_msec, const time_t now_sec,
+                 const time_t now_sec,
                  int * setmeSize )
 {
     int i, peerCount, outsize;
@@ -3178,8 +3176,6 @@ getPeersToClose( Torrent * t, tr_close_type_t closeType,
         if( shouldPeerBeClosed( t, peers[i], peerCount, now_sec ) == closeType )
             ret[outsize++] = peers[i];
 
-    sortPeersByLivelinessReverse ( ret, NULL, outsize, now_msec );
-
     *setmeSize = outsize;
     return ret;
 }
@@ -3272,7 +3268,7 @@ removeAllPeers( Torrent * t )
 }
 
 static void
-closeBadPeers( Torrent * t, const uint64_t now_msec, const time_t now_sec )
+closeBadPeers( Torrent * t, const time_t now_sec )
 {
     if( !t->isRunning )
     {
@@ -3285,7 +3281,7 @@ closeBadPeers( Torrent * t, const uint64_t now_msec, const time_t now_sec )
         struct tr_peer ** mustClose;
 
         /* disconnect the really bad peers */
-        mustClose = getPeersToClose( t, TR_MUST_CLOSE, now_msec, now_sec, &mustCloseCount );
+        mustClose = getPeersToClose( t, TR_MUST_CLOSE, now_sec, &mustCloseCount );
         for( i=0; i<mustCloseCount; ++i )
             closePeer( t, mustClose[i] );
         tr_free( mustClose );
@@ -3325,12 +3321,6 @@ comparePeerLiveliness( const void * va, const void * vb )
     return 0;
 }
 
-static int
-comparePeerLivelinessReverse( const void * va, const void * vb )
-{
-    return -comparePeerLiveliness (va, vb);
-}
-
 static void
 sortPeersByLivelinessImpl( tr_peer  ** peers,
                            void     ** clientData,
@@ -3378,12 +3368,6 @@ sortPeersByLiveliness( tr_peer ** peers, void ** clientData, int n, uint64_t now
     sortPeersByLivelinessImpl( peers, clientData, n, now, comparePeerLiveliness );
 }
 
-static void
-sortPeersByLivelinessReverse( tr_peer ** peers, void ** clientData, int n, uint64_t now )
-{
-    sortPeersByLivelinessImpl( peers, clientData, n, now, comparePeerLivelinessReverse );
-}
-
 
 static void
 enforceTorrentPeerLimit( Torrent * t, uint64_t now )
@@ -3470,7 +3454,7 @@ reconnectPulse( int foo UNUSED, short bar UNUSED, void * vmgr )
     /* remove crappy peers */
     tor = NULL;
     while(( tor = tr_torrentNext( mgr->session, tor )))
-        closeBadPeers( tor->torrentPeers, now_msec, now_sec );
+        closeBadPeers( tor->torrentPeers, now_sec );
 
     /* try to make new peer connections */
     makeNewPeerConnections( mgr, MAX_CONNECTIONS_PER_PULSE );