diff --git a/CMakeLists.txt b/CMakeLists.txt index 7506ecc72..65a68c4f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,6 +180,8 @@ endif (build_tests) include_directories(${includes}) +add_definitions(-DTORRENT_BUILDING_LIBRARY) + if (encryption) list(APPEND sources pe_crypto asio_ssl) if(NOT DEFINED OPENSSL_INCLUDE_DIR OR NOT DEFINED OPENSSL_LIBRARIES) diff --git a/Jamfile b/Jamfile index d33fc761a..d9832fc0a 100755 --- a/Jamfile +++ b/Jamfile @@ -228,6 +228,12 @@ rule linking ( properties * ) rule warnings ( properties * ) { local result ; + + if off in $(properties) + { + return $(result) ; + } + if clang in $(properties) || darwin in $(properties) { @@ -747,6 +753,7 @@ lib torrent : # requirements ./ed25519/src multi + TORRENT_BUILDING_LIBRARY shared:TORRENT_BUILDING_SHARED BOOST_NO_DEPRECATED diff --git a/examples/client_test.cpp b/examples/client_test.cpp index ff9a8d937..b50f62f61 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -668,7 +668,7 @@ std::string path_to_url(std::string f) f = path_append(cwd, f); } - for (int i = 0; i < f.size(); ++i) + for (int i = 0; i < int(f.size()); ++i) { #ifdef TORRENT_WINDOWS if (f[i] == '\\') ret.push_back('/'); diff --git a/examples/torrent_view.cpp b/examples/torrent_view.cpp index 9c5c1455a..e398b729b 100644 --- a/examples/torrent_view.cpp +++ b/examples/torrent_view.cpp @@ -262,7 +262,7 @@ void torrent_view::print_tabs() } pos += snprintf(str + pos, sizeof(str) - pos, "\x1b[K"); - if (m_width + 1 < sizeof(str)) + if (m_width + 1 < int(sizeof(str))) str[m_width + 1] = '\0'; print(str); } @@ -272,15 +272,14 @@ void torrent_view::print_headers() set_cursor_pos(0, 1); char str[400]; - int pos = 0; // print title bar for torrent list - pos = snprintf(str, sizeof(str) + snprintf(str, sizeof(str) , " %-3s %-50s %-35s %-17s %-17s %-11s %-6s %-6s %-4s\x1b[K" , "#", "Name", "Progress", "Download", "Upload", "Peers (D:S)" , "Down", "Up", "Flags"); - if (m_width + 1 < sizeof(str)) + if (m_width + 1 < int(sizeof(str))) str[m_width + 1] = '\0'; print(str); @@ -337,7 +336,7 @@ void torrent_view::print_torrent(lt::torrent_status const& s, bool selected) pos += snprintf(str + pos, sizeof(str) - pos, "\x1b[K"); - if (m_width + 1 < sizeof(str)) + if (m_width + 1 < int(sizeof(str))) str[m_width + 1] = '\0'; print(str); diff --git a/include/libtorrent/Makefile.am b/include/libtorrent/Makefile.am index 617cd25f4..95be06ff6 100644 --- a/include/libtorrent/Makefile.am +++ b/include/libtorrent/Makefile.am @@ -101,9 +101,11 @@ nobase_include_HEADERS = \ proxy_base.hpp \ puff.hpp \ random.hpp \ + receive_buffer.hpp \ resolve_links.hpp \ resolver.hpp \ resolver_interface.hpp \ + request_blocks.hpp \ rss.hpp \ session.hpp \ session_settings.hpp \ diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index 361056d83..f0fbe6858 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -267,6 +267,7 @@ namespace libtorrent { time_point m_timestamp; }; + // TODO: 3 delete this functionality #ifndef BOOST_NO_EXCEPTIONS #ifndef TORRENT_NO_DEPRECATE struct TORRENT_DEPRECATED TORRENT_EXPORT unhandled_alert : std::exception diff --git a/include/libtorrent/config.hpp b/include/libtorrent/config.hpp index 39a99f816..f1c545de4 100644 --- a/include/libtorrent/config.hpp +++ b/include/libtorrent/config.hpp @@ -91,7 +91,10 @@ POSSIBILITY OF SUCH DAMAGE. #if defined __GNUC__ -# if __GNUC__ >= 3 +// deprecation markup is only enabled when libtorrent +// headers are included by clients, not while building +// libtorrent itself +# if __GNUC__ >= 3 && !defined TORRENT_BUILDING_LIBRARY # define TORRENT_DEPRECATED __attribute__ ((deprecated)) # endif @@ -116,7 +119,12 @@ POSSIBILITY OF SUCH DAMAGE. // '_vsnprintf': This function or variable may be unsafe #pragma warning(disable:4996) -#define TORRENT_DEPRECATED __declspec(deprecated) +// deprecation markup is only enabled when libtorrent +// headers are included by clients, not while building +// libtorrent itself +#if !defined TORRENT_BUILDING_LIBRARY +# define TORRENT_DEPRECATED __declspec(deprecated) +#endif #endif diff --git a/include/libtorrent/create_torrent.hpp b/include/libtorrent/create_torrent.hpp index 217d65813..97e3c7907 100644 --- a/include/libtorrent/create_torrent.hpp +++ b/include/libtorrent/create_torrent.hpp @@ -453,29 +453,36 @@ namespace libtorrent TORRENT_EXPORT void set_piece_hashes(create_torrent& t, std::wstring const& p , boost::function f, error_code& ec); + TORRENT_EXPORT void set_piece_hashes_deprecated(create_torrent& t + , std::wstring const& p + , boost::function f, error_code& ec); + #ifndef BOOST_NO_EXCEPTIONS template TORRENT_DEPRECATED - void TORRENT_DEPRECATED set_piece_hashes(create_torrent& t, std::wstring const& p, Fun f) + void TORRENT_DEPRECATED set_piece_hashes(create_torrent& t + , std::wstring const& p, Fun f) { error_code ec; - set_piece_hashes(t, p, f, ec); + set_piece_hashes_deprecated(t, p, f, ec); if (ec) throw libtorrent_exception(ec); } TORRENT_DEPRECATED - inline void TORRENT_DEPRECATED set_piece_hashes(create_torrent& t, std::wstring const& p) + inline void TORRENT_DEPRECATED set_piece_hashes(create_torrent& t + , std::wstring const& p) { error_code ec; - set_piece_hashes(t, p, detail::nop, ec); + set_piece_hashes_deprecated(t, p, detail::nop, ec); if (ec) throw libtorrent_exception(ec); } #endif TORRENT_DEPRECATED - inline void TORRENT_DEPRECATED set_piece_hashes(create_torrent& t, std::wstring const& p, error_code& ec) + inline void TORRENT_DEPRECATED set_piece_hashes(create_torrent& t + , std::wstring const& p, error_code& ec) { - set_piece_hashes(t, p, detail::nop, ec); + set_piece_hashes_deprecated(t, p, detail::nop, ec); } #endif // TORRENT_NO_DEPRECATE #endif // TORRENT_USE_WSTRING diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 9403631d1..1dea633fa 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -1343,7 +1343,7 @@ namespace libtorrent // again the next time. time_duration announce_interval; #else - // leave this here for ABI stability + // hidden time_duration deprecated_announce_interval_; #endif diff --git a/src/Makefile.am b/src/Makefile.am index 6492afabd..c9372f1f2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -146,17 +146,11 @@ libtorrent_rasterbar_la_SOURCES = \ $(KADEMLIA_SOURCES) \ $(ASIO_OPENSSL_SOURCES) -#libtorrent_rasterbar_la_LDFLAGS = $(LDFLAGS) -version-info $(INTERFACE_VERSION_INFO) libtorrent_rasterbar_la_LDFLAGS = -version-info $(INTERFACE_VERSION_INFO) - -#libtorrent_rasterbar_la_LIBADD = @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @OPENSSL_LIBS@ libtorrent_rasterbar_la_LIBADD = @BOOST_SYSTEM_LIB@ @OPENSSL_LIBS@ -#AM_CXXFLAGS= -ftemplate-depth-100 -I$(top_srcdir)/include @DEBUGFLAGS@ @OPENSSL_INCLUDES@ -AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/ed25519/src @DEBUGFLAGS@ @OPENSSL_INCLUDES@ +AM_CPPFLAGS = -DTORRENT_BUILDING_LIBRARY -I$(top_srcdir)/include -I$(top_srcdir)/ed25519/src @DEBUGFLAGS@ @OPENSSL_INCLUDES@ AM_CFLAGS = -I$(top_srcdir)/ed25519/src -std=c99 -#AM_CFLAGS= -I$(top_srcdir)/include @DEBUGFLAGS@ -#AM_LDFLAGS = $(LDFLAGS) @BOOST_SYSTEM_LIB@ @BOOST_FILESYSTEM_LIB@ @BOOST_THREAD_LIB@ @OPENSSL_LDFLAGS@ @OPENSSL_LIBS@ AM_LDFLAGS = @OPENSSL_LDFLAGS@ diff --git a/src/create_torrent.cpp b/src/create_torrent.cpp index 39fcf2896..121df64c7 100644 --- a/src/create_torrent.cpp +++ b/src/create_torrent.cpp @@ -219,6 +219,14 @@ namespace libtorrent wchar_utf8(p, utf8); set_piece_hashes(t, utf8, f, ec); } + + void set_piece_hashes_deprecated(create_torrent& t, std::wstring const& p + , boost::function f, error_code& ec) + { + std::string utf8; + wchar_utf8(p, utf8); + set_piece_hashes(t, utf8, f, ec); + } #endif #endif diff --git a/src/kademlia/routing_table.cpp b/src/kademlia/routing_table.cpp index bccf132c5..3ff402d62 100644 --- a/src/kademlia/routing_table.cpp +++ b/src/kademlia/routing_table.cpp @@ -333,7 +333,6 @@ node_entry const* routing_table::next_refresh() // a missing prefix for that bucket node_entry* candidate = NULL; - int bucket_idx = -1; // this will have a bias towards pinging nodes close to us first. int idx = m_buckets.size() - 1; @@ -349,7 +348,6 @@ node_entry const* routing_table::next_refresh() if (j->last_queried == min_time()) { - bucket_idx = idx; candidate = &*j; goto out; } @@ -357,7 +355,6 @@ node_entry const* routing_table::next_refresh() if (candidate == NULL || j->last_queried < candidate->last_queried) { candidate = &*j; - bucket_idx = idx; } } } diff --git a/src/kademlia/traversal_algorithm.cpp b/src/kademlia/traversal_algorithm.cpp index fddd8b31b..a405385ee 100644 --- a/src/kademlia/traversal_algorithm.cpp +++ b/src/kademlia/traversal_algorithm.cpp @@ -274,8 +274,8 @@ void traversal_algorithm::finished(observer_ptr o) o->flags |= observer::flag_alive; ++m_responses; + TORRENT_ASSERT(m_invoke_count > 0); --m_invoke_count; - TORRENT_ASSERT(m_invoke_count >= 0); bool is_done = add_requests(); if (is_done) done(); } @@ -285,8 +285,6 @@ void traversal_algorithm::finished(observer_ptr o) // So, if this is true, don't make another request void traversal_algorithm::failed(observer_ptr o, int flags) { - TORRENT_ASSERT(m_invoke_count >= 0); - // don't tell the routing table about // node ids that we just generated ourself if ((o->flags & observer::flag_no_id) == 0) @@ -337,8 +335,8 @@ void traversal_algorithm::failed(observer_ptr o, int flags) #endif ++m_timeouts; + TORRENT_ASSERT(m_invoke_count > 0); --m_invoke_count; - TORRENT_ASSERT(m_invoke_count >= 0); } if (flags & prevent_request) @@ -450,7 +448,7 @@ bool traversal_algorithm::add_requests() o->flags |= observer::flag_queried; if (invoke(*i)) { - TORRENT_ASSERT(m_invoke_count >= 0); + TORRENT_ASSERT(m_invoke_count < (std::numeric_limits::max)()); ++m_invoke_count; ++outstanding; } diff --git a/src/pe_crypto.cpp b/src/pe_crypto.cpp index 8be82f8b4..ba4b3d7a2 100644 --- a/src/pe_crypto.cpp +++ b/src/pe_crypto.cpp @@ -314,6 +314,7 @@ namespace libtorrent , int& produce , int& packet_size) { + TORRENT_UNUSED(consume); if (!m_decrypt) return; int bytes_processed = 0; diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 7e42340ed..89217e2c7 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -501,7 +501,6 @@ namespace libtorrent , end(m_downloads[j].end()); i != end; ++i) { TORRENT_ASSERT(m_piece_map[i->index].download_queue() == j); - bool blocks_requested = false; int num_blocks = blocks_in_piece(i->index); int num_requested = 0; int num_finished = 0; @@ -522,7 +521,6 @@ namespace libtorrent else if (info[k].state == block_info::state_requested) { ++num_requested; - blocks_requested = true; TORRENT_ASSERT(info[k].num_peers > 0); } else if (info[k].state == block_info::state_writing) diff --git a/src/socket_type.cpp b/src/socket_type.cpp index 7880ed7c5..b05c619ff 100644 --- a/src/socket_type.cpp +++ b/src/socket_type.cpp @@ -125,6 +125,7 @@ namespace libtorrent #endif } +#ifdef TORRENT_USE_OPENSSL namespace { void on_close_socket(socket_type* s, boost::shared_ptr) @@ -137,6 +138,7 @@ namespace libtorrent } } // anonymous namespace +#endif // the second argument is a shared pointer to an object that // will keep the socket (s) alive for the duration of the async operation diff --git a/src/storage.cpp b/src/storage.cpp index 6235edec9..998e53b7f 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -888,10 +888,6 @@ namespace libtorrent } } - bool full_allocation_mode = false; - if (rd.dict_find_string_value("allocation") != "compact") - full_allocation_mode = true; - #ifndef TORRENT_DISABLE_MUTABLE_TORRENTS if (links) { @@ -1402,7 +1398,7 @@ namespace libtorrent } int zero_storage::writev(file::iovec_t const* bufs, int num_bufs - , int /* piece */, int /* offset */, int /* flags */, storage_error& ec) + , int /* piece */, int /* offset */, int /* flags */, storage_error&) { int ret = 0; for (int i = 0; i < num_bufs; ++i) diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 6c441bdc4..4dacc5832 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -854,6 +854,7 @@ namespace libtorrent , m_private(false) , m_i2p(false) { + TORRENT_UNUSED(flags); std::pair buf = torrent_file.data_section(); bdecode_node e; if (bdecode(buf.first, buf.first + buf.second, e, ec) != 0) @@ -870,6 +871,7 @@ namespace libtorrent , m_private(false) , m_i2p(false) { + TORRENT_UNUSED(flags); std::pair buf = torrent_file.data_section(); bdecode_node e; error_code ec; @@ -1020,7 +1022,8 @@ namespace libtorrent #endif // TORRENT_USE_WSTRING #endif - torrent_info::torrent_info(bdecode_node const& torrent_file, error_code& ec, int flags) + torrent_info::torrent_info(bdecode_node const& torrent_file, error_code& ec + , int flags) : m_piece_hashes(0) , m_creation_date(0) , m_merkle_first_leaf(0) @@ -1074,7 +1077,8 @@ namespace libtorrent #if TORRENT_USE_WSTRING #ifndef TORRENT_NO_DEPRECATE - torrent_info::torrent_info(std::wstring const& filename, error_code& ec, int flags) + torrent_info::torrent_info(std::wstring const& filename, error_code& ec + , int flags) : m_piece_hashes(0) , m_creation_date(0) , m_merkle_first_leaf(0) @@ -1112,7 +1116,9 @@ namespace libtorrent , m_multifile(false) , m_private(false) , m_i2p(false) - {} + { + TORRENT_UNUSED(flags); + } torrent_info::~torrent_info() {} @@ -1207,6 +1213,7 @@ namespace libtorrent bool torrent_info::parse_info_section(bdecode_node const& info , error_code& ec, int flags) { + TORRENT_UNUSED(flags); if (info.type() != bdecode_node::dict_t) { ec = errors::torrent_info_no_dict; diff --git a/test/Makefile.am b/test/Makefile.am index 13f65ac39..422e8b058 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -7,7 +7,6 @@ test_programs = \ test_torrent_info \ test_recheck \ test_stat_cache \ - test_policy \ test_part_file \ test_file \ test_file_storage \ @@ -29,6 +28,7 @@ test_programs = \ test_metadata_extension \ test_pe_crypto \ test_peer_classes \ + test_peer_list \ test_peer_priority \ test_pex \ test_piece_picker \ @@ -141,12 +141,12 @@ libtest_la_SOURCES = main.cpp \ swarm_suite.cpp \ test_utils.cpp +test_alert_manager_SOURCES = test_alert_manager.cpp test_bitfield_SOURCES = test_bitfield.cpp test_crc32_SOURCES = test_crc32.cpp test_torrent_info_SOURCES = test_torrent_info.cpp test_recheck_SOURCES = test_recheck.cpp test_stat_cache_SOURCES = test_stat_cache.cpp -test_policy_SOURCES = test_policy.cpp test_part_file_SOURCES = test_part_file.cpp test_file_SOURCES = test_file.cpp test_file_storage_SOURCES = test_file_storage.cpp @@ -161,6 +161,7 @@ test_block_cache_SOURCES = test_block_cache.cpp test_checking_SOURCES = test_checking.cpp test_fast_extension_SOURCES = test_fast_extension.cpp test_hasher_SOURCES = test_hasher.cpp +test_heterogeneous_queue_SOURCES = test_heterogeneous_queue.cpp test_http_connection_SOURCES = test_http_connection.cpp test_ip_filter_SOURCES = test_ip_filter.cpp test_lsd_SOURCES = test_lsd.cpp @@ -168,6 +169,7 @@ test_metadata_extension_SOURCES = test_metadata_extension.cpp test_peer_priority_SOURCES = test_peer_priority.cpp test_pe_crypto_SOURCES = test_pe_crypto.cpp test_peer_classes_SOURCES = test_peer_classes.cpp +test_peer_list_SOURCES = test_peer_list.cpp test_pex_SOURCES = test_pex.cpp test_piece_picker_SOURCES = test_piece_picker.cpp test_xml_SOURCES = test_xml.cpp