fix storage destruction order issue (#2138)

back-ported from b553cb32f7
This commit is contained in:
d-komarov 2017-07-11 07:35:34 +03:00 committed by Arvid Norberg
parent 5188c190db
commit 11d6a00bec
2 changed files with 14 additions and 4 deletions

View File

@ -1168,6 +1168,10 @@ namespace libtorrent
void on_file_renamed(disk_io_job const* j);
void on_cache_flushed(disk_io_job const* j);
// this is used when a torrent is being removed.It synchronizes with the
// disk thread
void on_torrent_aborted();
// upload and download rate limits for the torrent
void set_limit_impl(int limit, int channel, bool state_update = true);
int limit_impl(int channel) const;

View File

@ -5003,9 +5003,8 @@ namespace libtorrent
// the torrent object from there
if (m_storage.get())
{
inc_refcount("release_files");
m_ses.disk_thread().async_stop_torrent(m_storage.get()
, boost::bind(&torrent::on_cache_flushed, shared_from_this(), _1));
, boost::bind(&torrent::on_torrent_aborted, shared_from_this()));
}
else
{
@ -5014,8 +5013,6 @@ namespace libtorrent
alerts().emplace_alert<cache_flushed_alert>(get_handle());
}
m_storage.reset();
// TODO: 2 abort lookups this torrent has made via the
// session host resolver interface
@ -9821,6 +9818,15 @@ namespace libtorrent
alerts().emplace_alert<cache_flushed_alert>(get_handle());
}
void torrent::on_torrent_aborted()
{
TORRENT_ASSERT(is_single_thread());
// there should be no more disk activity for this torrent now, we can
// release the disk io handle
m_storage.reset();
}
bool torrent::is_paused() const
{
return !m_allow_peers || m_ses.is_paused() || m_graceful_pause_mode;