From 18dc2e3d3a757960dcda4ba5942fefc90fafd4f9 Mon Sep 17 00:00:00 2001 From: Steven Siloti Date: Sat, 6 Feb 2016 07:48:17 -0800 Subject: [PATCH 01/10] port new Boost.Python macro from RC_1_0 --- m4/ax_boost_python.m4 | 104 +++++++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 43 deletions(-) diff --git a/m4/ax_boost_python.m4 b/m4/ax_boost_python.m4 index 90dfa0ec0..385af3ef5 100644 --- a/m4/ax_boost_python.m4 +++ b/m4/ax_boost_python.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.nongnu.org/autoconf-archive/ax_boost_python.html +# http://www.gnu.org/software/autoconf-archive/ax_boost_python.html # =========================================================================== # # SYNOPSIS @@ -9,7 +9,7 @@ # DESCRIPTION # # This macro checks to see if the Boost.Python library is installed. It -# also attempts to guess the currect library name using several attempts. +# also attempts to guess the correct library name using several attempts. # It tries to build the library name using a user supplied name or suffix # and then just the raw library. # @@ -18,20 +18,14 @@ # # This macro calls AC_SUBST(BOOST_PYTHON_LIB). # -# In order to ensure that the Python headers are specified on the include -# path, this macro requires AX_PYTHON to be called. -# -# EDIT: -# 2009-09-14 Cristian Greco -# - Require AX_PYTHON_DEVEL to be called before this macro to properly -# detect python include path, instead of AX_PYTHON. -# 2009-09-07 Cristian Greco -# - Prefix BOOST_PYTHON_LIB with a `-l` for consistency with other -# ax_boost_libname.m4 scripts. +# In order to ensure that the Python headers and the Boost libraries are +# specified on the include path, this macro requires AX_PYTHON_DEVEL and +# AX_BOOST_BASE to be called. # # LICENSE # # Copyright (c) 2008 Michael Tindal +# Copyright (c) 2013 Daniel M"ullner # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the @@ -59,45 +53,69 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. +#serial 21 + AC_DEFUN([AX_BOOST_PYTHON], [AC_REQUIRE([AX_PYTHON_DEVEL])dnl +AC_REQUIRE([AX_BOOST_BASE])dnl +AC_LANG_PUSH([C++]) +ax_boost_python_save_CPPFLAGS="$CPPFLAGS" +ax_boost_python_save_LDFLAGS="$LDFLAGS" +ax_boost_python_save_LIBS="$LIBS" +if test "x$PYTHON_CPPFLAGS" != "x"; then + CPPFLAGS="$PYTHON_CPPFLAGS $CPPFLAGS" +fi + +# Versions of AX_PYTHON_DEVEL() before serial 18 provided PYTHON_LDFLAGS +# instead of PYTHON_LIBS, so this is just here for compatibility. +if test "x$PYTHON_LDFLAGS" != "x"; then + LDFLAGS="$PYTHON_LDFLAGS $LDFLAGS" +fi + +# Note: Only versions of AX_PYTHON_DEVEL() since serial 18 provide PYTHON_LIBS +# instead of PYTHON_LDFLAGS. +if test "x$PYTHON_LIBS" != "x"; then + LIBS="$PYTHON_LIBS $LIBS" +fi + +if test "x$BOOST_CPPFLAGS" != "x"; then + CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS" +fi +if test "x$BOOST_LDFLAGS" != "x"; then + LDFLAGS="$BOOST_LDFLAGS $LDFLAGS" +fi AC_CACHE_CHECK(whether the Boost::Python library is available, ac_cv_boost_python, -[AC_LANG_SAVE - AC_LANG_CPLUSPLUS - CPPFLAGS_SAVE=$CPPFLAGS - if test "x$PYTHON_CPPFLAGS" != "x"; then - CPPFLAGS="$PYTHON_CPPFLAGS $CPPFLAGS" - fi - AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[ - #include - using namespace boost::python; - BOOST_PYTHON_MODULE(test) { throw "Boost::Python test."; }]], - [[return 0;]]), - ac_cv_boost_python=yes, ac_cv_boost_python=no) - AC_LANG_RESTORE - CPPFLAGS=$CPPFLAGS_SAVE +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +BOOST_PYTHON_MODULE(test) { throw "Boost::Python test."; }]], [])], + ac_cv_boost_python=yes, ac_cv_boost_python=no) ]) -if test "x$ac_cv_boost_python" = "xyes"; then - AC_DEFINE(HAVE_BOOST_PYTHON,[1],[define if the Boost::Python library is available]) - dnl - LDFLAGS_SAVE=$LDFLAGS - if test "x$PYTHON_LDFLAGS" != "x"; then - LDFLAGS="$LDFLAGS $PYTHON_LDFLAGS" - fi - dnl +if test "$ac_cv_boost_python" = "yes"; then + AC_DEFINE(HAVE_BOOST_PYTHON,,[define if the Boost::Python library is available]) ax_python_lib=boost_python - AC_ARG_WITH([boost-python],AS_HELP_STRING([--with-boost-python],[specify the boost python library or suffix to use]), - [if test "x$with_boost_python" != "xno"; then - ax_python_lib="$with_boost_python" - ax_boost_python_lib="boost_python-$with_boost_python" + AC_ARG_WITH([boost-python],AS_HELP_STRING([--with-boost-python],[specify yes/no or the boost python library or suffix to use]), + [if test "x$with_boost_python" != "xno" -a "x$with_boost_python" != "xyes"; then + ax_python_lib=$with_boost_python + ax_boost_python_lib=boost_python-$with_boost_python fi]) - for ax_lib in $ax_python_lib $ax_boost_python_lib boost_python; do - AC_CHECK_LIB($ax_lib, main, [BOOST_PYTHON_LIB=-l$ax_lib break]) + BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` + for ax_lib in $ax_python_lib $ax_boost_python_lib `ls $BOOSTLIBDIR/libboost_python*.so* $BOOSTLIBDIR/libboost_python*.dylib* $BOOSTLIBDIR/libboost_python*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_python.*\)\.so.*$;\1;' -e 's;^lib\(boost_python.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_python.*\)\.a.*$;\1;' ` boost_python boost_python3; do + AS_VAR_PUSHDEF([ax_Lib], [ax_cv_lib_$ax_lib''_BOOST_PYTHON_MODULE])dnl + AC_CACHE_CHECK([whether $ax_lib is the correct library], [ax_Lib], + [LIBS="-l$ax_lib $ax_boost_python_save_LIBS $PYTHON_LIBS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +BOOST_PYTHON_MODULE(test) { throw "Boost::Python test."; }]], [])], + [AS_VAR_SET([ax_Lib], [yes])], + [AS_VAR_SET([ax_Lib], [no])])]) + AS_VAR_IF([ax_Lib], [yes], [BOOST_PYTHON_LIB=$ax_lib break], []) + AS_VAR_POPDEF([ax_Lib])dnl done - dnl - LDFLAGS=$LDFLAGS_SAVE - dnl AC_SUBST(BOOST_PYTHON_LIB) fi +CPPFLAGS="$ax_boost_python_save_CPPFLAGS" +LDFLAGS="$ax_boost_python_save_LDFLAGS" +LIBS="$ax_boost_python_save_LIBS" +AC_LANG_POP([C++]) ])dnl From df353bc3f94218b4e4d9ccc996470385f54d879d Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 6 Feb 2016 15:49:25 -0500 Subject: [PATCH 02/10] forward port typo fix in udp_socket from RC_1_0 --- src/udp_socket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/udp_socket.cpp b/src/udp_socket.cpp index 330525d19..f7e26a0ea 100644 --- a/src/udp_socket.cpp +++ b/src/udp_socket.cpp @@ -820,9 +820,9 @@ void udp_socket::bind(udp::endpoint const& ep, error_code& ec) // this is best-effort. ignore errors error_code err; #ifdef TORRENT_WINDOWS - m_ipv4_sock.set_option(exclusive_address_use(true), err); + m_ipv6_sock.set_option(exclusive_address_use(true), err); #endif - m_ipv4_sock.set_option(boost::asio::socket_base::reuse_address(true), err); + m_ipv6_sock.set_option(boost::asio::socket_base::reuse_address(true), err); m_ipv6_sock.set_option(boost::asio::ip::v6_only(true), err); m_ipv6_sock.bind(ep6, ec); From dcee303120700f9b42ffc5dbeb8ec8f1c8d17c3d Mon Sep 17 00:00:00 2001 From: Steven Siloti Date: Sat, 6 Feb 2016 19:41:40 -0800 Subject: [PATCH 03/10] escape underscores in function signatures Underscores can be interpreted as hyperlinks so they must be escaped in code. Also fix spliting of the function name and formal parameters when the parameters contain default values with parens in them. --- docs/gen_reference_doc.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) mode change 100755 => 100644 docs/gen_reference_doc.py diff --git a/docs/gen_reference_doc.py b/docs/gen_reference_doc.py old mode 100755 new mode 100644 index b3ef661db..10c0645f4 --- a/docs/gen_reference_doc.py +++ b/docs/gen_reference_doc.py @@ -149,7 +149,7 @@ def is_visible(desc): return True def highlight_signature(s): - name = s.split('(') + name = s.split('(', 1) name2 = name[0].split(' ') if len(name2[-1]) == 0: return s @@ -168,6 +168,9 @@ def highlight_signature(s): # we also have to escape colons name[1] = name[1].replace(':', '\\:') + # escape trailing underscores + name[1] = name[1].replace('_', '\\_') + # comments in signatures are italic name[1] = name[1].replace('/\\*', '*/\\*') name[1] = name[1].replace('\\*/', '\\*/*') From e62278e951b0e84c26401274038cb4f422cbad5b Mon Sep 17 00:00:00 2001 From: Steven Siloti Date: Sat, 6 Feb 2016 19:44:45 -0800 Subject: [PATCH 04/10] update reference document list --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 0b373a4a9..5942f04b7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -94,17 +94,17 @@ DOCS_PAGES = \ docs/utp.rst \ docs/streaming.rst \ docs/reference-Alerts.html \ + docs/reference-Bdecoding.html \ docs/reference-Bencoding.html \ docs/reference-Core.html \ docs/reference-Create_Torrents.html \ docs/reference-Custom_Storage.html \ + docs/reference-ed25519.html \ docs/reference-Error_Codes.html \ docs/reference-Filter.html \ docs/reference-Plugins.html \ - docs/reference-Session.html \ docs/reference-Settings.html \ docs/reference-Storage.html \ - docs/reference-Time.html \ docs/reference-Utility.html \ docs/reference.html From ad9d50c6b885f013dba20b8a3065086dbbe64dc0 Mon Sep 17 00:00:00 2001 From: Steven Siloti Date: Sat, 6 Feb 2016 19:45:23 -0800 Subject: [PATCH 05/10] add make_torrent to Makefile.am --- test/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Makefile.am b/test/Makefile.am index 7c0be30d5..4e6ae74b2 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -101,7 +101,7 @@ EXTRA_PROGRAMS = $(test_programs) $(benchmark_programs) noinst_HEADERS = test.hpp setup_transfer.hpp dht_server.hpp \ peer_server.hpp udp_tracker.hpp web_seed_suite.hpp swarm_suite.hpp \ - test_utils.hpp settings.hpp + test_utils.hpp settings.hpp make_torrent.hpp libtest_la_SOURCES = main.cpp \ test.cpp \ @@ -109,6 +109,7 @@ libtest_la_SOURCES = main.cpp \ dht_server.cpp \ udp_tracker.cpp \ peer_server.cpp \ + make_torrent.cpp \ web_seed_suite.cpp \ swarm_suite.cpp \ test_utils.cpp \ From f2bd5003ad8d7ceb716290b589c9418c0703fd5a Mon Sep 17 00:00:00 2001 From: Steven Siloti Date: Sat, 6 Feb 2016 20:47:55 -0800 Subject: [PATCH 06/10] Enable extra exports when doing a distcheck --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 5942f04b7..f3c0ef9df 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ACLOCAL_AMFLAGS = -I m4 -#DISTCHECK_CONFIGURE_FLAGS = --enable-tests +AM_DISTCHECK_CONFIGURE_FLAGS = --enable-tests=yes SUBDIRS = include/libtorrent src examples test bindings tools From f8a53d17ec49fd76152c87fd3891f886b9099d45 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 7 Feb 2016 02:12:58 -0500 Subject: [PATCH 07/10] un-deprecate the endpoint field in listen_failed_alert --- include/libtorrent/alert_types.hpp | 2 -- src/alert.cpp | 4 ---- 2 files changed, 6 deletions(-) diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 291a4f421..9ced3fc7b 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -1298,10 +1298,8 @@ namespace libtorrent // the type of listen socket this alert refers to. socket_type_t sock_type; -#ifndef TORRENT_NO_DEPRECATE // the address and port libtorrent attempted to listen on tcp::endpoint endpoint; -#endif private: aux::stack_allocator const& m_alloc; diff --git a/src/alert.cpp b/src/alert.cpp index 310a9db07..5add43b12 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -787,14 +787,12 @@ namespace libtorrent { "SSL/uTP" }; -#ifndef TORRENT_NO_DEPRECATE tcp::endpoint parse_interface(std::string const& iface, int port) { // ignore errors error_code ec; return tcp::endpoint(address::from_string(iface, ec), port); } -#endif } listen_failed_alert::listen_failed_alert( @@ -808,9 +806,7 @@ namespace libtorrent { , operation(op) , port(prt) , sock_type(t) -#ifndef TORRENT_NO_DEPRECATE , endpoint(parse_interface(iface, prt)) -#endif , m_alloc(alloc) , m_interface_idx(alloc.copy_string(iface)) {} From f4627db97f9ed3efe024841ffd5c2c14b9a5a4ce Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 7 Feb 2016 02:37:32 -0500 Subject: [PATCH 08/10] removed unused field in torrent --- include/libtorrent/torrent.hpp | 19 +++++++------------ src/torrent.cpp | 4 +--- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 2c9639363..00faf1c6b 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -1481,10 +1481,11 @@ namespace libtorrent // its value until the piece picker is created bool m_sequential_download:1; - // is false by default and set to - // true when the first tracker reponse - // is received - bool m_got_tracker_response:1; + // this is set if the auto_sequential setting is true and this swarm + // satisfies the criteria to be considered high-availability. i.e. if + // there's mostly seeds in the swarm, download the files sequentially + // for improved disk I/O performance. + bool m_auto_sequential:1; // this means we haven't verified the file content // of the files we're seeding. the m_verified bitfield @@ -1561,11 +1562,11 @@ namespace libtorrent // set to true if the session IP filter applies to this // torrent or not. Defaults to true. bool m_apply_ip_filter:1; - + // if set to true, add tracker URLs loaded from resume // data into this torrent instead of replacing them bool m_merge_resume_trackers:1; - + // ---- // the number of bytes of padding files @@ -1663,12 +1664,6 @@ namespace libtorrent // at high enough rates, it's inactive. bool m_inactive:1; - // this is set if the auto_sequential setting is true and this swarm - // satisfies the criteria to be considered high-availability. i.e. if - // there's mostly seeds in the swarm, download the files sequentially - // for improved disk I/O performance. - bool m_auto_sequential:1; - // ---- // the scrape data from the tracker response, this diff --git a/src/torrent.cpp b/src/torrent.cpp index 17c3c5fdd..fa35d0c4b 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -234,7 +234,7 @@ namespace libtorrent , m_last_working_tracker(-1) , m_finished_time(0) , m_sequential_download(false) - , m_got_tracker_response(false) + , m_auto_sequential(false) , m_seed_mode(false) , m_super_seeding(false) , m_override_resume_data((p.flags & add_torrent_params::flag_override_resume_data) != 0) @@ -274,7 +274,6 @@ namespace libtorrent , m_current_gauge_state(no_gauge_state) , m_moving_storage(false) , m_inactive(false) - , m_auto_sequential(false) , m_downloaded(0xffffff) , m_last_scrape((std::numeric_limits::min)()) , m_progress_ppm(0) @@ -3565,7 +3564,6 @@ namespace libtorrent #endif , r.url); } - m_got_tracker_response = true; // we're listening on an interface type that was not used // when talking to the tracker. If there is a matching interface From dd48faa8d482162435ddba75ffdb4698e610b701 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 8 Feb 2016 02:05:00 -0500 Subject: [PATCH 09/10] minor debug logging issue in test facility wait-for-alert and fix minor shutdown issue with udp_socket packet subscription --- src/session_impl.cpp | 4 +++- src/torrent.cpp | 9 +++++++++ test/setup_transfer.cpp | 7 +++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 15495bb56..b642688e6 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -5924,7 +5924,7 @@ retry: #ifdef TORRENT_USE_OPENSSL m_ssl_udp_socket.unsubscribe(this); - m_ssl_udp_socket.unsubscribe(&m_utp_socket_manager); + m_ssl_udp_socket.unsubscribe(&m_ssl_utp_socket_manager); #endif TORRENT_ASSERT(m_torrents.empty()); @@ -6048,6 +6048,8 @@ retry: } #endif + // TODO: 2 this should be factored into the udp socket, so we only have the + // code once void session_impl::update_peer_tos() { error_code ec; diff --git a/src/torrent.cpp b/src/torrent.cpp index fa35d0c4b..af4c245ee 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -6009,18 +6009,27 @@ namespace libtorrent if (alerts().should_post()) alerts().emplace_alert(get_handle(), ec, certificate); } +#ifndef TORRENT_DISABLE_LOGGING + debug_log("*** use certificate file: %s", ec.message().c_str()); +#endif m_ssl_ctx->use_private_key_file(private_key, context::pem, ec); if (ec) { if (alerts().should_post()) alerts().emplace_alert(get_handle(), ec, private_key); } +#ifndef TORRENT_DISABLE_LOGGING + debug_log("*** use private key file: %s", ec.message().c_str()); +#endif m_ssl_ctx->use_tmp_dh_file(dh_params, ec); if (ec) { if (alerts().should_post()) alerts().emplace_alert(get_handle(), ec, dh_params); } +#ifndef TORRENT_DISABLE_LOGGING + debug_log("*** use DH file: %s", ec.message().c_str()); +#endif } void torrent::set_ssl_cert_buffer(std::string const& certificate diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 6f8a4af8c..209ab1468 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -155,6 +155,8 @@ alert const* wait_for_alert(lt::session& ses, int type, char const* name) time_point now = clock_type::now(); if (now > end) return NULL; + alert const* ret = NULL; + ses.wait_for_alert(end - now); std::vector alerts; ses.pop_alerts(&alerts); @@ -163,11 +165,12 @@ alert const* wait_for_alert(lt::session& ses, int type, char const* name) { fprintf(stderr, "%s: %s: [%s] %s\n", time_now_string(), name , (*i)->what(), (*i)->message().c_str()); - if ((*i)->type() == type) + if ((*i)->type() == type && !ret) { - return *i; + ret = *i; } } + if (ret) return ret; } return NULL; } From 44abd1a59b47cc059d38895cf2eabc2e4cf6499a Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 8 Feb 2016 15:28:13 -0500 Subject: [PATCH 10/10] forward port fix to post torrent_added_alert earlier, from RC_1_0 --- src/session_impl.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index b642688e6..1e6cbd4ab 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -4834,6 +4834,10 @@ retry: torrent_ptr = boost::make_shared(boost::ref(*this) , 16 * 1024, queue_pos, boost::cref(params), boost::cref(*ih)); + + if (m_alerts.should_post()) + m_alerts.emplace_alert(torrent_ptr->get_handle()); + torrent_ptr->set_ip_filter(m_ip_filter); torrent_ptr->start(params); @@ -4913,9 +4917,6 @@ retry: m_uuids.insert(std::make_pair(params.uuid.empty() ? params.url : params.uuid, torrent_ptr)); - if (m_alerts.should_post()) - m_alerts.emplace_alert(torrent_ptr->get_handle()); - // recalculate auto-managed torrents sooner (or put it off) // if another torrent will be added within one second from now // we want to put it off again anyway. So that while we're adding