fixes #234. properly shuts down the disk io thread

This commit is contained in:
Arvid Norberg 2007-12-24 08:15:10 +00:00
parent 44735a425f
commit e0d1951fac
4 changed files with 20 additions and 7 deletions

View File

@ -102,7 +102,9 @@ namespace libtorrent
int disk_allocations() const
{ return m_allocations; }
#endif
void join();
// aborts read operations
void stop(boost::intrusive_ptr<piece_manager> s);
void add_job(disk_io_job const& j

View File

@ -62,12 +62,7 @@ namespace libtorrent
disk_io_thread::~disk_io_thread()
{
mutex_t::scoped_lock l(m_mutex);
m_abort = true;
m_signal.notify_all();
l.unlock();
m_disk_io_thread.join();
TORRENT_ASSERT(m_abort == true);
}
#ifndef NDEBUG
@ -95,6 +90,16 @@ namespace libtorrent
#endif
void disk_io_thread::join()
{
mutex_t::scoped_lock l(m_mutex);
m_abort = true;
m_signal.notify_all();
l.unlock();
m_disk_io_thread.join();
}
// aborts read operations
void disk_io_thread::stop(boost::intrusive_ptr<piece_manager> s)
{

View File

@ -2195,6 +2195,11 @@ namespace detail
#endif
m_checker_thread->join();
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
(*m_logger) << time_now_string() << " waiting for disk io thread\n";
#endif
m_disk_thread.join();
TORRENT_ASSERT(m_torrents.empty());
TORRENT_ASSERT(m_connections.empty());
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)

View File

@ -130,6 +130,7 @@ void run_storage_tests(boost::intrusive_ptr<torrent_info> info
pm->async_read(r, bind(&on_read_piece, _1, _2, piece2, piece_size));
pm->async_release_files(none);
io.join();
}
}