Skip to content

Commit 081365f

Browse files
committed
merge RC_1_1 into master
2 parents 97c8d04 + 5a19c9a commit 081365f

13 files changed

+158
-27
lines changed

ChangeLog

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
* resume data no longer has timestamps of files
5858
* require C++11 to build libtorrent
5959

60+
1.1.2 release
61+
62+
* default TOS marking to 0x20
6063
* fix invalid access when leaving seed-mode with outstanding hash jobs
6164
* fix ABI compatibility issue introduced with preformatted entry type
6265
* add web_seed_name_lookup_retry to session_settings

bindings/python/src/create_torrent.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <libtorrent/create_torrent.hpp>
77
#include <libtorrent/file_storage.hpp>
88
#include "libtorrent/torrent_info.hpp"
9+
#include <libtorrent/version.hpp>
910
#include "bytes.hpp"
1011

1112
using namespace boost::python;

bindings/python/src/error_code.cpp

+70
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,81 @@ namespace boost
4545
}
4646
}
4747

48+
#include <boost/asio/error.hpp>
49+
#if defined TORRENT_USE_OPENSSL
50+
#include <boost/asio/ssl/error.hpp>
51+
#endif
4852
#include "boost_python.hpp"
4953

5054
using namespace boost::python;
5155
using namespace libtorrent;
5256
using boost::system::error_category;
5357

