added shutdown logging and tracker manager shutdown flag
This commit is contained in:
parent
cbd67ed729
commit
883773e8fa
|
@ -224,7 +224,8 @@ namespace libtorrent
|
|||
|
||||
tracker_manager(session_settings const& s, proxy_settings const& ps)
|
||||
: m_settings(s)
|
||||
, m_proxy(ps) {}
|
||||
, m_proxy(ps)
|
||||
, m_abort(false) {}
|
||||
|
||||
void queue_request(
|
||||
asio::strand& str
|
||||
|
@ -249,6 +250,7 @@ namespace libtorrent
|
|||
tracker_connections_t m_connections;
|
||||
session_settings const& m_settings;
|
||||
proxy_settings const& m_proxy;
|
||||
bool m_abort;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1075,9 +1075,18 @@ namespace libtorrent { namespace detail
|
|||
m_natpmp.close();
|
||||
m_upnp.close();
|
||||
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << time_now_string() << " locking mutex\n";
|
||||
#endif
|
||||
session_impl::mutex_t::scoped_lock l(m_mutex);
|
||||
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << time_now_string() << " aborting all tracker requests\n";
|
||||
#endif
|
||||
m_tracker_manager.abort_all_requests();
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << time_now_string() << " sending stopped to all torrent's trackers\n";
|
||||
#endif
|
||||
for (std::map<sha1_hash, boost::shared_ptr<torrent> >::iterator i =
|
||||
m_torrents.begin(); i != m_torrents.end(); ++i)
|
||||
{
|
||||
|
@ -1109,6 +1118,10 @@ namespace libtorrent { namespace detail
|
|||
ptime start(time_now());
|
||||
l.unlock();
|
||||
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << time_now_string() << " waiting for trackers to respond\n";
|
||||
#endif
|
||||
|
||||
while (time_now() - start < seconds(
|
||||
m_settings.stop_tracker_timeout)
|
||||
&& !m_tracker_manager.empty())
|
||||
|
@ -1121,10 +1134,17 @@ namespace libtorrent { namespace detail
|
|||
m_io_service.run();
|
||||
}
|
||||
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << time_now_string() << " tracker shutdown complete, locking mutex\n";
|
||||
#endif
|
||||
|
||||
l.lock();
|
||||
assert(m_abort);
|
||||
m_abort = true;
|
||||
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << time_now_string() << " cleaning up connections\n";
|
||||
#endif
|
||||
while (!m_connections.empty())
|
||||
m_connections.begin()->second->disconnect();
|
||||
|
||||
|
@ -1136,6 +1156,9 @@ namespace libtorrent { namespace detail
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||
(*m_logger) << time_now_string() << " cleaning up torrents\n";
|
||||
#endif
|
||||
m_torrents.clear();
|
||||
|
||||
assert(m_torrents.empty());
|
||||
|
|
|
@ -507,6 +507,10 @@ namespace libtorrent
|
|||
if (req.event == tracker_request::stopped)
|
||||
req.num_want = 0;
|
||||
|
||||
assert(!m_abort || req.event == tracker_request::stopped);
|
||||
if (m_abort && req.event != tracker_request::stopped)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
std::string protocol;
|
||||
|
@ -572,6 +576,7 @@ namespace libtorrent
|
|||
// 'event=stopped'-requests)
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
|
||||
m_abort = true;
|
||||
tracker_connections_t keep_connections;
|
||||
|
||||
for (tracker_connections_t::const_iterator i =
|
||||
|
|
Loading…
Reference in New Issue