From dc612b6423f09361f738429bd567bad582dedb78 Mon Sep 17 00:00:00 2001 From: Steven Siloti Date: Thu, 26 Oct 2017 11:07:37 -0700 Subject: [PATCH] keep updating aux::time_now() while there are announces This fixes an infinite loop when an announce during shutown fails and aux::time_now() has fallen behind clock_type::now() by more than the delay calculated in announce_entry::failed(). If this happens, announce_entry::can_announce() can forever return true when called from torrent::announce_with_tracker() because that function uses clock_type::now(). Also change torrent::announce_with_tracker() to use aux::time_now() just for consistency with the reset of the announce related functions. --- src/session_impl.cpp | 5 ++++- src/torrent.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index ab2ca1953..cea3ca98a 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -3052,10 +3052,13 @@ retry: // we have to keep ticking the utp socket manager // until they're all closed + // we also have to keep updating the aux time while + // there are outstanding announces if (m_abort) { if (m_utp_socket_manager.num_sockets() == 0 - && m_undead_peers.empty()) + && m_undead_peers.empty() + && m_tracker_manager.empty()) return; #if defined TORRENT_ASIO_DEBUGGING fprintf(stderr, "uTP sockets left: %d undead-peers left: %d\n" diff --git a/src/torrent.cpp b/src/torrent.cpp index 2319557f7..17f07dc45 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -3206,7 +3206,7 @@ namespace { req.num_want = (req.event == tracker_request::stopped) ? 0 : settings().get_int(settings_pack::num_want); - time_point now = clock_type::now(); + time_point now = aux::time_now(); // the tier is kept as INT_MAX until we find the first // tracker that works, then it's set to that tracker's