fix force-reannounce and tracker retry issue

This commit is contained in:
Arvid Norberg 2010-07-15 05:16:06 +00:00
parent 21e2894a4d
commit aa25ed00c6
4 changed files with 20 additions and 8 deletions

View File

@ -36,6 +36,8 @@
incoming connection
* added more detailed instrumentation of the disk I/O thread
* fix force-reannounce and tracker retry issue
0.15.1 release
* fixed rare crash when purging the peer list

View File

@ -1469,11 +1469,12 @@ int main(int argc, char* argv[])
for (std::vector<announce_entry>::iterator i = tr.begin()
, end(tr.end()); i != end; ++i)
{
snprintf(str, sizeof(str), "%2d %-55s fails: %-3d (%-3d) %s %s \"%s\" %s\n"
snprintf(str, sizeof(str), "%2d %-55s fails: %-3d (%-3d) %s %s %5d \"%s\" %s\n"
, i->tier, i->url.c_str(), i->fails, i->fail_limit, i->verified?"OK ":"- "
, i->updating?"updating"
:!i->will_announce(now)?""
:to_string(total_seconds(i->next_announce - now), 8).c_str()
, i->min_announce > now ? total_seconds(i->min_announce - now) : 0
, i->last_error ? i->last_error.message().c_str() : ""
, i->message.c_str());
out += str;

View File

@ -75,6 +75,8 @@ namespace libtorrent
{
announce_entry(std::string const& u)
: url(u)
, next_announce(min_time())
, min_announce(min_time())
, tier(0)
, fail_limit(3)
, fails(0)

View File

@ -1732,7 +1732,7 @@ namespace libtorrent
void torrent::force_tracker_request()
{
if (is_paused()) return;
ptime now = time_now();
ptime now = time_now_hires();
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);
@ -1745,7 +1745,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(time_now());
update_tracker_timer(time_now_hires());
}
void torrent::set_tracker_login(
@ -5536,18 +5536,25 @@ namespace libtorrent
&& !settings().announce_to_all_tiers) break;
}
if (next_announce == max_time()
|| next_announce <= now) return;
if (next_announce == max_time()) return;
m_waiting_tracker = true;
error_code ec;
boost::weak_ptr<torrent> self(shared_from_this());
if (next_announce <= now)
{
// no need to post this via asio, just call directly
on_tracker_announce_disp(self, ec);
return;
}
// since we don't know if we have to re-issue the async_wait or not
// always do it
// if (m_tracker_timer.expires_at() <= next_announce) return;
error_code ec;
boost::weak_ptr<torrent> self(shared_from_this());
m_tracker_timer.expires_at(next_announce, ec);
m_tracker_timer.async_wait(boost::bind(&torrent::on_tracker_announce_disp, self, _1));
m_waiting_tracker = true;
}
void torrent::start_announcing()