From 60f9191fdc053a148803d4e4a559c4b20366f261 Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Sun, 31 Jul 2011 00:58:05 +0000 Subject: [PATCH] (trunk libT) modify announcer's scrape triggers as per discussion with Elbandi --- libtransmission/announcer.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/libtransmission/announcer.c b/libtransmission/announcer.c index aacb6a5fc..241514fd9 100644 --- a/libtransmission/announcer.c +++ b/libtransmission/announcer.c @@ -1072,6 +1072,7 @@ on_announce_done( const tr_announce_response * response, { int i; const char * str; + bool got_scrape_info = false; const bool isStopped = event == TR_ANNOUNCE_EVENT_STOPPED; publishErrorClear( tier ); @@ -1079,9 +1080,20 @@ on_announce_done( const tr_announce_response * response, if(( tracker = tier->currentTracker )) { tracker->consecutiveFailures = 0; - tracker->seederCount = response->seeders; - tracker->leecherCount = response->leechers; - tracker->downloadCount = response->downloads; + + /* if the tracker included scrape fields in its announce response, + then a separate scrape isn't needed */ + + got_scrape_info = response->seeders + || response->leechers + || response->downloads; + + if( got_scrape_info ) + { + tracker->seederCount = response->seeders; + tracker->leecherCount = response->leechers; + tracker->downloadCount = response->downloads; + } if(( str = response->tracker_id_str )) { @@ -1117,9 +1129,18 @@ on_announce_done( const tr_announce_response * response, sizeof( tier->lastAnnounceStr ) ); tier->isRunning = data->isRunningOnSuccess; - tier->scrapeAt = get_next_scrape_time( announcer->session, tier, tier->scrapeIntervalSec ); - tier->lastScrapeTime = now; - tier->lastScrapeSucceeded = true; + + if( got_scrape_info ) + { + tier->scrapeAt = get_next_scrape_time( announcer->session, tier, tier->scrapeIntervalSec ); + tier->lastScrapeTime = now; + tier->lastScrapeSucceeded = true; + } + else if( tier->lastScrapeTime + tier->scrapeIntervalSec <= now ) + { + tier->scrapeAt = get_next_scrape_time( announcer->session, tier, 0 ); + } + tier->lastAnnounceSucceeded = true; tier->lastAnnouncePeerCount = response->pex_count + response->pex6_count;