Changeset 10096
- Timestamp:
- Feb 5, 2010, 1:47:33 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/announcer.c
r10095 r10096 48 48 DEFAULT_ANNOUNCE_MIN_INTERVAL_SEC = ( 60 * 2 ), 49 49 50 /* how long to wait before a reannounce the first time we get an error */51 FIRST_ANNOUNCE_RETRY_INTERVAL_SEC = 30,52 53 /* how long to wait before a rescrape the first time we get an error */54 FIRST_SCRAPE_RETRY_INTERVAL_SEC = 120,55 56 50 /* the length of the 'key' argument passed in tracker requests */ 57 51 KEYLEN = 8, … … 110 104 /* the last time we sent an announce or scrape message */ 111 105 time_t lastRequestTime; 106 107 /* the last successful announce/scrape time for this host */ 108 time_t lastSuccessfulRequest; 112 109 } 113 110 tr_host; … … 376 373 int announceIntervalSec; 377 374 int announceMinIntervalSec; 378 int retryAnnounceIntervalSec;379 int retryScrapeIntervalSec;380 375 381 376 int lastAnnouncePeerCount; … … 432 427 tier->announceIntervalSec = DEFAULT_ANNOUNCE_INTERVAL_SEC; 433 428 tier->announceMinIntervalSec = DEFAULT_ANNOUNCE_MIN_INTERVAL_SEC; 434 tier->retryAnnounceIntervalSec = FIRST_ANNOUNCE_RETRY_INTERVAL_SEC;435 tier->retryScrapeIntervalSec = FIRST_SCRAPE_RETRY_INTERVAL_SEC;436 429 tier->isAnnouncing = FALSE; 437 430 tier->isScraping = FALSE; … … 974 967 975 968 static int 969 getRetryInterval( const tr_host * host ) 970 { 971 int interval; 972 const int jitter = tr_cryptoWeakRandInt( 120 ); 973 const time_t timeSinceLastSuccess = tr_time() - host->lastSuccessfulRequest; 974 if( timeSinceLastSuccess < 15*60 ) interval = 0; 975 else if( timeSinceLastSuccess < 30*60 ) interval = 60*4; 976 else if( timeSinceLastSuccess < 45*60 ) interval = 60*8; 977 else if( timeSinceLastSuccess < 60*60 ) interval = 60*16; 978 else interval = 60*32; 979 return interval + jitter; 980 } 981 982 static int 976 983 compareTiers( const void * va, const void * vb ) 977 984 { … … 1086 1093 success = TRUE; 1087 1094 1088 tier->retryAnnounceIntervalSec = FIRST_ANNOUNCE_RETRY_INTERVAL_SEC;1089 1090 1095 if( tr_bencDictFindStr( &benc, "failure reason", &str ) ) 1091 1096 { … … 1258 1263 if( responseCode == 0 ) 1259 1264 { 1260 const int interval = tr_cryptoWeakRandInt( 120);1265 const int interval = getRetryInterval( tier->currentTracker->host ); 1261 1266 dbgmsg( tier, "No response from tracker... retrying in %d seconds.", interval ); 1262 1267 tier->manualAnnounceAllowedAt = ~(time_t)0; … … 1306 1311 * incapable of performing the request. So we pause a bit and 1307 1312 * try again. */ 1313 const int interval = getRetryInterval( tier->currentTracker->host ); 1308 1314 tier->manualAnnounceAllowedAt = ~(time_t)0; 1309 tierSetNextAnnounce( tier, tier->announceEvent, now + tier->retryAnnounceIntervalSec ); 1310 tier->retryAnnounceIntervalSec *= 2; 1315 tierSetNextAnnounce( tier, tier->announceEvent, now + interval ); 1311 1316 } 1312 1317 else … … 1322 1327 1323 1328 if( success ) 1329 { 1324 1330 tier->isRunning = data->isRunningOnSuccess; 1331 1332 if( tier->currentTracker->host ) 1333 tier->currentTracker->host->lastSuccessfulRequest = now; 1334 } 1325 1335 1326 1336 if( !success ) … … 1435 1445 "Scrape successful. Rescraping in %d seconds.", 1436 1446 tier->scrapeIntervalSec ); 1437 1438 tier->retryScrapeIntervalSec = FIRST_SCRAPE_RETRY_INTERVAL_SEC;1439 1447 } 1440 1448 } … … 1504 1512 else 1505 1513 { 1506 const int interval = tier->retryScrapeIntervalSec; 1507 tier->retryScrapeIntervalSec *= 2; 1514 const int interval = getRetryInterval( tier->currentTracker->host ); 1508 1515 1509 1516 /* Don't retry on a 4xx. … … 1526 1533 1527 1534 tier->lastScrapeSucceeded = success; 1535 1536 if( success && tier->currentTracker->host ) 1537 tier->currentTracker->host->lastSuccessfulRequest = now; 1528 1538 } 1529 1539
Note: See TracChangeset
for help on using the changeset viewer.