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