58+
namespace {
59+
60+
struct ec_pickle_suite : boost::python::pickle_suite
61+
{
62+
static boost::python::tuple
63+
getinitargs(error_code const& ec)
64+
{
65+
return boost::python::tuple();
66+
}
67+
68+
static boost::python::tuple
69+
getstate(error_code const& ec)
70+
{
71+
return boost::python::make_tuple(ec.value(), ec.category().name());
72+
}
73+
74+
static void
75+
setstate(error_code& ec, boost::python::tuple state)
76+
{
77+
using namespace boost::python;
78+
if (len(state) != 2)
79+
{
80+
PyErr_SetObject(PyExc_ValueError,
81+
("expected 2-item tuple in call to __setstate__; got %s"
82+
% state).ptr());
83+
throw_error_already_set();
84+
}
85+
86+
int const value = extract<int>(state[0]);
87+
std::string const category = extract<std::string>(state[1]);
88+
if (category == "system")
89+
ec.assign(value, libtorrent::system_category());
90+
else if (category == "generic")
91+
ec.assign(value, libtorrent::generic_category());
92+
else if (category == "libtorrent")
93+
ec.assign(value, libtorrent::libtorrent_category());
94+
else if (category == "http error")
95+
ec.assign(value, libtorrent::http_category());
96+
else if (category == "UPnP error")
97+
ec.assign(value, libtorrent::upnp_category());
98+
else if (category == "bdecode error")
99+
ec.assign(value, libtorrent::bdecode_category());
100+
else if (category == "asio.netdb")
101+
ec.assign(value, boost::asio::error::get_netdb_category());
102+
else if (category == "asio.addinfo")
103+
ec.assign(value, boost::asio::error::get_addrinfo_category());
104+
else if (category == "asio.misc")
105+
ec.assign(value, boost::asio::error::get_misc_category());
106+
else if (category == "asio.misc")
107+
ec.assign(value, boost::asio::error::get_misc_category());
108+
#if defined TORRENT_USE_OPENSSL
109+
else if (category == "asio.ssl")
110+
ec.assign(value, boost::asio::error::get_ssl_category());
111+
#endif
112+
else
113+
{
114+
PyErr_SetObject(PyExc_ValueError,
115+
("unexpected error_category passed to __setstate__; got '%s'"
116+
% object(category)).ptr());
117+
throw_error_already_set();
118+
}
119+
}
120+
};
121+
}
122+
54123
void bind_error_code()
55124
{
56125
using boost::noncopyable;
@@ -71,6 +140,7 @@ void bind_error_code()
71140
.def("category", &error_code::category
72141
, return_value_policy<reference_existing_object>())
73142
.def("assign", &error_code::assign)
143+
.def_pickle(ec_pickle_suite())
74144
;
75145

76146
using return_existing = return_value_policy<reference_existing_object>;

bindings/python/src/torrent_handle.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ list trackers(torrent_handle& h)
247247
d["url"] = i->url;
248248
d["trackerid"] = i->trackerid;
249249
d["message"] = i->message;
250-
d["last_error"] = i->last_error;
250+
dict last_error;
251+
last_error["value"] = i->last_error.value();
252+
last_error["category"] = i->last_error.category().name();
253+
d["last_error"] = last_error;
251254
d["next_announce"] = i->next_announce;
252255
d["min_announce"] = i->min_announce;
253256
d["scrape_incomplete"] = i->scrape_incomplete;

bindings/python/test.py

+23
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import subprocess as sub
1515
import sys
1616
import inspect
17+
import pickle
1718

1819
# include terminal interface for travis parallel executions of scripts which use
1920
# terminal features: fix multiple stdin assignment at termios.tcgetattr
@@ -88,6 +89,20 @@ def test_replace_trackers(self):
8889
self.assertEqual(new_trackers[1]['tier'], 1)
8990
self.assertEqual(new_trackers[1]['fail_limit'], 2)
9091

92+
def test_pickle_trackers(self):
93+
"""Test lt objects convertors are working and trackers can be pickled"""
94+
self.setup()
95+
tracker = lt.announce_entry('udp://tracker1.com')
96+
tracker.tier = 0
97+
tracker.fail_limit = 1
98+
trackers = [tracker]
99+
self.h.replace_trackers(trackers)
100+
tracker_list = [tracker for tracker in self.h.trackers()]
101+
pickled_trackers = pickle.dumps(tracker_list)
102+
unpickled_trackers = pickle.loads(pickled_trackers)
103+
self.assertEqual(unpickled_trackers[0]['url'], 'udp://tracker1.com')
104+
self.assertEqual(unpickled_trackers[0]['last_error']['value'], 0)
105+
91106
def test_file_status(self):
92107
self.setup()
93108
l = self.h.file_status()
@@ -109,6 +124,13 @@ def test_status_last_uploaded_dowloaded(self):
109124
self.assertLessEqual(abs(st.last_upload - sessionStart), datetime.timedelta(seconds=1))
110125
self.assertLessEqual(abs(st.last_download - sessionStart), datetime.timedelta(seconds=1))
111126

127+
def test_serialize_trackers(self):
128+
"""Test to ensure the dict contains only python built-in types"""
129+
self.setup()
130+
self.h.add_tracker({'url':'udp://tracker1.com'})
131+
import json
132+
print(json.dumps(self.h.trackers()[0]))
133+
112134
def test_torrent_status(self):
113135
self.setup()
114136
st = self.h.status()
@@ -257,6 +279,7 @@ def test_announce_entry(self):
257279
self.assertEquals(ae.can_announce(False), True)
258280
self.assertEquals(ae.scrape_incomplete, -1)
259281
self.assertEquals(ae.next_announce, None)
282+
self.assertEquals(ae.last_error.value(), 0)
260283

261284
class test_alerts(unittest.TestCase):
262285

examples/Makefile.am

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ client_test_SOURCES = client_test.cpp print.cpp session_view.cpp torrent_view.cp
2020
stats_counters_SOURCES = stats_counters.cpp
2121
bt_get_SOURCES = bt-get.cpp
2222
bt_get2_SOURCES = bt-get2.cpp
23+
bt_get_CXXFLAGS = -std=c++11
24+
bt_get2_CXXFLAGS = -std=c++11
2325
dump_torrent_SOURCES = dump_torrent.cpp
2426
make_torrent_SOURCES = make_torrent.cpp
2527
simple_client_SOURCES = simple_client.cpp

include/libtorrent/create_torrent.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ POSSIBILITY OF SUCH DAMAGE.
4141
#include "libtorrent/string_view.hpp"
4242
#include "libtorrent/aux_/vector.hpp"
4343
#include "libtorrent/file.hpp" // for combine_path etc.
44-
#include "libtorrent/version.hpp"
4544

4645
#include <vector>
4746
#include <string>

include/libtorrent/settings_pack.hpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -793,27 +793,9 @@ namespace libtorrent
793793
// low number, like 5
794794
urlseed_pipeline_size,
795795

796-
// The maximum request range of an url seed in bytes. This value
797-
// defines the largest possible sequential web seed request. Default
798-
// is 16 * 1024 * 1024. Lower values are possible but will be ignored
799-
// if they are lower then piece size.
800-
// This value should be related to your download speed to prevent
801-
// libtorrent from creating too many expensive http requests per
802-
// second. You can select a value as high as you want but keep in mind
803-
// that libtorrent can't create parallel requests if the first request
804-
// did already select the whole file.
805-
// If you combine bittorrent seeds with web seeds and pick strategies
806-
// like rarest first you may find your web seed requests split into
807-
// smaller parts because we don't download already picked pieces
808-
// twice.
809-
urlseed_max_request_bytes,
810-
811796
// time to wait until a new retry of a web seed takes place
812797
urlseed_wait_retry,
813798

814-
// time to wait until a new retry of a web seed name lookup
815-
web_seed_name_lookup_retry,
816-
817799
// sets the upper limit on the total number of files this session will
818800
// keep open. The reason why files are left open at all is that some
819801
// anti virus software hooks on every file close, and scans the file
@@ -1618,6 +1600,24 @@ namespace libtorrent
16181600
// them in the cache is limited.
16191601
cache_size_volatile,
16201602

1603+
// The maximum request range of an url seed in bytes. This value
1604+
// defines the largest possible sequential web seed request. Default
1605+
// is 16 * 1024 * 1024. Lower values are possible but will be ignored
1606+
// if they are lower then piece size.
1607+
// This value should be related to your download speed to prevent
1608+
// libtorrent from creating too many expensive http requests per
1609+
// second. You can select a value as high as you want but keep in mind
1610+
// that libtorrent can't create parallel requests if the first request
1611+
// did already select the whole file.
1612+
// If you combine bittorrent seeds with web seeds and pick strategies
1613+
// like rarest first you may find your web seed requests split into
1614+
// smaller parts because we don't download already picked pieces
1615+
// twice.
1616+
urlseed_max_request_bytes,
1617+
1618+
// time to wait until a new retry of a web seed name lookup
1619+
web_seed_name_lookup_retry,
1620+
16211621
max_int_setting_internal
16221622
};
16231623

