From c609faa87915d08f0db95490e4f93415a8fa6165 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 30 Aug 2004 09:08:36 +0000 Subject: [PATCH] *** empty log message *** --- examples/client_test.cpp | 2 +- include/libtorrent/torrent_handle.hpp | 2 +- src/identify_client.cpp | 1 + src/session.cpp | 39 +++++++++++---------------- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 82ba43565..0f7f0cc97 100755 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -218,7 +218,7 @@ void print_peer_info(std::ostream& out, std::vector const { using namespace libtorrent; - out << " down up q r flags block\n"; + out << " down up q r flags client block\n"; for (std::vector::const_iterator i = peers.begin(); i != peers.end(); diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index f200b5a7c..6a3f6830b 100755 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -177,7 +177,7 @@ namespace libtorrent friend class session; friend class torrent; - torrent_handle(): m_ses(0) {} + torrent_handle(): m_ses(0), m_chk(0) {} void get_peer_info(std::vector& v) const; torrent_status status() const; diff --git a/src/identify_client.cpp b/src/identify_client.cpp index eb5658d88..bfbb2fd72 100755 --- a/src/identify_client.cpp +++ b/src/identify_client.cpp @@ -155,6 +155,7 @@ namespace { map_entry("A", "ABC") , map_entry("AZ", "Azureus") + , map_entry("BB", "BitBuddy") , map_entry("BX", "BittorrentX") , map_entry("LT", "libtorrent") , map_entry("M", "Mainline") diff --git a/src/session.cpp b/src/session.cpp index 1e87495e1..d97363e45 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -840,14 +840,12 @@ namespace libtorrent throw duplicate_torrent(); } - { - // lock the checker_thread - boost::mutex::scoped_lock l(m_checker_impl.m_mutex); + // lock the checker_thread + boost::mutex::scoped_lock l(m_checker_impl.m_mutex); - // is the torrent currently being checked? - if (m_checker_impl.find_torrent(ti.info_hash())) - throw duplicate_torrent(); - } + // is the torrent currently being checked? + if (m_checker_impl.find_torrent(ti.info_hash())) + throw duplicate_torrent(); // create the torrent and the data associated with // the checker thread and store it before starting @@ -861,9 +859,6 @@ namespace libtorrent d.info_hash = ti.info_hash(); 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 m_checker_impl.m_torrents.push_back(d); // and notify the thread that it got another @@ -880,15 +875,6 @@ namespace libtorrent , boost::filesystem::path const& save_path , 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 boost::mutex::scoped_lock l(m_checker_impl.m_mutex); @@ -898,13 +884,19 @@ namespace libtorrent 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 // the checker thread and store it before starting // the thread boost::shared_ptr torrent_ptr( 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( std::make_pair(info_hash, torrent_ptr)).first; @@ -1006,6 +998,7 @@ namespace libtorrent session::~session() { { + // lock the main thread and abort it boost::mutex::scoped_lock l(m_impl.m_mutex); m_impl.m_abort = true; } @@ -1032,8 +1025,7 @@ namespace libtorrent assert(bytes_per_second > 0 || bytes_per_second == -1); boost::mutex::scoped_lock l(m_impl.m_mutex); m_impl.m_upload_rate = bytes_per_second; - if (m_impl.m_upload_rate != -1/* || !m_impl.m_connections.empty()*/) - return; + if (m_impl.m_upload_rate != -1) return; for (detail::session_impl::connection_map::iterator i = m_impl.m_connections.begin(); @@ -1048,8 +1040,7 @@ namespace libtorrent assert(bytes_per_second > 0 || bytes_per_second == -1); boost::mutex::scoped_lock l(m_impl.m_mutex); m_impl.m_download_rate = bytes_per_second; - if (m_impl.m_download_rate != -1/* || !m_impl.m_connections.empty()*/) - return; + if (m_impl.m_download_rate != -1) return; for (detail::session_impl::connection_map::iterator i = m_impl.m_connections.begin();