mirror of
https://github.com/transmission/transmission
synced 2024-12-27 01:57:52 +00:00
(libT) if a tracker announce succeeds and the tracker's response is a superset of a scrape response, then treat it as a successful announce AND scrape.
This commit is contained in:
parent
2f3580cc90
commit
26cac56509
2 changed files with 27 additions and 4 deletions
|
@ -347,6 +347,7 @@ onTrackerResponse( tr_session * session,
|
||||||
{
|
{
|
||||||
int retry;
|
int retry;
|
||||||
int success = FALSE;
|
int success = FALSE;
|
||||||
|
int scrapeFields = 0;
|
||||||
tr_tracker * t;
|
tr_tracker * t;
|
||||||
|
|
||||||
onReqDone( session );
|
onReqDone( session );
|
||||||
|
@ -400,13 +401,22 @@ onTrackerResponse( tr_session * session,
|
||||||
t->trackerID = tr_strdup( str );
|
t->trackerID = tr_strdup( str );
|
||||||
|
|
||||||
if( ( tr_bencDictFindInt( &benc, "complete", &i ) ) )
|
if( ( tr_bencDictFindInt( &benc, "complete", &i ) ) )
|
||||||
|
{
|
||||||
|
++scrapeFields;
|
||||||
t->seederCount = i;
|
t->seederCount = i;
|
||||||
|
}
|
||||||
|
|
||||||
if( ( tr_bencDictFindInt( &benc, "incomplete", &i ) ) )
|
if( ( tr_bencDictFindInt( &benc, "incomplete", &i ) ) )
|
||||||
|
{
|
||||||
|
++scrapeFields;
|
||||||
t->leecherCount = incomplete = i;
|
t->leecherCount = incomplete = i;
|
||||||
|
}
|
||||||
|
|
||||||
if( ( tr_bencDictFindInt( &benc, "downloaded", &i ) ) )
|
if( ( tr_bencDictFindInt( &benc, "downloaded", &i ) ) )
|
||||||
|
{
|
||||||
|
++scrapeFields;
|
||||||
t->timesDownloaded = i;
|
t->timesDownloaded = i;
|
||||||
|
}
|
||||||
|
|
||||||
if( ( tmp = tr_bencDictFind( &benc, "peers" ) ) )
|
if( ( tmp = tr_bencDictFind( &benc, "peers" ) ) )
|
||||||
{
|
{
|
||||||
|
@ -446,8 +456,21 @@ onTrackerResponse( tr_session * session,
|
||||||
const time_t now = time ( NULL );
|
const time_t now = time ( NULL );
|
||||||
dbgmsg( t->name, "request succeeded. reannouncing in %d seconds",
|
dbgmsg( t->name, "request succeeded. reannouncing in %d seconds",
|
||||||
interval );
|
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;
|
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->reannounceAt = now + interval;
|
||||||
t->manualAnnounceAllowedAt = now + t->announceMinIntervalSec;
|
t->manualAnnounceAllowedAt = now + t->announceMinIntervalSec;
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,7 @@ event_cb( int fd, short kind, void * vg )
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
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 );
|
rc = curl_multi_socket_action( g->multi, fd, mask, &g->still_running );
|
||||||
} while( rc == CURLM_CALL_MULTI_PERFORM );
|
} while( rc == CURLM_CALL_MULTI_PERFORM );
|
||||||
if( rc != CURLM_OK )
|
if( rc != CURLM_OK )
|
||||||
|
|
Loading…
Reference in a new issue