support forced shutdown/destruction of torrent objects
This commit is contained in:
parent
5f0c9a0c1d
commit
aae12250ae
|
@ -103,6 +103,8 @@ namespace libtorrent {
|
||||||
explicit peer_list(torrent_peer_allocator_interface& alloc);
|
explicit peer_list(torrent_peer_allocator_interface& alloc);
|
||||||
~peer_list();
|
~peer_list();
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
// not copyable
|
// not copyable
|
||||||
peer_list(peer_list const&) = delete;
|
peer_list(peer_list const&) = delete;
|
||||||
peer_list& operator=(peer_list const&) = delete;
|
peer_list& operator=(peer_list const&) = delete;
|
||||||
|
|
|
@ -448,6 +448,7 @@ namespace libtorrent {
|
||||||
// the necessary actions then.
|
// the necessary actions then.
|
||||||
void abort();
|
void abort();
|
||||||
bool is_aborted() const { return m_abort; }
|
bool is_aborted() const { return m_abort; }
|
||||||
|
void panic();
|
||||||
|
|
||||||
void new_external_ip();
|
void new_external_ip();
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ namespace libtorrent {
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
torrent_peer(torrent_peer const&) = default;
|
torrent_peer(torrent_peer const&) = default;
|
||||||
torrent_peer& operator=(torrent_peer const&) = default;
|
torrent_peer& operator=(torrent_peer const&) = default;
|
||||||
~torrent_peer() { in_use = false; }
|
~torrent_peer() { TORRENT_ASSERT(in_use); in_use = false; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::int64_t total_download() const;
|
std::int64_t total_download() const;
|
||||||
|
|
|
@ -125,6 +125,13 @@ namespace libtorrent {
|
||||||
thread_started();
|
thread_started();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void peer_list::clear()
|
||||||
|
{
|
||||||
|
for (auto const p : m_peers)
|
||||||
|
m_peer_allocator.free_peer_entry(p);
|
||||||
|
m_peers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
peer_list::~peer_list()
|
peer_list::~peer_list()
|
||||||
{
|
{
|
||||||
for (auto const p : m_peers)
|
for (auto const p : m_peers)
|
||||||
|
|
|
@ -6030,7 +6030,13 @@ namespace {
|
||||||
// TORRENT_ASSERT(is_not_thread());
|
// TORRENT_ASSERT(is_not_thread());
|
||||||
// TODO: asserts that no outstanding async operations are still in flight
|
// TODO: asserts that no outstanding async operations are still in flight
|
||||||
|
|
||||||
TORRENT_ASSERT(m_torrents.empty());
|
// this can happen if we end the io_service run loop with an exception
|
||||||
|
for (auto& t : m_torrents)
|
||||||
|
{
|
||||||
|
t.second->panic();
|
||||||
|
t.second->abort();
|
||||||
|
}
|
||||||
|
m_torrents.clear();
|
||||||
|
|
||||||
#if defined TORRENT_ASIO_DEBUGGING
|
#if defined TORRENT_ASIO_DEBUGGING
|
||||||
FILE* f = fopen("wakeups.log", "w+");
|
FILE* f = fopen("wakeups.log", "w+");
|
||||||
|
|
|
@ -4419,6 +4419,18 @@ namespace libtorrent {
|
||||||
m_state_subscription = false;
|
m_state_subscription = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this is called when we're destructing non-gracefully. i.e. we're _just_
|
||||||
|
// destructing everything.
|
||||||
|
void torrent::panic()
|
||||||
|
{
|
||||||
|
m_storage.reset();
|
||||||
|
// if there are any other peers allocated still, we need to clear them
|
||||||
|
// now. They can't be cleared later because the allocator will already
|
||||||
|
// have been destructed
|
||||||
|
if (m_peer_list) m_peer_list->clear();
|
||||||
|
m_connections.clear();
|
||||||
|
}
|
||||||
|
|
||||||
void torrent::set_super_seeding(bool on)
|
void torrent::set_super_seeding(bool on)
|
||||||
{
|
{
|
||||||
if (on == m_super_seeding) return;
|
if (on == m_super_seeding) return;
|
||||||
|
|
Loading…
Reference in New Issue