Skip to content

Commit

Permalink
Merge branch 'RC_2_0'
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Oct 1, 2024
2 parents b1fd3ed + aee6a8e commit 2784433
Show file tree
Hide file tree
Showing 40 changed files with 261 additions and 112 deletions.
7 changes: 6 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@

2.0.11 not released

* limit piece size in torrent creator
* fix file pre-allocation when changing file priority (HanabishiRecca)
* fix uTP issue where closing the connection could corrupt the payload
* apply DSCP/TOS to sockets before initiating the TCP connection
* assume copy_file_range() exists on linux (unless old glibc)
* fix issue where set_piece_deadline() did not correctly post read_piece_alert
* fix integer overflow in piece picker
* torrent_status::num_pieces counts pieces passed hash check, as documented
* check settings_pack::max_out_request_queue before performance alert

2.0.10 released

Expand Down Expand Up @@ -182,7 +187,7 @@
2.0 released

* dropped dependency on iconv
* deprecate set_file_hash() in torrent creator, as it's superceded by v2 torrents
* deprecate set_file_hash() in torrent creator, as it's superseded by v2 torrents
* deprecate mutable access to info_section in torrent_info
* removed deprecated lazy_entry/lazy_bdecode
* stats_alert deprecated
Expand Down
2 changes: 1 addition & 1 deletion Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ rule linking ( properties * )
else if [ version.version-less $(jam-version) : 1990 0 ]
{
# the visibility feature was introduced in boost-1.69. This was close to
# when the verisoning scheme changed from year to (low) version numbers.
# when the versioning scheme changed from year to (low) version numbers.
# in boost-1.70
result += <visibility>hidden ;
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ feature.compose <libtorrent-python-pic>on : <cxxflags>-fPIC ;
feature python-install-path : : free path ;

# when not specifying a custom install path, this controls whether to install
# the python module in the system directory or user-specifc directory
# the python module in the system directory or user-specific directory
feature python-install-scope : user system : ;

feature auto-ptr : off on : composite propagated ;
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/src/alert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ void bind_alert()
;

#if TORRENT_ABI_VERSION == 1
enum_<listen_succeeded_alert::socket_type_t>("listen_succeded_alert_socket_type_t")
enum_<listen_succeeded_alert::socket_type_t>("listen_succeeded_alert_socket_type_t")
.value("tcp", listen_succeeded_alert::socket_type_t::tcp)
.value("tcp_ssl", listen_succeeded_alert::socket_type_t::tcp_ssl)
.value("udp", listen_succeeded_alert::socket_type_t::udp)
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/LibtorrentMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endmacro()
# target_optional_compile_definitions(<target> [FEATURE]
# NAME <name> DESCRIPTION <description> DEFAULT <default_value>
# [ENABLED [enabled_compile_definitions...]]
# [DISABLED [disabled_compile_defnitions...]]
# [DISABLED [disabled_compile_definitions...]]
# )
# NAME, DESCRIPTION and DEFAULT are passed to option() call
# if FEATURE is given, they are passed to add_feature_info()
Expand Down
2 changes: 1 addition & 1 deletion examples/connection_tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void generate_block(span<std::uint32_t> buffer, piece_index_t const piece
for (auto& w : buffer) w = fill;
}

// in order to circumvent the restricton of only
// in order to circumvent the restriction of only
// one connection per IP that most clients implement
// all sockets created by this tester are bound to
// unique local IPs in the range (127.0.0.1 - 127.255.255.255)
Expand Down
2 changes: 1 addition & 1 deletion include/libtorrent/aux_/hash_picker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ namespace libtorrent::aux

// this is for a future per-block request feature
#if 0
// blocks are only added to this list if there is a time critial block which
// blocks are only added to this list if there is a time critical block which
// has been downloaded but we don't have its hash or if the initial request
// for the hash was rejected
// this block hash will be requested from every peer possible until the hash
Expand Down
2 changes: 1 addition & 1 deletion include/libtorrent/aux_/merkle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace libtorrent {
// if we're inserting the hash N, the uncle hashes provide proof of it being
// valid by containing 0, 1 and two (as marked in the tree above)
// Any non-zero hash encountered in target_tree is assumed to be valid, and
// will termiate the validation early, either successful (if there's a
// will terminate the validation early, either successful (if there's a
// match) or unsuccessful (if there's a mismatch).
TORRENT_EXTRA_EXPORT
bool merkle_validate_and_insert_proofs(span<sha256_hash> target_tree
Expand Down
2 changes: 1 addition & 1 deletion include/libtorrent/aux_/peer_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ namespace libtorrent::aux {
int max_out_request_queue() const;

std::time_t last_seen_complete() const { return m_last_seen_complete; }
void set_last_seen_complete(int ago) { m_last_seen_complete = ::time(nullptr) - ago; }
void set_last_seen_complete(int ago) { m_last_seen_complete = aux::posix_time() - ago; }

std::int64_t uploaded_in_last_round() const
{ return m_statistics.total_payload_upload() - m_uploaded_at_last_round; }
Expand Down
3 changes: 2 additions & 1 deletion include/libtorrent/aux_/posix_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ namespace aux {
, storage_error& error);

bool has_any_file(storage_error& error);
void set_file_priority(aux::vector<download_priority_t, file_index_t>& prio
void set_file_priority(settings_interface const&
, aux::vector<download_priority_t, file_index_t>& prio
, storage_error& ec);
bool verify_resume_data(add_torrent_params const& rd
, aux::vector<std::string, file_index_t> const& links
Expand Down
3 changes: 3 additions & 0 deletions include/libtorrent/aux_/time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ namespace libtorrent { namespace aux {

TORRENT_EXTRA_EXPORT std::time_t to_time_t(time_point32 tp);
TORRENT_EXTRA_EXPORT time_point32 from_time_t(std::time_t t);

// returns the current posix time (UTC)
TORRENT_EXTRA_EXPORT time_t posix_time();
} }

#endif
4 changes: 2 additions & 2 deletions include/libtorrent/aux_/torrent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,8 +1115,8 @@ namespace libtorrent::aux {

void write_resume_data(resume_data_flags_t const flags, add_torrent_params& ret) const;

void seen_complete() { m_last_seen_complete = ::time(nullptr); }
int time_since_complete() const { return int(::time(nullptr) - m_last_seen_complete); }
void seen_complete() { m_last_seen_complete = aux::posix_time(); }
int time_since_complete() const { return int(aux::posix_time() - m_last_seen_complete); }
time_t last_seen_complete() const { return m_last_seen_complete; }

template <typename Fun, typename... Args>
Expand Down
2 changes: 2 additions & 0 deletions include/libtorrent/create_torrent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ TORRENT_VERSION_NAMESPACE_4
// The ``piece_size`` is the size of each piece in bytes. It must be a
// power of 2 and a minimum of 16 kiB. If a piece size of 0 is
// specified, a piece_size will be set automatically.
// Piece sizes greater than 128 MiB are considered unreasonable and will
// be rejected (with an lt::system_error exception).
//
// The ``flags`` arguments specifies options for the torrent creation. It can
// be any combination of the flags defined by create_flags_t.
Expand Down
33 changes: 23 additions & 10 deletions simulation/setup_swarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ using namespace sim;

#define DEBUG_SWARM 0

#if DEBUG_SWARM
#include <cstdio>
#include "libtorrent/aux_/file_pointer.hpp"
#endif

constexpr swarm_test_t swarm_test::download;
constexpr swarm_test_t swarm_test::upload;
constexpr swarm_test_t swarm_test::no_auto_stop;
Expand Down Expand Up @@ -311,6 +316,12 @@ void setup_swarm(int num_nodes
// line
#if DEBUG_SWARM == 0
if (i != 0) return;
#else
char path[200];
lt::error_code ignore;
lt::create_directory("logs", ignore);
std::snprintf(path, sizeof(path), "logs/node-%d.log", i);
lt::aux::file_pointer log_output(::fopen(path, "a"));
#endif

for (lt::alert* a : alerts)
Expand All @@ -320,25 +331,27 @@ void setup_swarm(int num_nodes
std::uint32_t const millis = std::uint32_t(
lt::duration_cast<lt::milliseconds>(d).count());

#if DEBUG_SWARM != 0
std::fprintf(log_output.file(),
"%4u.%03u: %-25s %s\n"
, millis / 1000, millis % 1000
, a->what()
, a->message().c_str());

// the behavior of the test itself should not be affected by
// whether we're printing logs for all nodes
if (i != 0) continue;
#endif
// when debugging, we print *all* alerts to the log
if (should_print(a))
{
std::printf(
#if DEBUG_SWARM != 0
"[%d] "
#endif
"%4u.%03u: %-25s %s\n"
#if DEBUG_SWARM != 0
, i
#endif
, millis / 1000, millis % 1000
, a->what()
, a->message().c_str());
}

#if DEBUG_SWARM != 0
if (i != 0) continue;
#endif

// if a torrent was added save the torrent handle
if (lt::add_torrent_alert* at = lt::alert_cast<lt::add_torrent_alert>(a))
{
Expand Down
2 changes: 1 addition & 1 deletion simulation/test_web_seed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ TORRENT_TEST(urlseed_timeout)
// check for correct handle of unexpected http status response.
// with disabled "close_redundant_connections" alive web server connection
// may be closed in such manner.
TORRENT_TEST(no_close_redudant_webseed)
TORRENT_TEST(no_close_redundant_webseed)
{
using namespace lt;

Expand Down
11 changes: 9 additions & 2 deletions src/create_torrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ see LICENSE file.
#include "libtorrent/session.hpp" // for default_disk_io_constructor
#include "libtorrent/aux_/directory.hpp"
#include "libtorrent/aux_/bencoder.hpp"
#include "libtorrent/aux_/time.hpp" // for posix_time

#include <sys/types.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -559,7 +560,7 @@ TORRENT_VERSION_NAMESPACE_4
, create_flags_t const flags)
: m_files(std::move(files))
, m_total_size(compute_total_size(m_files))
, m_creation_date(::time(nullptr))
, m_creation_date(aux::posix_time())
, m_multifile(m_files.size() > 1)
, m_private(false)
, m_include_mtime(bool(flags & create_torrent::modification_time))
Expand Down Expand Up @@ -628,6 +629,12 @@ TORRENT_VERSION_NAMESPACE_4
aux::throw_ex<system_error>(errors::invalid_piece_size);
}

// this is an unreasonably large piece size. Some clients don't support
// pieces this large.
if (piece_size > 128 * 1024 * 1024) {
aux::throw_ex<system_error>(errors::invalid_piece_size);
}

m_piece_length = piece_size;
TORRENT_ASSERT(m_piece_length > 0);
if (!(flags & v1_only)
Expand All @@ -644,7 +651,7 @@ TORRENT_VERSION_NAMESPACE_4
, m_piece_length(ti.piece_length())
, m_num_pieces(ti.num_pieces())
, m_name(ti.name())
, m_creation_date(::time(nullptr))
, m_creation_date(aux::posix_time())
, m_multifile(ti.num_files() > 1)
, m_private(ti.priv())
, m_include_mtime(false)
Expand Down
2 changes: 1 addition & 1 deletion src/hash_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool validate_hash_request(hash_request const& hr, file_storage const& fs)
{
// limit the size of the base layer to something reasonable
// Blocks are requested for an entire piece so this limit
// effectivly caps the piece size we can handle. A limit of 8192
// effectively caps the piece size we can handle. A limit of 8192
// corresponds to a piece size of 128MB.

if (hr.file < file_index_t{0}
Expand Down
38 changes: 3 additions & 35 deletions src/ip_notifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,6 @@ struct ip_change_notifier_impl final : ip_change_notifier
netlink::socket m_socket;
std::array<char, 4096> m_buf;

struct local_address
{
int family;
std::array<char, 16> data;
};
// maps if_index to the most recently advertised local address
// this is used to filter duplicate updates
std::unordered_map<std::uint32_t, local_address> m_state;

void on_notify(int len, std::function<void(error_code const& ec)> cb)
{
bool pertinent = false;
Expand All @@ -161,33 +152,10 @@ struct ip_change_notifier_impl final : ip_change_notifier
nlmsg_ok (nh, len);
nh = nlmsg_next(nh, len))
{
if (nh->nlmsg_type != RTM_NEWADDR)
if (nh->nlmsg_type != RTM_NEWADDR &&
nh->nlmsg_type != RTM_DELADDR)
continue;

auto const* addr_msg = static_cast<ifaddrmsg const*>(nlmsg_data(nh));
std::uint32_t const index = addr_msg->ifa_index;
int const family = addr_msg->ifa_family;
std::size_t attr_len = ifa_payload(nh);
auto const* rta_ptr = ifa_rta(addr_msg);

for (; rta_ok(rta_ptr, attr_len); rta_ptr = rta_next(rta_ptr, attr_len))
{
auto* const ptr = rta_data(rta_ptr);
if (rta_ptr->rta_type != IFA_LOCAL)
continue;

auto& existing = m_state[index];
std::size_t const address_len = family == AF_INET ? 4 : 16;
if (existing.family == family
&& std::memcmp(&existing.data, ptr, address_len) == 0)
{
break;
}

existing.family = family;
std::memcpy(existing.data.data(), ptr, address_len);
pertinent = true;
}
pertinent = true;
}

if (!pertinent)
Expand Down
2 changes: 1 addition & 1 deletion src/kademlia/routing_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ routing_table::add_node_status_t routing_table::add_node_impl(node_entry e)
existing->update_rtt(e.rtt);
existing->last_queried = e.last_queried;
}
// if this was a replacement node it may be elligible for
// if this was a replacement node it may be eligible for
// promotion to the live bucket
fill_from_replacements(existing_bucket);
prune_empty_bucket();
Expand Down
Loading

0 comments on commit 2784433

Please sign in to comment.