const int peerCount = tr_ptrArraySize( &t->peers );
const time_t now = tr_time( );
+ /* some cases where this function isn't necessary */
+ if( tr_torrentIsSeed( t->tor ) )
+ return;
+ if ( tr_torrentIsPieceTransferAllowed( t->tor, TR_PEER_TO_CLIENT ) )
+ return;
+
/* decide HOW MANY peers to be interested in */
{
int blocks = 0;
while(( tor = tr_torrentNext( mgr->session, tor ))) {
if( tor->isRunning ) {
Torrent * t = tor->torrentPeers;
- if( tr_ptrArrayEmpty( &t->peers ) )
- continue;
- rechokeUploads( t, now );
- if( !tr_torrentIsSeed( tor ) && tr_torrentIsPieceTransferAllowed( tor, TR_PEER_TO_CLIENT ) )
+ if( !tr_ptrArrayEmpty( &t->peers ) ) {
+ rechokeUploads( t, now );
rechokeDownloads( t );
+ }
}
}
tr_torrentSetIdleLimit( tor, tr_sessionGetIdleLimit( tor->session ) );
}
- {
- tr_torrent * it = NULL;
- tr_torrent * last = NULL;
- while( ( it = tr_torrentNext( session, it ) ) )
- last = it;
-
- if( !last )
- session->torrentList = tor;
- else
- last->next = tor;
- ++session->torrentCount;
- }
+ /* add the torrent to tr_session.torrentList */
+ tor->next = session->torrentList;
+ session->torrentList = tor;
+ ++session->torrentCount;
/* if we don't have a local .torrent file already, assume the torrent is new */
isNewTorrent = stat( tor->info.torrent, &st );