From efc817926185106dd2b4c615627d10c66c715fa0 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Sun, 11 Nov 2007 20:55:48 +0000 Subject: [PATCH] cancels more async operations on shutdown --- libtorrent/include/libtorrent/proxy_base.hpp | 1 + libtorrent/src/kademlia/dht_tracker.cpp | 1 + libtorrent/src/torrent.cpp | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/libtorrent/include/libtorrent/proxy_base.hpp b/libtorrent/include/libtorrent/proxy_base.hpp index f2a955958..7ade2a0a9 100644 --- a/libtorrent/include/libtorrent/proxy_base.hpp +++ b/libtorrent/include/libtorrent/proxy_base.hpp @@ -128,6 +128,7 @@ public: void close(asio::error_code& ec) { m_sock.close(ec); + m_resolver.cancel(); } endpoint_type remote_endpoint() diff --git a/libtorrent/src/kademlia/dht_tracker.cpp b/libtorrent/src/kademlia/dht_tracker.cpp index b2981f7cd..f32db06d4 100644 --- a/libtorrent/src/kademlia/dht_tracker.cpp +++ b/libtorrent/src/kademlia/dht_tracker.cpp @@ -224,6 +224,7 @@ namespace libtorrent { namespace dht m_connection_timer.cancel(); m_refresh_timer.cancel(); m_socket.close(); + m_host_resolver.cancel(); } void dht_tracker::dht_status(session_status& s) diff --git a/libtorrent/src/torrent.cpp b/libtorrent/src/torrent.cpp index 84f30aa2d..b2dafb291 100755 --- a/libtorrent/src/torrent.cpp +++ b/libtorrent/src/torrent.cpp @@ -278,6 +278,7 @@ namespace libtorrent { boost::weak_ptr self(shared_from_this()); if (m_torrent_file->is_valid()) init(); + if (m_abort) return; m_announce_timer.expires_from_now(seconds(1)); m_announce_timer.async_wait(m_ses.m_strand.wrap( bind(&torrent::on_announce_disp, self, _1))); @@ -421,6 +422,8 @@ namespace libtorrent try #endif { + if (m_abort) return; + boost::weak_ptr self(shared_from_this()); if (!m_torrent_file->priv()) @@ -1060,6 +1063,7 @@ namespace libtorrent m_owning_storage = 0; m_announce_timer.cancel(); + m_host_resolver.cancel(); } void torrent::on_files_deleted(int ret, disk_io_job const& j) @@ -2206,6 +2210,7 @@ namespace libtorrent // only start the announce if we want to announce with the dht if (should_announce_dht()) { + if (m_abort) return; // force the DHT to reannounce m_last_dht_announce = time_now() - minutes(15); boost::weak_ptr self(shared_from_this());