From be8c918158352aba2618edbd66a3d1e192c1e715 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 20 Dec 2013 08:35:29 +0000 Subject: [PATCH] fix TORRENT_DISABLE_EXTENSIONS issues (specifically when enabling it) --- include/libtorrent/add_torrent_params.hpp | 4 +--- include/libtorrent/bt_peer_connection.hpp | 2 +- src/bt_peer_connection.cpp | 12 ++++++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp index 57819a678..472a86d73 100644 --- a/include/libtorrent/add_torrent_params.hpp +++ b/include/libtorrent/add_torrent_params.hpp @@ -48,10 +48,8 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { class torrent_info; -#ifdef TORRENT_DISABLE_EXTENSIONS - struct torrent; + class torrent; struct torrent_plugin; -#endif // The add_torrent_params is a parameter pack for adding torrents to a session. // The key fields when adding a torrent are: diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index 655e501f6..ad49542a9 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -206,11 +206,11 @@ namespace libtorrent void on_allowed_fast(int received); #ifndef TORRENT_DISABLE_EXTENSIONS void on_holepunch(); -#endif void on_extended(int received); void on_extended_handshake(); +#endif typedef void (bt_peer_connection::*message_handler)(int received); diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 6221ad06a..50204a665 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -89,8 +89,10 @@ namespace libtorrent &bt_peer_connection::on_have_none, &bt_peer_connection::on_reject_request, &bt_peer_connection::on_allowed_fast, +#ifndef TORRENT_DISABLE_EXTENSIONS 0, 0, &bt_peer_connection::on_extended +#endif }; @@ -115,6 +117,8 @@ namespace libtorrent #ifndef TORRENT_DISABLE_ENCRYPTION , m_encrypted(false) , m_rc4_encrypted(false) +#endif +#ifndef TORRENT_DISABLE_EXTENSIONS , m_upload_only_id(0) , m_holepunch_id(0) , m_sync_bytes_read(0) @@ -129,7 +133,9 @@ namespace libtorrent #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS m_in_constructor = false; #endif +#ifndef TORRENT_DISABLE_EXTENSIONS memset(m_reserved_bits, 0, sizeof(m_reserved_bits)); +#endif } void bt_peer_connection::start() @@ -1564,6 +1570,7 @@ namespace libtorrent // --------- EXTENDED ---------- // ----------------------------- +#ifndef TORRENT_DISABLE_EXTENSIONS void bt_peer_connection::on_extended(int received) { INVARIANT_CHECK; @@ -1664,7 +1671,6 @@ namespace libtorrent , extended_id, packet_size()); #endif -#ifndef TORRENT_DISABLE_EXTENSIONS for (extension_list_t::iterator i = m_extensions.begin() , end(m_extensions.end()); i != end; ++i) { @@ -1672,7 +1678,6 @@ namespace libtorrent , recv_buffer)) return; } -#endif disconnect(errors::invalid_message, 2); return; @@ -1704,7 +1709,6 @@ namespace libtorrent peer_log("<== EXTENDED HANDSHAKE: %s", print_entry(root).c_str()); #endif -#ifndef TORRENT_DISABLE_EXTENSIONS for (extension_list_t::iterator i = m_extensions.begin(); !m_extensions.empty() && i != m_extensions.end();) { @@ -1724,7 +1728,6 @@ namespace libtorrent m_holepunch_id = boost::uint8_t(m->dict_find_int_value("ut_holepunch", 0)); m_dont_have_id = boost::uint8_t(m->dict_find_int_value("lt_donthave", 0)); } -#endif // there is supposed to be a remote listen port int listen_port = int(root.dict_find_int_value("p")); @@ -1788,6 +1791,7 @@ namespace libtorrent && !t->share_mode()) disconnect(errors::upload_upload_connection); } +#endif // TORRENT_DISABLE_EXTENSIONS bool bt_peer_connection::dispatch_message(int received) {