src/settings_pack.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@ namespace libtorrent
211211
SET(peer_timeout, 120, nullptr),
212212
SET(urlseed_timeout, 20, nullptr),
213213
SET(urlseed_pipeline_size, 5, nullptr),
214-
SET(urlseed_max_request_bytes, 16 * 1024 * 1024, 0),
215214
SET(urlseed_wait_retry, 30, nullptr),
216-
SET(web_seed_name_lookup_retry, 1800, nullptr),
217215
SET(file_pool_size, 40, nullptr),
218216
SET(max_failcount, 3, &session_impl::update_max_failcount),
219217
SET(min_reconnect_time, 60, nullptr),
@@ -240,7 +238,7 @@ namespace libtorrent
240238
SET(disk_io_read_mode, settings_pack::enable_os_cache, nullptr),
241239
SET(outgoing_port, 0, nullptr),
242240
SET(num_outgoing_ports, 0, nullptr),
243-
SET(peer_tos, 0, &session_impl::update_peer_tos),
241+
SET(peer_tos, 0x20, &session_impl::update_peer_tos),
244242
SET(active_downloads, 3, &session_impl::trigger_auto_manage),
245243
SET(active_seeds, 5, &session_impl::trigger_auto_manage),
246244
SET(active_checking, 1, &session_impl::trigger_auto_manage),
@@ -326,7 +324,9 @@ namespace libtorrent
326324
SET(proxy_type, settings_pack::none, &session_impl::update_proxy),
327325
SET(proxy_port, 0, &session_impl::update_proxy),
328326
SET(i2p_port, 0, &session_impl::update_i2p_bridge),
329-
SET(cache_size_volatile, 256, nullptr)
327+
SET(cache_size_volatile, 256, nullptr),
328+
SET(urlseed_max_request_bytes, 16 * 1024 * 1024, 0),
329+
SET(web_seed_name_lookup_retry, 1800, nullptr),
330330
}});
331331

