From f945058de0a2e9848b7bf3ba28857d505edecfbd Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 13 Jan 2009 16:51:38 +0000 Subject: [PATCH] (trunk libT) minor torrent iteration cleanup. (wereHamster, charles) --- libtransmission/port-forwarding.c | 15 ++------------- libtransmission/tracker.c | 5 +++-- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/libtransmission/port-forwarding.c b/libtransmission/port-forwarding.c index 459424d1b..e014e120d 100644 --- a/libtransmission/port-forwarding.c +++ b/libtransmission/port-forwarding.c @@ -165,8 +165,7 @@ bindCb( int * const socket, static void incomingPeersPulse( tr_shared * s ) { - int allPaused; - tr_torrent * tor; + tr_bool allPaused; if( s->shouldChange ) { @@ -176,17 +175,7 @@ incomingPeersPulse( tr_shared * s ) tr_socketListForEach( s->bindSockets, &bindCb, s ); } - /* see if any torrents aren't paused */ - allPaused = 1; - tor = NULL; - while( ( tor = tr_torrentNext( s->session, tor ) ) ) - { - if( TR_STATUS_IS_ACTIVE( tr_torrentGetActivity( tor ) ) ) - { - allPaused = 0; - break; - } - } + allPaused = tr_sessionGetActiveTorrentCount( s->session ) == 0; /* if we have any running torrents, check for new incoming peer connections */ /* (jhujhiti): diff --git a/libtransmission/tracker.c b/libtransmission/tracker.c index dfc4a13a5..e81af9181 100644 --- a/libtransmission/tracker.c +++ b/libtransmission/tracker.c @@ -936,7 +936,8 @@ trackerPulse( void * vsession ) dbgmsg( NULL, "tracker pulse... %d running", th->runningCount ); /* upkeep: queue periodic rescrape / reannounce */ - for( tor = session->torrentList; tor; tor = tor->next ) + tor = NULL; + while(( tor = tr_torrentNext( session, tor ))) { tr_tracker * t = tor->tracker; @@ -965,7 +966,7 @@ trackerPulse( void * vsession ) /* free the tracker manager if no torrents are left */ if( ( session->tracker ) && ( session->tracker->runningCount < 1 ) - && ( session->torrentList == NULL ) ) + && ( tr_sessionCountTorrents( session ) == 0 ) ) { tr_trackerSessionClose( session ); }