fixed issue with disk read cache not being cleared when removing torrents

This commit is contained in:
Arvid Norberg 2010-02-21 08:52:26 +00:00
parent 17750035ea
commit 59deff7a44
4 changed files with 32 additions and 2 deletions

View File

@ -105,6 +105,7 @@
* added info_hash to torrent_deleted_alert
* improved LSD performance and made the interval configurable
* improved UDP tracker support by caching connect tokens
* fixed issue with disk read cache not being cleared when removing torrents
release 0.14.9

View File

@ -763,6 +763,7 @@ namespace libtorrent
void on_files_deleted(int ret, disk_io_job const& j);
void on_files_released(int ret, disk_io_job const& j);
void on_torrent_aborted(int ret, disk_io_job const& j);
void on_torrent_paused(int ret, disk_io_job const& j);
void on_storage_moved(int ret, disk_io_job const& j);
void on_save_resume_data(int ret, disk_io_job const& j);

View File

@ -1650,6 +1650,25 @@ namespace libtorrent
post_callback(i->second.callback, i->second, -3);
sorted_read_jobs.erase(i++);
}
jl.unlock();
mutex_t::scoped_lock l(m_piece_mutex);
for (cache_t::iterator i = m_read_pieces.begin();
i != m_read_pieces.end();)
{
if (i->storage == j.storage)
{
free_piece(*i, l);
i = m_read_pieces.erase(i);
}
else
{
++i;
}
}
l.unlock();
release_memory();
break;
}
case disk_io_job::abort_thread:

View File

@ -2391,11 +2391,14 @@ namespace libtorrent
// disconnect all peers and close all
// files belonging to the torrents
disconnect_all(errors::torrent_aborted);
// post a message to the main thread to destruct
// the torrent object from there
if (m_owning_storage.get())
{
m_storage->async_release_files(
bind(&torrent::on_files_released, shared_from_this(), _1, _2));
m_storage->abort_disk_io();
m_storage->async_release_files(
boost::bind(&torrent::on_torrent_aborted, shared_from_this(), _1, _2));
}
dequeue_torrent_check();
@ -2503,6 +2506,12 @@ namespace libtorrent
*/
}
void torrent::on_torrent_aborted(int ret, disk_io_job const& j)
{
// the torrent should be completely shut down now, and the
// destructor has to be called from the main thread
}
void torrent::on_save_resume_data(int ret, disk_io_job const& j)
{
mutex::scoped_lock l(m_ses.m_mutex);