another attempt to fix tracker timer bug. Fixes issue where the tracker timer would be triggered repeatedly. Fixes bug where trackers loaded from resume data would get a fail limit of 3 (now they don't have a limit)

This commit is contained in:
Arvid Norberg 2010-05-03 08:24:30 +00:00
parent 5d8feafc11
commit feaf4aa082
2 changed files with 14 additions and 10 deletions

View File

@ -809,7 +809,7 @@ namespace libtorrent
void parse_response(const entry& e, std::vector<peer_entry>& peer_list);
void update_tracker_timer();
void update_tracker_timer(ptime now);
static void on_tracker_announce_disp(boost::weak_ptr<torrent> p
, error_code const& e);

View File

@ -1404,7 +1404,7 @@ namespace libtorrent
req.listen_port = m_ses.listen_port();
req.key = m_ses.m_key;
ptime now = time_now();
ptime now = time_now_hires();
// the tier is kept as INT_MAX until we find the first
// tracker that works, then it's set to that tracker's
@ -1460,7 +1460,7 @@ namespace libtorrent
if ((protocol == "http" || protocol == "https")
&& proxy_type == proxy_settings::none)
{
ae.next_announce = now + minutes(10);
if (m_ses.m_alerts.should_post<anonymous_mode_alert>())
{
m_ses.m_alerts.post_alert(
@ -1475,6 +1475,7 @@ namespace libtorrent
&& proxy_type != proxy_settings::socks5_pw
&& proxy_type != proxy_settings::i2p_proxy))
{
ae.next_announce = now + minutes(10);
if (m_ses.m_alerts.should_post<anonymous_mode_alert>())
{
m_ses.m_alerts.post_alert(
@ -1513,7 +1514,7 @@ namespace libtorrent
&& !settings().announce_to_all_tiers)
break;
}
update_tracker_timer();
update_tracker_timer(now);
}
void torrent::scrape_tracker()
@ -1601,7 +1602,7 @@ namespace libtorrent
int tracker_index = ae - &m_trackers[0];
m_last_working_tracker = prioritize_tracker(tracker_index);
}
update_tracker_timer();
update_tracker_timer(now);
if (complete >= 0) m_complete = complete;
if (incomplete >= 0) m_incomplete = incomplete;
@ -1732,7 +1733,7 @@ namespace libtorrent
for (std::vector<announce_entry>::iterator i = m_trackers.begin()
, end(m_trackers.end()); i != end; ++i)
i->next_announce = (std::max)(now, i->min_announce);
update_tracker_timer();
update_tracker_timer(now);
}
void torrent::force_tracker_request(ptime t)
@ -1741,7 +1742,7 @@ namespace libtorrent
for (std::vector<announce_entry>::iterator i = m_trackers.begin()
, end(m_trackers.end()); i != end; ++i)
i->next_announce = (std::max)(t, i->min_announce);
update_tracker_timer();
update_tracker_timer(time_now());
}
void torrent::set_tracker_login(
@ -3740,6 +3741,7 @@ namespace libtorrent
, boost::bind(&announce_entry::url, _1) == e.url) != m_trackers.end())
continue;
e.tier = tier;
e.fail_limit = 0;
m_trackers.push_back(e);
}
++tier;
@ -5456,7 +5458,7 @@ namespace libtorrent
start_announcing();
}
void torrent::update_tracker_timer()
void torrent::update_tracker_timer(ptime now)
{
if (!m_announcing) return;
@ -5487,7 +5489,9 @@ namespace libtorrent
if (!settings().announce_to_all_trackers
&& !settings().announce_to_all_tiers) break;
}
if (next_announce == max_time()) return;
if (next_announce == max_time()
|| next_announce <= now) return;
// since we don't know if we have to re-issue the async_wait or not
// always do it
@ -6489,7 +6493,7 @@ namespace libtorrent
m_ses.m_alerts.post_alert(scrape_failed_alert(get_handle(), r.url, ec));
}
}
update_tracker_timer();
update_tracker_timer(time_now());
}