forked from premiere/premiere-libtorrent
merged RC_1_1 into master
This commit is contained in:
commit
16f1deb3ec
|
@ -82,6 +82,7 @@
|
|||
* resume data no longer has timestamps of files
|
||||
* require C++11 to build libtorrent
|
||||
|
||||
* don't perform DNS lookups for the DHT bootstrap unless DHT is enabled
|
||||
* fix issue where setting file/piece priority would stop checking
|
||||
* expose post_dht_stats() to python binding
|
||||
* fix backwards compatibility to downloads without partfiles
|
||||
|
|
|
@ -8,6 +8,8 @@ import modules ;
|
|||
use-project /torrent : ../.. ;
|
||||
|
||||
BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ;
|
||||
# this is used to make bjam use the same version of python which is executing setup.py
|
||||
LIBTORRENT_PYTHON_INTERPRETER = [ modules.peek : LIBTORRENT_PYTHON_INTERPRETER ] ;
|
||||
|
||||
feature visibility : default hidden : composite ;
|
||||
feature.compose <visibility>hidden : <cflags>-fvisibility=hidden <cxxflags>-fvisibility-inlines-hidden ;
|
||||
|
@ -16,10 +18,20 @@ feature libtorrent-link : shared static : composite propagated ;
|
|||
feature libtorrent-python-pic : off on : composite propagated link-incompatible ;
|
||||
feature.compose <libtorrent-python-pic>on : <cflags>-fPIC ;
|
||||
|
||||
# this is just to force boost build to pick the desired python target when using LIBTORRENT_PYTHON_INTERPRETER
|
||||
feature libtorrent-python : on ;
|
||||
|
||||
if $(LIBTORRENT_PYTHON_INTERPRETER)
|
||||
{
|
||||
echo "using python interpreter at: " $(LIBTORRENT_PYTHON_INTERPRETER) ;
|
||||
using python : : "$(LIBTORRENT_PYTHON_INTERPRETER)" : : : <libtorrent-python>on ;
|
||||
}
|
||||
|
||||
if $(BOOST_ROOT)
|
||||
{
|
||||
use-project /boost : $(BOOST_ROOT) ;
|
||||
alias boost_python : /boost/python//boost_python : : : <include>$(BOOST_ROOT) ;
|
||||
alias boost_python3 : /boost/python//boost_python3 : : : <include>$(BOOST_ROOT) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -40,9 +52,13 @@ else
|
|||
# the names are decorated in MacPorts
|
||||
lib boost_python : : <target-os>darwin <name>boost_python-mt
|
||||
: : $(boost-include-path) ;
|
||||
lib boost_python3 : : <target-os>darwin <name>boost_python3-mt
|
||||
: : $(boost-include-path) ;
|
||||
|
||||
lib boost_python : : <name>boost_python
|
||||
: : $(boost-include-path) ;
|
||||
lib boost_python3 : : <name>boost_python3
|
||||
: : $(boost-include-path) ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,16 +96,33 @@ rule libtorrent_linking ( properties * )
|
|||
ECHO "WARNING: you cannot link statically against boost-python on linux, because it links against pthread statically in that case, which is not allowed" ;
|
||||
}
|
||||
|
||||
local boost_python_lib ;
|
||||
|
||||
for local prop in $(properties)
|
||||
{
|
||||
switch $(prop)
|
||||
{
|
||||
case <python>2.* : boost_python_lib = boost_python ;
|
||||
case <python>3.* : boost_python_lib = boost_python3 ;
|
||||
}
|
||||
}
|
||||
|
||||
if ! $(boost_python_lib)
|
||||
{
|
||||
ECHO "WARNING: unknown python version" ;
|
||||
boost_python_lib = boost_python ;
|
||||
}
|
||||
|
||||
# linux must link dynamically against boost python because it pulls
|
||||
# in libpthread, which must be linked dynamically since we're building a .so
|
||||
# (the static build of libpthread is not position independent)
|
||||
if <boost-link>shared in $(properties) || <target-os>linux in $(properties)
|
||||
{
|
||||
result += <library>boost_python/<link>shared/<warnings>off ;
|
||||
result += <library>$(boost_python_lib)/<link>shared/<warnings>off ;
|
||||
}
|
||||
else
|
||||
{
|
||||
result += <library>boost_python/<link>static/<warnings>off ;
|
||||
result += <library>$(boost_python_lib)/<link>static/<warnings>off ;
|
||||
}
|
||||
|
||||
if <libtorrent-link>shared in $(properties)
|
||||
|
@ -169,6 +202,7 @@ install stage_module
|
|||
install stage_dependencies
|
||||
: /torrent//torrent
|
||||
boost_python
|
||||
boost_python3
|
||||
: <location>dependencies
|
||||
<install-dependencies>on
|
||||
<install-type>SHARED_LIB
|
||||
|
|
|
@ -84,39 +84,59 @@ packages = None
|
|||
if '--bjam' in sys.argv:
|
||||
del sys.argv[sys.argv.index('--bjam')]
|
||||
|
||||
if '--help' not in sys.argv and '--help-commands' not in sys.argv:
|
||||
if '--help' not in sys.argv \
|
||||
and '--help-commands' not in sys.argv:
|
||||
|
||||
toolset = ''
|
||||
file_ext = '.so'
|
||||
|
||||
if platform.system() == 'Windows':
|
||||
file_ext = '.pyd'
|
||||
else:
|
||||
file_ext = '.so'
|
||||
# See https://wiki.python.org/moin/WindowsCompilers for a table of msvc versions
|
||||
# used for each python version
|
||||
# Specify the full version number for 9.0 and 10.0 because apparently
|
||||
# older versions of boost don't support only specifying the major number and
|
||||
# there was only one version of msvc with those majors.
|
||||
# Only specify the major for msvc-14 so that 14.1, 14.11, etc can be used.
|
||||
# Hopefully people building with msvc-14 are using a new enough version of boost
|
||||
# for this to work.
|
||||
if sys.version_info[0:2] in ((2, 6), (2, 7), (3, 0), (3, 1), (3, 2)):
|
||||
toolset = ' toolset=msvc-9.0'
|
||||
elif sys.version_info[0:2] in ((3, 3), (3, 4)):
|
||||
toolset = ' toolset=msvc-10.0'
|
||||
elif sys.version_info[0:2] in ((3, 5), (3, 6)):
|
||||
toolset = ' toolset=msvc-14'
|
||||
else:
|
||||
# unknown python version, lets hope the user has the right version of msvc configured
|
||||
toolset = ' toolset=msvc'
|
||||
|
||||
parallel_builds = ' -j%d' % multiprocessing.cpu_count()
|
||||
if sys.maxsize > 2**32:
|
||||
address_model = ' address-model=64'
|
||||
else:
|
||||
address_model = ' address-model=32'
|
||||
|
||||
# add extra quoting around the path to prevent bjam from parsing it as a list
|
||||
# if the path has spaces
|
||||
os.environ['LIBTORRENT_PYTHON_INTERPRETER'] = '"' + sys.executable + '"'
|
||||
|
||||
# build libtorrent using bjam and build the installer with distutils
|
||||
cmdline = ('b2 libtorrent-link=static boost-link=static release '
|
||||
'optimization=space stage_module --abbreviate-paths' +
|
||||
parallel_builds)
|
||||
address_model + toolset + parallel_builds)
|
||||
print(cmdline)
|
||||
if os.system(cmdline) != 0:
|
||||
print('build failed')
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
os.mkdir('build')
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
shutil.rmtree('build/lib')
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
os.mkdir('build/lib')
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
os.mkdir('libtorrent')
|
||||
except:
|
||||
pass
|
||||
try: os.mkdir('build')
|
||||
except: pass
|
||||
try: shutil.rmtree('build/lib')
|
||||
except: pass
|
||||
try: os.mkdir('build/lib')
|
||||
except: pass
|
||||
try: os.mkdir('libtorrent')
|
||||
except: pass
|
||||
shutil.copyfile('libtorrent' + file_ext,
|
||||
'build/lib/libtorrent' + file_ext)
|
||||
|
||||
|
|
|
@ -505,32 +505,37 @@ class test_session(unittest.TestCase):
|
|||
s.post_session_stats()
|
||||
alerts = []
|
||||
# first the stats headers log line. but not if logging is disabled
|
||||
s.wait_for_alert(1000)
|
||||
alerts = s.pop_alerts()
|
||||
while len(alerts) == 0:
|
||||
s.wait_for_alert(1000)
|
||||
alerts = s.pop_alerts()
|
||||
a = alerts.pop(0)
|
||||
print(a)
|
||||
self.assertTrue(isinstance(a, lt.session_stats_header_alert))
|
||||
# then the actual stats values
|
||||
if len(alerts) == 0:
|
||||
while len(alerts) == 0:
|
||||
s.wait_for_alert(1000)
|
||||
alerts = s.pop_alerts()
|
||||
a = alerts.pop(0)
|
||||
print(a)
|
||||
self.assertTrue(isinstance(a, lt.session_stats_alert))
|
||||
self.assertTrue(isinstance(a.values, dict))
|
||||
self.assertTrue(len(a.values) > 0)
|
||||
a = alerts.pop(0)
|
||||
print(a)
|
||||
self.assertTrue(isinstance(a, lt.session_stats_alert))
|
||||
self.assertTrue(isinstance(a.values, dict))
|
||||
self.assertTrue(len(a.values) > 0)
|
||||
|
||||
def test_post_dht_stats(self):
|
||||
s = lt.session({'alert_mask': lt.alert.category_t.stats_notification, 'enable_dht': False})
|
||||
s.post_dht_stats()
|
||||
alerts = []
|
||||
# first the stats headers log line. but not if logging is disabled
|
||||
time.sleep(1)
|
||||
alerts = s.pop_alerts()
|
||||
while len(alerts) == 0:
|
||||
s.wait_for_alert(1000)
|
||||
alerts = s.pop_alerts()
|
||||
a = alerts.pop(0)
|
||||
self.assertTrue(isinstance(a, lt.session_stats_header_alert))
|
||||
print(a.message())
|
||||
while len(alerts) == 0:
|
||||
s.wait_for_alert(1000)
|
||||
alerts = s.pop_alerts()
|
||||
a = alerts.pop(0)
|
||||
while not isinstance(a, lt.dht_stats_alert):
|
||||
a = alerts.pop(0
|
||||
)
|
||||
self.assertTrue(isinstance(a, lt.dht_stats_alert))
|
||||
self.assertTrue(isinstance(a.active_requests, list))
|
||||
self.assertTrue(isinstance(a.routing_table, list))
|
||||
|
|
|
@ -3,5 +3,4 @@
|
|||
import os
|
||||
|
||||
os.chdir('bindings/python')
|
||||
with open('setup.py') as filename:
|
||||
exec(filename.read())
|
||||
exec(open('setup.py').read())
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 26c08bd1dd6e3d7ff7b22aae3be43addcd6cd584
|
||||
Subproject commit 8905f8a0faec37ea0655fc2e7921fad40e904749
|
|
@ -286,7 +286,7 @@ TORRENT_EXPORT void assert_print(char const* fmt, ...)
|
|||
if (assert_counter > 500) return;
|
||||
|
||||
FILE* out = fopen(libtorrent_assert_log, "a+");
|
||||
if (out == 0) out = stderr;
|
||||
if (out == nullptr) out = stderr;
|
||||
#else
|
||||
FILE* out = stderr;
|
||||
#endif
|
||||
|
|
|
@ -626,12 +626,18 @@ namespace libtorrent { namespace dht {
|
|||
|
||||
void dht_tracker::add_node(udp::endpoint const& node)
|
||||
{
|
||||
#if !TORRENT_USE_IPV6
|
||||
TORRENT_ASSERT(is_v4(node));
|
||||
#endif
|
||||
for (auto& n : m_nodes)
|
||||
n.second.dht.add_node(node);
|
||||
}
|
||||
|
||||
void dht_tracker::add_router_node(udp::endpoint const& node)
|
||||
{
|
||||
#if !TORRENT_USE_IPV6
|
||||
TORRENT_ASSERT(is_v4(node));
|
||||
#endif
|
||||
for (auto& n : m_nodes)
|
||||
n.second.dht.add_router_node(node);
|
||||
}
|
||||
|
|
|
@ -1021,6 +1021,9 @@ void routing_table::node_failed(node_id const& nid, udp::endpoint const& ep)
|
|||
|
||||
void routing_table::add_router_node(udp::endpoint const& router)
|
||||
{
|
||||
#if !TORRENT_USE_IPV6
|
||||
TORRENT_ASSERT(is_v4(router));
|
||||
#endif
|
||||
m_router_nodes.insert(router);
|
||||
}
|
||||
|
||||
|
|
|
@ -730,7 +730,7 @@ namespace aux {
|
|||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
if (need_update_dht) update_dht();
|
||||
if (need_update_dht) start_dht();
|
||||
#endif
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
if (need_update_proxy) update_proxy();
|
||||
|
@ -3533,6 +3533,9 @@ namespace aux {
|
|||
void session_impl::add_dht_node(udp::endpoint const& n)
|
||||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
#if !TORRENT_USE_IPV6
|
||||
if (!is_v4(n)) return;
|
||||
#endif
|
||||
|
||||
if (m_dht) m_dht->add_node(n);
|
||||
else m_dht_nodes.push_back(n);
|
||||
|
@ -5303,7 +5306,20 @@ namespace aux {
|
|||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
if (m_settings.get_bool(settings_pack::enable_dht))
|
||||
start_dht();
|
||||
{
|
||||
if (!m_settings.get_str(settings_pack::dht_bootstrap_nodes).empty()
|
||||
&& m_dht_router_nodes.empty())
|
||||
{
|
||||
// if we have bootstrap nodes configured, make sure we initiate host
|
||||
// name lookups. once these complete, the DHT will be started.
|
||||
// they are tracked by m_outstanding_router_lookups
|
||||
update_dht_bootstrap_nodes();
|
||||
}
|
||||
else
|
||||
{
|
||||
start_dht();
|
||||
}
|
||||
}
|
||||
else
|
||||
stop_dht();
|
||||
#endif
|
||||
|
@ -5312,6 +5328,8 @@ namespace aux {
|
|||
void session_impl::update_dht_bootstrap_nodes()
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
if (!m_settings.get_bool(settings_pack::enable_dht)) return;
|
||||
|
||||
std::string const& node_list = m_settings.get_str(settings_pack::dht_bootstrap_nodes);
|
||||
std::vector<std::pair<std::string, int>> nodes;
|
||||
parse_comma_separated_string_port(node_list, nodes);
|
||||
|
@ -5630,6 +5648,8 @@ namespace aux {
|
|||
|
||||
stop_dht();
|
||||
|
||||
if (!m_settings.get_bool(settings_pack::enable_dht)) return;
|
||||
|
||||
// postpone starting the DHT if we're still resolving the DHT router
|
||||
if (m_outstanding_router_lookups > 0)
|
||||
{
|
||||
|
@ -5795,20 +5815,23 @@ namespace aux {
|
|||
m_alerts.emplace_alert<dht_error_alert>(
|
||||
operation_t::hostname_lookup, e);
|
||||
|
||||
if (m_outstanding_router_lookups == 0) update_dht();
|
||||
if (m_outstanding_router_lookups == 0) start_dht();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (auto const& addr : addresses)
|
||||
{
|
||||
#if !TORRENT_USE_IPV6
|
||||
if (!i->is_v4()) continue;
|
||||
#endif
|
||||
// router nodes should be added before the DHT is started (and bootstrapped)
|
||||
udp::endpoint ep(addr, std::uint16_t(port));
|
||||
if (m_dht) m_dht->add_router_node(ep);
|
||||
m_dht_router_nodes.push_back(ep);
|
||||
}
|
||||
|
||||
if (m_outstanding_router_lookups == 0) update_dht();
|
||||
if (m_outstanding_router_lookups == 0) start_dht();
|
||||
}
|
||||
|
||||
// callback for dht_immutable_get
|
||||
|
|
Loading…
Reference in New Issue