diff --git a/libtransmission/tracker.c b/libtransmission/tracker.c index b37f872d8..791dfcd8c 100644 --- a/libtransmission/tracker.c +++ b/libtransmission/tracker.c @@ -345,8 +345,9 @@ onTrackerResponse( tr_session * session, size_t responseLen, void * torrent_hash ) { - int retry; - int success = FALSE; + int retry; + int success = FALSE; + int scrapeFields = 0; tr_tracker * t; onReqDone( session ); @@ -400,13 +401,22 @@ onTrackerResponse( tr_session * session, t->trackerID = tr_strdup( str ); if( ( tr_bencDictFindInt( &benc, "complete", &i ) ) ) + { + ++scrapeFields; t->seederCount = i; + } if( ( tr_bencDictFindInt( &benc, "incomplete", &i ) ) ) + { + ++scrapeFields; t->leecherCount = incomplete = i; + } if( ( tr_bencDictFindInt( &benc, "downloaded", &i ) ) ) + { + ++scrapeFields; t->timesDownloaded = i; + } if( ( tmp = tr_bencDictFind( &benc, "peers" ) ) ) { @@ -446,8 +456,21 @@ onTrackerResponse( tr_session * session, const time_t now = time ( NULL ); dbgmsg( t->name, "request succeeded. reannouncing in %d seconds", interval ); - if( t->scrapeAt <= now ) + + /* if the announce response was a superset of the scrape response, + treat this as both a successful announce AND scrape. */ + if( scrapeFields >= 3 ) { + t->lastScrapeResponse = responseCode; + t->lastScrapeTime = now; t->scrapeAt = now + t->scrapeIntervalSec + t->randOffset; + } + + /* most trackers don't provide all the scrape responses, but do + provide most of them, so don't scrape too soon anyway */ + if( ( scrapeFields == 2 ) && ( t->scrapeAt <= ( now + 120 ) ) ) { + t->scrapeAt = now + t->scrapeIntervalSec + t->randOffset; + } + t->reannounceAt = now + interval; t->manualAnnounceAllowedAt = now + t->announceMinIntervalSec; diff --git a/libtransmission/web.c b/libtransmission/web.c index e24bc6433..131ae8d2f 100644 --- a/libtransmission/web.c +++ b/libtransmission/web.c @@ -230,7 +230,7 @@ event_cb( int fd, short kind, void * vg ) } do { - dbgmsg( stderr, "event_cb calling socket_action fd %d, mask %d", fd, mask ); + dbgmsg( "event_cb calling socket_action fd %d, mask %d", fd, mask ); rc = curl_multi_socket_action( g->multi, fd, mask, &g->still_running ); } while( rc == CURLM_CALL_MULTI_PERFORM ); if( rc != CURLM_OK )