diff --git a/ChangeLog b/ChangeLog index 246c4b9b1..536f07875 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 16ca55282..e4464c61b 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1469,11 +1469,12 @@ int main(int argc, char* argv[]) for (std::vector::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; diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index f7fc751bb..b00d4034d 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -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) diff --git a/src/torrent.cpp b/src/torrent.cpp index 4304689cf..6888ceca7 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -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::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::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 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 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()