|
|
@@ -840,14 +840,12 @@ namespace libtorrent
|
|
|
|
throw duplicate_torrent();
|
|
|
|
throw duplicate_torrent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
// lock the checker_thread
|
|
|
|
// lock the checker_thread
|
|
|
|
boost::mutex::scoped_lock l(m_checker_impl.m_mutex);
|
|
|
|
boost::mutex::scoped_lock l(m_checker_impl.m_mutex);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// is the torrent currently being checked?
|
|
|
|
// is the torrent currently being checked?
|
|
|
|
if (m_checker_impl.find_torrent(ti.info_hash()))
|
|
|
|
if (m_checker_impl.find_torrent(ti.info_hash()))
|
|
|
|
throw duplicate_torrent();
|
|
|
|
throw duplicate_torrent();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create the torrent and the data associated with
|
|
|
|
// create the torrent and the data associated with
|
|
|
|
// the checker thread and store it before starting
|
|
|
|
// the checker thread and store it before starting
|
|
|
@@ -861,9 +859,6 @@ namespace libtorrent
|
|
|
|
d.info_hash = ti.info_hash();
|
|
|
|
d.info_hash = ti.info_hash();
|
|
|
|
d.parse_resume_data(resume_data, torrent_ptr->torrent_file());
|
|
|
|
d.parse_resume_data(resume_data, torrent_ptr->torrent_file());
|
|
|
|
|
|
|
|
|
|
|
|
// lock the checker thread
|
|
|
|
|
|
|
|
boost::mutex::scoped_lock l(m_checker_impl.m_mutex);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// add the torrent to the queue to be checked
|
|
|
|
// add the torrent to the queue to be checked
|
|
|
|
m_checker_impl.m_torrents.push_back(d);
|
|
|
|
m_checker_impl.m_torrents.push_back(d);
|
|
|
|
// and notify the thread that it got another
|
|
|
|
// and notify the thread that it got another
|
|
|
@@ -880,15 +875,6 @@ namespace libtorrent
|
|
|
|
, boost::filesystem::path const& save_path
|
|
|
|
, boost::filesystem::path const& save_path
|
|
|
|
, entry const& resume_data)
|
|
|
|
, entry const& resume_data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// lock the session
|
|
|
|
|
|
|
|
boost::mutex::scoped_lock l(m_impl.m_mutex);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// is the torrent already active?
|
|
|
|
|
|
|
|
if (m_impl.find_torrent(info_hash))
|
|
|
|
|
|
|
|
throw duplicate_torrent();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// lock the checker_thread
|
|
|
|
// lock the checker_thread
|
|
|
|
boost::mutex::scoped_lock l(m_checker_impl.m_mutex);
|
|
|
|
boost::mutex::scoped_lock l(m_checker_impl.m_mutex);
|
|
|
@@ -898,13 +884,19 @@ namespace libtorrent
|
|
|
|
throw duplicate_torrent();
|
|
|
|
throw duplicate_torrent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// lock the session
|
|
|
|
|
|
|
|
boost::mutex::scoped_lock l(m_impl.m_mutex);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// is the torrent already active?
|
|
|
|
|
|
|
|
if (m_impl.find_torrent(info_hash))
|
|
|
|
|
|
|
|
throw duplicate_torrent();
|
|
|
|
|
|
|
|
|
|
|
|
// create the torrent and the data associated with
|
|
|
|
// create the torrent and the data associated with
|
|
|
|
// the checker thread and store it before starting
|
|
|
|
// the checker thread and store it before starting
|
|
|
|
// the thread
|
|
|
|
// the thread
|
|
|
|
boost::shared_ptr<torrent> torrent_ptr(
|
|
|
|
boost::shared_ptr<torrent> torrent_ptr(
|
|
|
|
new torrent(m_impl, tracker_url, info_hash, save_path, m_impl.m_listen_interface));
|
|
|
|
new torrent(m_impl, tracker_url, info_hash, save_path, m_impl.m_listen_interface));
|
|
|
|
|
|
|
|
|
|
|
|
boost::mutex::scoped_lock l(m_impl.m_mutex);
|
|
|
|
|
|
|
|
m_impl.m_torrents.insert(
|
|
|
|
m_impl.m_torrents.insert(
|
|
|
|
std::make_pair(info_hash, torrent_ptr)).first;
|
|
|
|
std::make_pair(info_hash, torrent_ptr)).first;
|
|
|
|
|
|
|
|
|
|
|
@@ -1006,6 +998,7 @@ namespace libtorrent
|
|
|
|
session::~session()
|
|
|
|
session::~session()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// lock the main thread and abort it
|
|
|
|
boost::mutex::scoped_lock l(m_impl.m_mutex);
|
|
|
|
boost::mutex::scoped_lock l(m_impl.m_mutex);
|
|
|
|
m_impl.m_abort = true;
|
|
|
|
m_impl.m_abort = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -1032,8 +1025,7 @@ namespace libtorrent
|
|
|
|
assert(bytes_per_second > 0 || bytes_per_second == -1);
|
|
|
|
assert(bytes_per_second > 0 || bytes_per_second == -1);
|
|
|
|
boost::mutex::scoped_lock l(m_impl.m_mutex);
|
|
|
|
boost::mutex::scoped_lock l(m_impl.m_mutex);
|
|
|
|
m_impl.m_upload_rate = bytes_per_second;
|
|
|
|
m_impl.m_upload_rate = bytes_per_second;
|
|
|
|
if (m_impl.m_upload_rate != -1/* || !m_impl.m_connections.empty()*/)
|
|
|
|
if (m_impl.m_upload_rate != -1) return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (detail::session_impl::connection_map::iterator i
|
|
|
|
for (detail::session_impl::connection_map::iterator i
|
|
|
|
= m_impl.m_connections.begin();
|
|
|
|
= m_impl.m_connections.begin();
|
|
|
@@ -1048,8 +1040,7 @@ namespace libtorrent
|
|
|
|
assert(bytes_per_second > 0 || bytes_per_second == -1);
|
|
|
|
assert(bytes_per_second > 0 || bytes_per_second == -1);
|
|
|
|
boost::mutex::scoped_lock l(m_impl.m_mutex);
|
|
|
|
boost::mutex::scoped_lock l(m_impl.m_mutex);
|
|
|
|
m_impl.m_download_rate = bytes_per_second;
|
|
|
|
m_impl.m_download_rate = bytes_per_second;
|
|
|
|
if (m_impl.m_download_rate != -1/* || !m_impl.m_connections.empty()*/)
|
|
|
|
if (m_impl.m_download_rate != -1) return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (detail::session_impl::connection_map::iterator i
|
|
|
|
for (detail::session_impl::connection_map::iterator i
|
|
|
|
= m_impl.m_connections.begin();
|
|
|
|
= m_impl.m_connections.begin();
|
|
|
|