332332
#undef SET

src/torrent.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10724,7 +10724,7 @@ namespace libtorrent
1072410724
st->pieces.resize(num_pieces, false);
1072510725
}
1072610726
st->num_pieces = num_have();
10727-
st->num_seeds = num_seeds();
10727+
st->num_seeds = num_seeds() - int(m_num_connecting_seeds);
1072810728
if ((flags & torrent_handle::query_distributed_copies) && m_picker.get())
1072910729
{
1073010730
std::tie(st->distributed_full_copies, st->distributed_fraction) =

src/torrent_info.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ namespace libtorrent
136136
res = ConvertUTF32toUTF8(const_cast<const UTF32**>(&cp), cp + 1, &start, start + 5, lenientConversion);
137137
TORRENT_ASSERT(res == conversionOK);
138138

139-
for (int i = 0; i < start - sequence; ++i)
139+
for (int i = 0; i < std::min(5, int(start - sequence)); ++i)
140140
tmp_path += char(sequence[i]);
141141
}
142142

test/test.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ int print_failures()
8989
std::printf("\x1b[0m");
9090

9191
if (total_num_failures > 0)
92-
std::printf("\n\n\x1b[41m == %d TEST(S) FAILED ==\x1b[0m\n\n\n", total_num_failures);
92+
std::printf("\n\n\x1b[41m == %d TEST(S) FAILED ==\x1b[0m\n\n\n"
93+
, total_num_failures);
9394
return total_num_failures;
9495
}
9596

test/test_settings_pack.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,32 @@ TORRENT_TEST(load_pack_from_dict)
226226
TEST_EQUAL(p2.get_int(settings_pack::max_out_request_queue), 1337);
227227
TEST_EQUAL(p2.get_bool(settings_pack::send_redundant_have), false);
228228
}
229+
230+
TORRENT_TEST(settings_pack_abi)
231+
{
232+
// make sure enum values are preserved across libtorrent versions
233+
// for ABI compatibility
234+
// These values are only allowed to change across major versions
235+
236+
TEST_EQUAL(settings_pack::string_type_base, 0x0000);
237+
TEST_EQUAL(settings_pack::int_type_base, 0x4000);
238+
TEST_EQUAL(settings_pack::bool_type_base, 0x8000);
239+
TEST_EQUAL(settings_pack::type_mask, 0xc000);
240+
241+
// strings
242+
TEST_EQUAL(settings_pack::outgoing_interfaces, settings_pack::string_type_base + 4);
243+
TEST_EQUAL(settings_pack::dht_bootstrap_nodes, settings_pack::string_type_base + 11);
244+
245+
// bool
246+
TEST_EQUAL(settings_pack::lazy_bitfields, settings_pack::bool_type_base + 3);
247+
TEST_EQUAL(settings_pack::use_read_cache, settings_pack::bool_type_base + 7);
248+
TEST_EQUAL(settings_pack::proxy_tracker_connections, settings_pack::bool_type_base + 67);
249+
250+
// ints
251+
TEST_EQUAL(settings_pack::max_suggest_pieces, settings_pack::int_type_base + 66);
252+
TEST_EQUAL(settings_pack::connections_slack, settings_pack::int_type_base + 86);
253+
TEST_EQUAL(settings_pack::aio_threads, settings_pack::int_type_base + 104);
254+
TEST_EQUAL(settings_pack::max_http_recv_buffer_size, settings_pack::int_type_base + 115);
255+
TEST_EQUAL(settings_pack::web_seed_name_lookup_retry, settings_pack::int_type_base + 128);
256+
}
257+

0 commit comments

Comments
 (0)