forked from premiere/premiere-libtorrent
retry failed trackers a little bit sooner. make the exponential back-off not quite grow as fast
This commit is contained in:
parent
6fcc469aef
commit
4d60adcaa9
|
@ -1,3 +1,4 @@
|
|||
* lower the default tracker retry intervals
|
||||
* support banning web seeds sending corrupt data
|
||||
* don't let hung outgoing connection attempts block incoming connections
|
||||
* improve SSL torrent support by using SNI and a single SSL listen socket
|
||||
|
|
|
@ -66,8 +66,8 @@ namespace libtorrent
|
|||
|
||||
enum
|
||||
{
|
||||
// wait 60 seconds before retrying a failed tracker
|
||||
tracker_retry_delay_min = 10
|
||||
// wait at least 5 seconds before retrying a failed tracker
|
||||
tracker_retry_delay_min = 5
|
||||
// when tracker_failed_max trackers
|
||||
// has failed, wait 60 minutes instead
|
||||
, tracker_retry_delay_max = 60 * 60
|
||||
|
|
|
@ -386,8 +386,8 @@ namespace libtorrent
|
|||
boost::shared_ptr<request_callback> cb = requester();
|
||||
if (!cb) return;
|
||||
|
||||
int interval = int(e.dict_find_int_value("interval", 1800));
|
||||
int min_interval = int(e.dict_find_int_value("min interval", 60));
|
||||
int interval = int(e.dict_find_int_value("interval", 0));
|
||||
int min_interval = int(e.dict_find_int_value("min interval", 30));
|
||||
|
||||
std::string trackerid;
|
||||
lazy_entry const* tracker_id = e.dict_find_string("tracker id");
|
||||
|
@ -427,6 +427,10 @@ namespace libtorrent
|
|||
, interval, min_interval);
|
||||
return;
|
||||
}
|
||||
|
||||
// if no interval is specified, default to 30 minutes
|
||||
if (interval == 0) interval == 1800;
|
||||
|
||||
int complete = int(scrape_data->dict_find_int_value("complete", -1));
|
||||
int incomplete = int(scrape_data->dict_find_int_value("incomplete", -1));
|
||||
int downloaded = int(scrape_data->dict_find_int_value("downloaded", -1));
|
||||
|
|
|
@ -473,8 +473,10 @@ namespace libtorrent
|
|||
void announce_entry::failed(int retry_interval)
|
||||
{
|
||||
++fails;
|
||||
// the exponential back-off ends up being:
|
||||
// 7, 15, 27, 45, 95, 127, 165, ... seconds
|
||||
int delay = (std::min)(tracker_retry_delay_min + int(fails) * int(fails)
|
||||
* tracker_retry_delay_min, int(tracker_retry_delay_max));
|
||||
* tracker_retry_delay_min / 2, int(tracker_retry_delay_max));
|
||||
delay = (std::max)(delay, retry_interval);
|
||||
next_announce = time_now() + seconds(delay);
|
||||
updating = false;
|
||||
|
|
|
@ -396,6 +396,20 @@ int test_main()
|
|||
error_code ec;
|
||||
int ret = 0;
|
||||
|
||||
// make sure the retry interval keeps growing
|
||||
// on failing announces
|
||||
announce_entry ae("dummy");
|
||||
int last = 0;
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
ae.failed(5);
|
||||
int delay = ae.next_announce_in();
|
||||
TEST_CHECK(delay > last);
|
||||
last = delay;
|
||||
fprintf(stderr, "%d, ", delay);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
#if defined TORRENT_USE_OPENSSL
|
||||
// test sign_rsa and verify_rsa
|
||||
char private_key[1192];
|
||||
|
|
Loading…
Reference in New Issue