From 4ef221187f1690a126da533994afa7a5898bec57 Mon Sep 17 00:00:00 2001 From: xavier2k6 <42386382+xavier2k6@users.noreply.github.com> Date: Sun, 28 Jan 2024 14:16:58 +0000 Subject: [PATCH 1/9] Updated numerous action revisions --- .cirrus.yml | 2 +- .github/workflows/android.yml | 2 +- .github/workflows/cibuildwheel.yml | 10 +++++----- .github/workflows/cifuzz.yml | 2 +- .github/workflows/codeql.yml | 6 +++--- .github/workflows/docs.yml | 2 +- .github/workflows/linux.yml | 26 +++++++++++++------------- .github/workflows/macos.yml | 10 +++++----- .github/workflows/python.yml | 4 ++-- .github/workflows/windows.yml | 16 ++++++++-------- 10 files changed, 40 insertions(+), 40 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 4b555e97619..3856f66037d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -28,7 +28,7 @@ build_and_store_wheels: &BUILD_AND_STORE_WHEELS delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} install_cibuildwheel_script: - - $PYTHON -m pip install cibuildwheel==2.16.3 + - $PYTHON -m pip install cibuildwheel==2.16.5 run_cibuildwheel_script: - cibuildwheel diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 0bde4e70373..8754fa605b6 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -22,7 +22,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index 9002aac5cb7..1f9390eec3c 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -6,7 +6,7 @@ name: cibuildwheel # sample. # The full list of cibuildwheel's build targets can be found here: -# https://github.com/pypa/cibuildwheel/blob/v2.2.0a1/cibuildwheel/resources/build-platforms.toml +# https://github.com/pypa/cibuildwheel/blob/v2.16.5/cibuildwheel/resources/build-platforms.toml # Notes on build targets we (don't) support: # - pypy: libtorrent doesn't build with pypy as of writing @@ -91,20 +91,20 @@ jobs: CIBW_TEST_SKIP: "*-win32" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/cache@v3 + - uses: actions/cache@v4 id: cache-wheel with: path: wheelhouse key: wheel-${{ matrix.CIBW_BUILD }}-${{ matrix.CIBW_ARCHS }}-${{ github.sha }} - - uses: docker/setup-qemu-action@v2 + - uses: docker/setup-qemu-action@v3 if: steps.cache-wheel.outputs.cache-hit != 'true' && runner.os == 'Linux' - - uses: pypa/cibuildwheel@v2.12.3 + - uses: pypa/cibuildwheel@v2.16.5 if: steps.cache-wheel.outputs.cache-hit != 'true' - uses: actions/upload-artifact@v3 diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml index ced1c8ea2f2..b037caf409d 100644 --- a/.github/workflows/cifuzz.yml +++ b/.github/workflows/cifuzz.yml @@ -19,7 +19,7 @@ jobs: dry-run: false language: c++ - name: Upload Crash - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: failure() && steps.build.outcome == 'success' with: name: artifacts diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index cff419bacbb..489a6145d5f 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive @@ -43,7 +43,7 @@ jobs: ' - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} queries: +security-and-quality @@ -57,6 +57,6 @@ jobs: ' - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index bf6cc0ad37b..aa85ba9e175 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -17,7 +17,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: update package lists continue-on-error: true diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 28aba9eb6ca..7d030139b88 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -15,13 +15,13 @@ jobs: # TODO: matrix across python version and os runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: 3.8 - - uses: pre-commit/action@v3.0.0 + - uses: pre-commit/action@v3.0.1 build: name: build @@ -34,7 +34,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -87,7 +87,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -126,7 +126,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -159,7 +159,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -205,7 +205,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -248,7 +248,7 @@ jobs: b2 ${{ matrix.config }} -l500 warnings-as-errors=on debug-iterators=on invariant-checks=full asserts=on deterministic-tests - name: run tests (flaky) - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 30 retry_wait_seconds: 4 @@ -263,7 +263,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -305,7 +305,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -331,9 +331,9 @@ jobs: - name: build tarball run: AAFIGURE=~/.local/bin/aafigure RST2HTML=rst2html make dist - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: - name: tarball + name: tarball-${{ matrix.os }} path: libtorrent-rasterbar-*.tar.gz - name: test-tarball (b2 install) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index b61b276566a..e32e053acaf 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -22,7 +22,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -41,7 +41,7 @@ jobs: run: (cd test; b2 ${{ matrix.config }} -l400 warnings-as-errors=on debug-iterators=on invariant-checks=full asserts=on deterministic-tests) - name: run tests (flaky) - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 30 retry_wait_seconds: 1 @@ -55,7 +55,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -87,7 +87,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -114,7 +114,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 70a0e49aff0..01e19e759ca 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -20,7 +20,7 @@ jobs: os: [ubuntu-20.04, macos-latest, windows-latest ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true @@ -66,7 +66,7 @@ jobs: - name: install openssl (windows) if: runner.os == 'Windows' - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: shell: cmd timeout_minutes: 5 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 3cd0f584d02..760ef6b3267 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -29,12 +29,12 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true - name: install openssl (64 bit) - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 30 retry_wait_seconds: 4 @@ -82,7 +82,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -116,7 +116,7 @@ jobs: b2 --hash release address-model=64 link=static debug-iterators=off invariant-checks=on define=BOOST_ASIO_DISABLE_IOCP asserts=on testing.execute=off - name: run sims - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: max_attempts: 3 timeout_minutes: 120 @@ -138,7 +138,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true @@ -149,7 +149,7 @@ jobs: bootstrap.bat - name: install openssl (64 bit) - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 30 retry_wait_seconds: 4 @@ -195,12 +195,12 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true - name: install openssl (64 bit) - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 30 retry_wait_seconds: 4 From 44d1a9c0c78eb2377157157572e39bc9cdad9c18 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 11 Mar 2024 12:58:12 +0100 Subject: [PATCH 2/9] back-port fixes to brew on CI --- .github/workflows/macos.yml | 4 ++++ .github/workflows/python.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index e32e053acaf..d6ad03092f0 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -9,6 +9,10 @@ concurrency: group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }} cancel-in-progress: true +env: + HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 + HOMEBREW_NO_AUTO_UPDATE: 1 + jobs: test: diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 01e19e759ca..834ef091925 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -9,6 +9,10 @@ concurrency: group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }} cancel-in-progress: true +env: + HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 + HOMEBREW_NO_AUTO_UPDATE: 1 + jobs: test: From 31003b7c8d08ba2e4b5956f3e2c0cfab6da7bdd5 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 11 Mar 2024 14:45:52 +0100 Subject: [PATCH 3/9] fix setup.py to not use distutils (as it has been removed in python 3.12) --- .github/workflows/python.yml | 2 +- bindings/python/setup.py | 47 +++++++++--------------------------- 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 834ef091925..6072e41e496 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -31,7 +31,7 @@ jobs: - name: dependencies (MacOS) if: runner.os == 'macOS' run: | - brew install boost-build boost boost-python3 python@3.12 openssl@1.1 + brew install boost-build boost boost-python3 python@3.12 openssl@1.1 python-setuptools export PATH=$(brew --prefix)/opt/python@3.12/bin:$PATH - name: update package lists (linux) diff --git a/bindings/python/setup.py b/bindings/python/setup.py index 0eb07c2b5c6..d720c475beb 100644 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -1,14 +1,9 @@ #!/usr/bin/env python3 import contextlib -from distutils import log -import distutils.cmd -import distutils.command.install_data as install_data_lib -import distutils.debug -import distutils.errors -import distutils.sysconfig import functools import itertools +import logging as log import os import pathlib import re @@ -75,11 +70,11 @@ def b2_version() -> Tuple[int, ...]: class B2Distribution(setuptools.Distribution): def reinitialize_command( self, command: str, reinit_subcommands: int = 0 - ) -> distutils.cmd.Command: + ) -> setuptools.Command: if command == "build_ext": - return cast(distutils.cmd.Command, self.get_command_obj("build_ext")) + return cast(setuptools.Command, self.get_command_obj("build_ext")) return cast( - distutils.cmd.Command, + setuptools.Command, super().reinitialize_command( command, reinit_subcommands=reinit_subcommands ), @@ -155,13 +150,11 @@ def write_b2_python_config( # other words we apply debian's override everywhere, and hope no other # overrides ever disagree with us. - # Note that sysconfig and distutils.sysconfig disagree here, especially on - # windows. - ext_suffix = distutils.sysconfig.get_config_var("EXT_SUFFIX") + ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") ext_suffix = str(ext_suffix or "") # python.jam appends the platform-specific final suffix on its own. I can't - # find a consistent value from sysconfig or distutils.sysconfig for this. + # find a consistent value from sysconfig for this. for plat_suffix in (".pyd", ".dll", ".so", ".sl"): if ext_suffix.endswith(plat_suffix): ext_suffix = ext_suffix[: -len(plat_suffix)] @@ -271,7 +264,7 @@ def finalize_options(self) -> None: super().finalize_options() if self.config_mode not in self.CONFIG_MODES: - raise distutils.errors.DistutilsOptionError( + raise setuptools.errors.DistutilsOptionError( f"--config-mode must be one of {self.CONFIG_MODES}" ) @@ -382,10 +375,10 @@ def _configure_b2_with_distutils(self) -> Iterator[None]: if os.name == "nt": self._maybe_add_arg("--abbreviate-paths") - if distutils.debug.DEBUG: - self._maybe_add_arg("--debug-configuration") - self._maybe_add_arg("--debug-building") - self._maybe_add_arg("--debug-generators") + # if distutils.debug.DEBUG: + # self._maybe_add_arg("--debug-configuration") + # self._maybe_add_arg("--debug-building") + # self._maybe_add_arg("--debug-generators") if sys.platform == "darwin": # boost.build defaults to toolset=clang on mac. However python.jam @@ -411,7 +404,7 @@ def _configure_b2_with_distutils(self) -> Iterator[None]: # macOS uses multi-arch binaries. Attempt to match the # configuration of the running python by translating distutils # platform modes to b2 architecture modes - machine = distutils.util.get_platform().split("-")[-1] + machine = sysconfig.get_platform().split("-")[-1] if machine == "arm64": self._maybe_add_arg("architecture=arm") elif machine in ("ppc", "ppc64"): @@ -500,21 +493,6 @@ def _find_project_config(self) -> Optional[pathlib.Path]: return None -class InstallDataToLibDir(install_data_lib.install_data): - def finalize_options(self) -> None: - # install_data installs to the *base* directory, which is useless. - # Nothing ever gets installed there, no tools search there. You could - # only make use of it by manually picking the right install paths. - # This instead defaults the "install_dir" option to be "install_lib", - # which is "where packages are normally installed". - self.set_undefined_options( - "install", - ("install_lib", "install_dir"), # note "install_lib" - ("root", "root"), - ("force", "force"), - ) - - def find_all_files(path: str) -> Iterator[str]: for dirpath, _, filenames in os.walk(path): for filename in filenames: @@ -532,7 +510,6 @@ def find_all_files(path: str) -> Iterator[str]: ext_modules=[StubExtension("libtorrent.__init__")], cmdclass={ "build_ext": LibtorrentBuildExt, - "install_data": InstallDataToLibDir, }, distclass=B2Distribution, data_files=[ From e539df0cc8e2a81e1c47a6efa1ba2297dbb2f0ea Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 11 Mar 2024 12:21:17 +0100 Subject: [PATCH 4/9] fix integer overflow in piece picker --- ChangeLog | 2 ++ include/libtorrent/piece_picker.hpp | 12 ++++++------ test/test_piece_picker.cpp | 12 ++++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4dde420529c..c360e37a614 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ + 2.0.11 not released + * fix integer overflow in piece picker * torrent_status::num_pieces counts pieces passed hash check, as documented 2.0.10 released diff --git a/include/libtorrent/piece_picker.hpp b/include/libtorrent/piece_picker.hpp index c90158e5578..e493e1d8a2b 100644 --- a/include/libtorrent/piece_picker.hpp +++ b/include/libtorrent/piece_picker.hpp @@ -83,7 +83,7 @@ namespace libtorrent { int num_pieces; // the number of bytes, out of those pieces, that are pad // files - int pad_bytes; + std::int64_t pad_bytes; // true if the last piece is part of the set bool last_piece; }; @@ -540,7 +540,7 @@ namespace libtorrent { void record_downloading_piece(piece_index_t const p); - int num_pad_bytes() const { return m_num_pad_bytes; } + std::int64_t num_pad_bytes() const { return m_num_pad_bytes; } span mutable_blocks_for_piece(downloading_piece const& dp); @@ -815,16 +815,16 @@ namespace libtorrent { mutable std::vector m_recent_extents; // the number of bytes of pad file set in this piece picker - int m_num_pad_bytes = 0; + std::int64_t m_num_pad_bytes = 0; // the number of pad blocks that we already have - int m_have_pad_bytes = 0; + std::int64_t m_have_pad_bytes = 0; // the number of pad blocks part of filtered pieces we don't have - int m_filtered_pad_bytes = 0; + std::int64_t m_filtered_pad_bytes = 0; // the number of pad blocks we have that are also filtered - int m_have_filtered_pad_bytes = 0; + std::int64_t m_have_filtered_pad_bytes = 0; // the number of seeds. These are not added to // the availability counters of the pieces diff --git a/test/test_piece_picker.cpp b/test/test_piece_picker.cpp index 9b8f3b3d215..7b78ba6794b 100644 --- a/test/test_piece_picker.cpp +++ b/test/test_piece_picker.cpp @@ -2076,6 +2076,18 @@ TORRENT_TEST(set_pad_bytes) TEST_EQUAL(blocks[3].state, piece_picker::block_info::state_finished); } +TORRENT_TEST(set_pad_bytes_overflow) +{ + int const ps = file_storage::max_piece_size; + auto p = setup_picker("11111111111", " ", "44444444444", "", ps); + p->set_pad_bytes(0_piece, ps - 1); + p->set_pad_bytes(2_piece, ps - 1); + p->set_pad_bytes(4_piece, ps - 1); + p->set_pad_bytes(6_piece, ps - 1); + + TEST_EQUAL(p->want().pad_bytes, std::int64_t(ps - 1) * 4); +} + TORRENT_TEST(pad_bytes_in_piece_bytes) { for (int i = 1; i < 10; ++i) From c4c0c53f32af662cdf051ad3bbd67fa5eb9c4638 Mon Sep 17 00:00:00 2001 From: Martin Rodriguez Reboredo Date: Sat, 2 Mar 2024 12:55:24 -0300 Subject: [PATCH 5/9] Send read_piece right at the end of piece_passed --- src/torrent.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/torrent.cpp b/src/torrent.cpp index f81054bc21f..3ec5361de54 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -4412,10 +4412,6 @@ namespace { inc_stats_counter(counters::num_piece_passed); -#ifndef TORRENT_DISABLE_STREAMING - remove_time_critical_piece(index, true); -#endif - if (settings().get_int(settings_pack::suggest_mode) == settings_pack::suggest_read_cache) { @@ -4463,6 +4459,10 @@ namespace { m_picker->piece_passed(index); update_gauge(); we_have(index); + +#ifndef TORRENT_DISABLE_STREAMING + remove_time_critical_piece(index, true); +#endif } #ifndef TORRENT_DISABLE_PREDICTIVE_PIECES From 64c817961b8a68edee019fd30f41209466ac2506 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 16 Mar 2024 14:27:41 +0100 Subject: [PATCH 6/9] add test for recent set_piece_deadline fix --- test/test_transfer.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/test_transfer.cpp b/test/test_transfer.cpp index 8059e2f0229..fbfc0901cae 100644 --- a/test/test_transfer.cpp +++ b/test/test_transfer.cpp @@ -58,6 +58,7 @@ using std::ignore; namespace { int peer_disconnects = 0; +int read_piece_alerts = 0; bool on_alert(alert const* a) { @@ -66,6 +67,11 @@ bool on_alert(alert const* a) ++peer_disconnects; else if (alert_cast(a)) ++peer_disconnects; + else if (auto rp = alert_cast(a)) + { + ++read_piece_alerts; + TORRENT_ASSERT(!rp->error); + } return false; } @@ -75,6 +81,7 @@ using transfer_flags_t = lt::flags::bitfield_flag; constexpr transfer_flags_t delete_files = 2_bit; constexpr transfer_flags_t move_storage = 3_bit; +constexpr transfer_flags_t piece_deadline = 4_bit; void test_transfer(int proxy_type, settings_pack const& sett , transfer_flags_t flags = {} @@ -197,6 +204,7 @@ void test_transfer(int proxy_type, settings_pack const& sett wait_for_listen(ses2, "ses2"); peer_disconnects = 0; + read_piece_alerts = 0; // test using piece sizes smaller than 16kB std::tie(tor1, tor2, ignore) = setup_transfer(&ses1, &ses2, nullptr @@ -205,6 +213,16 @@ void test_transfer(int proxy_type, settings_pack const& sett int num_pieces = tor2.torrent_file()->num_pieces(); std::vector priorities(std::size_t(num_pieces), 1); + if (flags & piece_deadline) + { + int deadline = 1; + for (auto const p : t->piece_range()) + { + ++deadline; + tor2.set_piece_deadline(p, deadline, lt::torrent_handle::alert_when_available); + } + } + lt::time_point const start_time = lt::clock_type::now(); static char const* state_str[] = @@ -268,6 +286,11 @@ void test_transfer(int proxy_type, settings_pack const& sett std::this_thread::sleep_for(lt::milliseconds(100)); } + if (flags & piece_deadline) + { + TEST_CHECK(read_piece_alerts > 0); + } + if (!(flags & delete_files)) { TEST_CHECK(tor2.status().is_seeding); @@ -341,6 +364,13 @@ TORRENT_TEST(move_storage) cleanup(); } +TORRENT_TEST(piece_deadline) +{ + using namespace lt; + test_transfer(0, settings_pack(), piece_deadline); + cleanup(); +} + TORRENT_TEST(delete_files) { using namespace lt; From 8a7aa8311387b8d530a2ec2a3eb5974fec5edb64 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 16 Mar 2024 14:28:13 +0100 Subject: [PATCH 7/9] update Changelog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index c360e37a614..6289511f372 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2.0.11 not released + * 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 From 250f216a329d6582e61e8ed46429319525218884 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 21 Apr 2024 18:04:14 +0200 Subject: [PATCH 8/9] default target windows 10 --- CMakeLists.txt | 2 +- Jamfile | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91be804fdf9..4b82f369862 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -620,7 +620,7 @@ if (WIN32) debug dbghelp crypt32 ) - add_definitions(-D_WIN32_WINNT=0x0601) # target Windows 7 or later + add_definitions(-D_WIN32_WINNT=0x0A00) # target Windows 10 or later target_compile_definitions(torrent-rasterbar PUBLIC WIN32_LEAN_AND_MEAN # prevent winsock1 to be included diff --git a/Jamfile b/Jamfile index 4d66ce837f7..1c897067807 100644 --- a/Jamfile +++ b/Jamfile @@ -68,6 +68,17 @@ rule linking ( properties * ) result += dbghelp ; } + if windows in $(properties) + { + switch [ feature.get-values : $(properties) ] + { + case xp : result += _WIN32_WINNT=0x0501 ; + case vista : result += _WIN32_WINNT=0x0600 ; + case win7 : result += _WIN32_WINNT=0x0601 ; + case win10 : result += _WIN32_WINNT=0x0A00 ; + } + } + # gcrypt libraries, if enabled if gcrypt in $(properties) { @@ -578,11 +589,7 @@ feature.compose on : TORRENT_USE_ASSERTS=1 ; feature.compose production : TORRENT_USE_ASSERTS=1 TORRENT_PRODUCTION_ASSERTS=1 ; feature.compose system : TORRENT_USE_ASSERTS=1 TORRENT_USE_SYSTEM_ASSERTS=1 ; -feature windows-version : win7 win10 vista xp : composite propagated ; -feature.compose vista : _WIN32_WINNT=0x0600 ; -feature.compose win7 : _WIN32_WINNT=0x0601 ; -feature.compose win10 : _WIN32_WINNT=0x0A00 ; -feature.compose xp : _WIN32_WINNT=0x0501 ; +feature windows-version : win10 vista xp win7 : composite propagated ; feature extensions : on off : composite propagated link-incompatible ; feature.compose off : TORRENT_DISABLE_EXTENSIONS ; From 15078572f2f99028025b60d516231ded7a215f55 Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Mon, 8 Apr 2024 21:48:13 +0800 Subject: [PATCH 9/9] Make anti-leech choker never increase score for dishonesty The current anti-leech choker takes the maximum of client-reported have and our own session uploaded size as the progress of the client. This may paradoxically inflate the score of dishonest clients if we've been uploading to it for long enough, that our uploaded size exceeds 50% of the total size. This commit caps "given_size" to 50% of total_size, so that the above- mentioned situation can never happen. --- src/choker.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/choker.cpp b/src/choker.cpp index 297ec1653eb..732e303363a 100644 --- a/src/choker.cpp +++ b/src/choker.cpp @@ -167,7 +167,10 @@ namespace { std::int64_t const total_size = t->torrent_file().total_size(); if (total_size == 0) return 0; - std::int64_t const have_size = std::max(peer->statistics().total_payload_upload() + // Cap the given_size so that it never causes the score to increase + std::int64_t const given_size = std::min(peer->statistics().total_payload_upload() + , total_size / 2); + std::int64_t const have_size = std::max(given_size , std::int64_t(t->torrent_file().piece_length()) * peer->num_have_pieces()); return int(std::abs((have_size - total_size / 2) * 2000 / total_size)); }