fixes #234. properly shuts down the disk io thread
This commit is contained in:
@@ -103,6 +103,8 @@ namespace libtorrent
|
|||||||
{ return m_allocations; }
|
{ return m_allocations; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void join();
|
||||||
|
|
||||||
// aborts read operations
|
// aborts read operations
|
||||||
void stop(boost::intrusive_ptr<piece_manager> s);
|
void stop(boost::intrusive_ptr<piece_manager> s);
|
||||||
void add_job(disk_io_job const& j
|
void add_job(disk_io_job const& j
|
||||||
|
@@ -62,12 +62,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
disk_io_thread::~disk_io_thread()
|
disk_io_thread::~disk_io_thread()
|
||||||
{
|
{
|
||||||
mutex_t::scoped_lock l(m_mutex);
|
TORRENT_ASSERT(m_abort == true);
|
||||||
m_abort = true;
|
|
||||||
m_signal.notify_all();
|
|
||||||
l.unlock();
|
|
||||||
|
|
||||||
m_disk_io_thread.join();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@@ -95,6 +90,16 @@ namespace libtorrent
|
|||||||
|
|
||||||
#endif
|
#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
|
// aborts read operations
|
||||||
void disk_io_thread::stop(boost::intrusive_ptr<piece_manager> s)
|
void disk_io_thread::stop(boost::intrusive_ptr<piece_manager> s)
|
||||||
{
|
{
|
||||||
|
@@ -2195,6 +2195,11 @@ namespace detail
|
|||||||
#endif
|
#endif
|
||||||
m_checker_thread->join();
|
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_torrents.empty());
|
||||||
TORRENT_ASSERT(m_connections.empty());
|
TORRENT_ASSERT(m_connections.empty());
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
||||||
|
@@ -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_read(r, bind(&on_read_piece, _1, _2, piece2, piece_size));
|
||||||
pm->async_release_files(none);
|
pm->async_release_files(none);
|
||||||
|
|
||||||
|
io.join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user