diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 6c4300ce6..cd148c020 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -208,6 +208,7 @@ namespace libtorrent std::vector get_torrents(); + void start_torrent(boost::weak_ptr wt); void check_torrent(boost::shared_ptr const& t); void done_checking(boost::shared_ptr const& t); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 82b55fd6b..f19686168 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1834,7 +1834,7 @@ namespace aux { , params.storage, params.paused, params.resume_data , queue_pos, params.auto_managed)); } - torrent_ptr->start(); + m_io_service.post(bind(&session_impl::start_torrent, this, boost::weak_ptr(torrent_ptr))); #ifndef TORRENT_DISABLE_EXTENSIONS for (extension_list_t::iterator i = m_extensions.begin() @@ -1878,6 +1878,20 @@ namespace aux { m_queued_for_checking.push_back(t); } + void session_impl::start_torrent(boost::weak_ptr wt) + { + boost::shared_ptr t = wt.lock(); + if (!t) return; + + mutex_t::scoped_lock l(m_mutex); + + INVARIANT_CHECK; + + if (t->is_aborted()) return; + + t->start(); + } + void session_impl::done_checking(boost::shared_ptr const& t) { if (m_queued_for_checking.empty()) return;