From d84c59d13bc32187a6a5674e0ff4fdd567f19f19 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 5 Dec 2009 16:46:10 +0000 Subject: [PATCH] upload only fix --- include/libtorrent/torrent.hpp | 5 +---- src/bt_peer_connection.cpp | 2 +- src/peer_connection.cpp | 4 ++++ 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 4a1baf55e..e8c8dcbd6 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -168,10 +168,7 @@ namespace libtorrent void set_upload_mode(bool b); bool upload_mode() const { return m_upload_mode; } bool is_upload_only() const - { - return (((is_finished() && !super_seeding()) || upload_mode()) - && !m_ses.settings().lazy_bitfields); - } + { return (is_finished() || upload_mode()) && !super_seeding(); } int seed_rank(session_settings const& s) const; diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 8434ce840..30de48692 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -1844,7 +1844,7 @@ namespace libtorrent // if we're using lazy bitfields or if we're super seeding, don't say // we're upload only, since it might make peers disconnect - if (t->is_upload_only()) + if (t->is_upload_only() && !m_ses.settings().lazy_bitfields) handshake["upload_only"] = 1; tcp::endpoint ep = m_ses.get_ipv6_interface(); diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 200f464f9..2d0ba1f57 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -4976,6 +4976,10 @@ namespace libtorrent void peer_connection::set_upload_only(bool u) { + // if the peer is a seed, don't allow setting + // upload_only to false + if (m_upload_only && is_seed()) return; + m_upload_only = u; boost::shared_ptr t = associated_torrent().lock(); t->get_policy().set_seed(m_peer_info, u);