Skip to content

Commit

Permalink
merged RC_2_0 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Oct 26, 2024
2 parents b8eb7ed + 1b8dc12 commit baba7ff
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 104 deletions.
70 changes: 45 additions & 25 deletions .github/workflows/cibuildwheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.16.5/cibuildwheel/resources/build-platforms.toml
# https://github.com/pypa/cibuildwheel/blob/v2.21.3/cibuildwheel/resources/build-platforms.toml

# Notes on build targets we (don't) support:
# - pypy: libtorrent doesn't build with pypy as of writing
Expand Down Expand Up @@ -45,22 +45,31 @@ jobs:
MATRIX_PULL_REQUEST: |
{
"include": [
{"os": "ubuntu-latest", "CIBW_BUILD": "cp39-manylinux_*", "CIBW_ARCHS": "x86_64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp39-musllinux_*", "CIBW_ARCHS": "x86_64"},
{"os": "macos-12", "CIBW_BUILD": "cp39-*", "CIBW_ARCHS": "x86_64"},
{"os": "windows-2022", "CIBW_BUILD": "cp39-*", "CIBW_ARCHS": "AMD64"}
{"os": "ubuntu-latest", "CIBW_BUILD": "cp39-manylinux_x86_64", "CIBW_ARCHS_LINUX": "x86_64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp39-manylinux_aarch64", "CIBW_ARCHS_LINUX": "aarch64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp39-musllinux_x86_64", "CIBW_ARCHS_LINUX": "x86_64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp39-musllinux_aarch64", "CIBW_ARCHS_LINUX": "aarch64"},
{"os": "macos-12", "CIBW_BUILD": "cp39-macosx_x86_64", "CIBW_ARCHS_MACOS": "x86_64", "MACOSX_DEPLOYMENT_TARGET": "12"},
{"os": "macos-13", "CIBW_BUILD": "cp39-macosx_x86_64", "CIBW_ARCHS_MACOS": "x86_64", "MACOSX_DEPLOYMENT_TARGET": "13"},
{"os": "macos-14", "CIBW_BUILD": "cp39-macosx_arm64", "CIBW_ARCHS_MACOS": "arm64", "MACOSX_DEPLOYMENT_TARGET": "14"},
{"os": "macos-15", "CIBW_BUILD": "cp39-macosx_arm64", "CIBW_ARCHS_MACOS": "arm64", "MACOSX_DEPLOYMENT_TARGET": "15"},
{"os": "windows-latest", "CIBW_BUILD": "cp39-win32", "CIBW_ARCHS_WINDOWS": "x86"},
{"os": "windows-latest", "CIBW_BUILD": "cp39-win_amd64", "CIBW_ARCHS_WINDOWS": "AMD64"}
]
}
MATRIX_WORKFLOW_DISPATCH: |
{
"include": [
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-manylinux_*", "CIBW_ARCHS": "x86_64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-manylinux_*", "CIBW_ARCHS": "aarch64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-musllinux_*", "CIBW_ARCHS": "x86_64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-musllinux_*", "CIBW_ARCHS": "aarch64"},
{"os": "macos-12", "CIBW_BUILD": "cp*", "CIBW_ARCHS": "x86_64"},
{"os": "windows-2022", "CIBW_BUILD": "cp*", "CIBW_ARCHS": "x86"},
{"os": "windows-2022", "CIBW_BUILD": "cp*", "CIBW_ARCHS": "AMD64"}
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-manylinux_x86_64", "CIBW_ARCHS_LINUX": "x86_64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-manylinux_aarch64", "CIBW_ARCHS_LINUX": "aarch64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-musllinux_x86_64", "CIBW_ARCHS_LINUX": "x86_64"},
{"os": "ubuntu-latest", "CIBW_BUILD": "cp*-musllinux_aarch64", "CIBW_ARCHS_LINUX": "aarch64"},
{"os": "macos-12", "CIBW_BUILD": "cp*-macosx_x86_64", "CIBW_ARCHS_MACOS": "x86_64", "MACOSX_DEPLOYMENT_TARGET": "12"},
{"os": "macos-13", "CIBW_BUILD": "cp*-macosx_x86_64", "CIBW_ARCHS_MACOS": "x86_64", "MACOSX_DEPLOYMENT_TARGET": "13"},
{"os": "macos-14", "CIBW_BUILD": "cp*-macosx_arm64", "CIBW_ARCHS_MACOS": "arm64", "MACOSX_DEPLOYMENT_TARGET": "14"},
{"os": "macos-15", "CIBW_BUILD": "cp*-macosx_arm64", "CIBW_ARCHS_MACOS": "arm64", "MACOSX_DEPLOYMENT_TARGET": "15"},
{"os": "windows-latest", "CIBW_BUILD": "cp*-win32", "CIBW_ARCHS_WINDOWS": "x86"},
{"os": "windows-latest", "CIBW_BUILD": "cp*-win_amd64", "CIBW_ARCHS_WINDOWS": "AMD64"}
]
}
Expand All @@ -87,7 +96,11 @@ jobs:
env:
CIBW_BUILD_VERBOSITY: 1
CIBW_BUILD: ${{ matrix.CIBW_BUILD }}
CIBW_ARCHS: ${{ matrix.CIBW_ARCHS }}
CIBW_ARCHS_LINUX: ${{ matrix.CIBW_ARCHS_LINUX }}
CIBW_ARCHS_WINDOWS: ${{ matrix.CIBW_ARCHS_WINDOWS }}
CIBW_ARCHS_MACOS: ${{ matrix.CIBW_ARCHS_MACOS }}
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.MACOSX_DEPLOYMENT_TARGET }}
CIBW_SKIP: pp*
CIBW_TEST_SKIP: "*-win32"

steps:
Expand All @@ -101,50 +114,57 @@ jobs:
id: cache-wheel
with:
path: wheelhouse
key: wheel-${{ matrix.CIBW_BUILD }}-${{ matrix.CIBW_ARCHS }}-${{ github.sha }}
key: wheel-${{ matrix.os }}-${{ matrix.CIBW_BUILD }}

- uses: docker/setup-qemu-action@v3
if: steps.cache-wheel.outputs.cache-hit != 'true' && runner.os == 'Linux'

- uses: pypa/[email protected]
- name: Install OpenSSL (win32)
if: ${{ endsWith(matrix.CIBW_BUILD, 'win32') }}
run: |
Remove-Item -Path "C:\Program Files\OpenSSL" -Force -Recurse
vcpkg install openssl:x86-windows
New-Item -Path "C:\Program Files\OpenSSL" -ItemType SymbolicLink -Value "C:\vcpkg\packages\openssl_x86-windows\"
- uses: pypa/[email protected]
if: steps.cache-wheel.outputs.cache-hit != 'true'

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
path: wheelhouse/*.whl
name: wheels
name: wheels-${{ matrix.os }}-${{ matrix.CIBW_BUILD }}

upload_pypi:
needs: build_wheels
runs-on: ubuntu-latest
if: needs.build_wheels.result == 'success' && github.event.inputs.publish == 'PUBLISH'

steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: wheels
name: wheels-${{ matrix.os }}-${{ matrix.CIBW_BUILD }}
path: wheelhouse

- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse
skip_existing: true
packages-dir: wheelhouse
skip-existing: true

upload_pypi_test:
needs: build_wheels
runs-on: ubuntu-latest
if: needs.build_wheels.result == 'success' && github.event.inputs.publish_test == 'PUBLISH_TEST'

steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: wheels
name: wheels-${{ matrix.os }}-${{ matrix.CIBW_BUILD }}
path: wheelhouse

- uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
packages_dir: wheelhouse
skip_existing: true
packages-dir: wheelhouse
skip-existing: true
repository_url: https://test.pypi.org/legacy/
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

2.0.11 not released

* fix bug where file_progress could sometimes be reported as >100%
* don't hint FADV_RANDOM on posix systems. May improve seeding performance
* allow boost connect while checking resume data if no_verify_files flag is set
* fix BEP-40 peer priority for IPv6
Expand Down
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
requires-python = ">=3.7"
requires-python = ">=3.9"

[tool.cibuildwheel]
manylinux-i686-image = "manylinux2014"
Expand All @@ -25,8 +25,7 @@ test-command = [
[tool.cibuildwheel.macos.environment]
BOOST_BUILD_PATH = "/tmp/boost/tools/build"
BOOST_ROOT = "/tmp/boost"
BOOST_VERSION = "1.81.0"
MACOSX_DEPLOYMENT_TARGET = "12"
BOOST_VERSION = "1.83.0"
PATH = "/tmp/boost:$PATH"

[[tool.cibuildwheel.overrides]]
Expand All @@ -48,7 +47,7 @@ test-command = [
[tool.cibuildwheel.overrides.environment] # sub-table of previous block!
BOOST_BUILD_PATH = "/tmp/boost/tools/build"
BOOST_ROOT = "/tmp/boost"
BOOST_VERSION = "1.81.0"
BOOST_VERSION = "1.83.0"
PATH = "/usr/local/ccache/bin:/tmp/boost:$PATH"

[[tool.cibuildwheel.overrides]]
Expand All @@ -69,7 +68,7 @@ test-command = [
[tool.cibuildwheel.overrides.environment] # sub-table of previous block!
BOOST_BUILD_PATH = "/tmp/boost/tools/build"
BOOST_ROOT = "/tmp/boost"
BOOST_VERSION = "1.81.0"
BOOST_VERSION = "1.83.0"
PATH = "/usr/lib/ccache/bin:/tmp/boost:$PATH"

[[tool.cibuildwheel.overrides]]
Expand All @@ -90,7 +89,7 @@ test-command = '''bash -c "cd '{project}/bindings/python' && python -m pip insta
[tool.cibuildwheel.windows.environment]
BOOST_BUILD_PATH = 'c:/boost/tools/build'
BOOST_ROOT = 'c:/boost'
BOOST_VERSION = "1.81.0"
BOOST_VERSION = "1.83.0"
PATH = 'c:/boost;$PATH'

[tool.isort]
Expand Down
2 changes: 1 addition & 1 deletion src/alert_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace libtorrent::aux {
#ifndef TORRENT_DISABLE_EXTENSIONS
void alert_manager::add_extension(std::shared_ptr<plugin> ext)
{
m_ses_extensions.push_back(ext);
m_ses_extensions.push_back(std::move(ext));
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/disk_buffer_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace {
if (m_exceeded_max_size)
{
exceeded = true;
if (o) m_observers.push_back(o);
if (o) m_observers.push_back(std::move(o));
}
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/file_pool_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace libtorrent::aux {
{
FileEntry e = open_file_impl(p, file_index, fs, m, file_key
#if TORRENT_HAVE_MAP_VIEW_OF_FILE
, open_unmap_lock
, std::move(open_unmap_lock)
#endif
);

Expand Down
4 changes: 2 additions & 2 deletions src/mmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ file_mapping::file_mapping(file_handle file, open_mode_t const mode, std::int64_
#endif
;
if (advise != 0)
madvise(m_mapping, static_cast<std::size_t>(m_size), advise);
::madvise(m_mapping, static_cast<std::size_t>(m_size), advise);
}
#endif
}
Expand All @@ -204,7 +204,7 @@ file_mapping::file_mapping(file_handle file, open_mode_t const mode
, std::shared_ptr<std::mutex> open_unmap_lock)
: m_size(memory_map_size(mode, file_size, file))
, m_file(std::move(file), mode, m_size)
, m_open_unmap_lock(open_unmap_lock)
, m_open_unmap_lock(std::move(open_unmap_lock))
, m_mapping((mode & open_mode::no_mmap) ? nullptr
: MapViewOfFile(m_file.handle(), map_access(mode), 0, 0, static_cast<std::size_t>(m_size)))
{
Expand Down
2 changes: 1 addition & 1 deletion src/peer_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ namespace {
void peer_connection::add_extension(std::shared_ptr<peer_plugin> ext)
{
TORRENT_ASSERT(is_single_thread());
m_extensions.push_back(ext);
m_extensions.push_back(std::move(ext));
}

peer_plugin const* peer_connection::find_plugin(string_view type)
Expand Down
20 changes: 16 additions & 4 deletions src/torrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1486,19 +1486,20 @@ bool is_downloading_state(int const st)

void torrent::add_extension(std::shared_ptr<torrent_plugin> ext)
{
m_extensions.push_back(ext);
m_extensions.push_back(std::move(ext));
auto& ext_ref = m_extensions.back();

for (auto* p : m_connections)
{
TORRENT_INCREMENT(m_iterating_connections);
std::shared_ptr<peer_plugin> pp(ext->new_connection(peer_connection_handle(p->self())));
std::shared_ptr<peer_plugin> pp(ext_ref->new_connection(peer_connection_handle(p->self())));
if (pp) p->add_extension(std::move(pp));
}

// if files are checked for this torrent, call the extension
// to let it initialize itself
if (m_connections_initialized)
ext->on_files_checked();
ext_ref->on_files_checked();
}

void torrent::remove_extension(std::shared_ptr<torrent_plugin> ext)
Expand All @@ -1514,7 +1515,7 @@ bool is_downloading_state(int const st)
std::shared_ptr<torrent_plugin> tp(ext(get_handle(), userdata));
if (!tp) return;

add_extension(tp);
add_extension(std::move(tp));
}

#endif
Expand Down Expand Up @@ -2239,6 +2240,9 @@ bool is_downloading_state(int const st)
continue;
}

if (has_piece_passed(piece))
continue;

// being in seed mode and missing a piece is not compatible.
// Leave seed mode if that happens
if (m_seed_mode) leave_seed_mode(seed_mode_t::skip_checking);
Expand Down Expand Up @@ -11565,6 +11569,12 @@ namespace {
file_storage const& fs = m_torrent_file->files();
for (auto const& dp : q)
{
if (has_piece_passed(dp.index))
{
// in this case this piece has already been accounted for in fp
continue;
}

std::int64_t offset = std::int64_t(static_cast<int>(dp.index))
* m_torrent_file->piece_length();
file_index_t file = fs.file_index_at_offset(offset);
Expand Down Expand Up @@ -11620,6 +11630,7 @@ namespace {
TORRENT_ASSERT(offset <= fs.file_offset(file) + fs.file_size(file));
std::int64_t const slice = std::min(fs.file_offset(file) + fs.file_size(file) - offset
, block);
TORRENT_ASSERT(fp[file] <= fs.file_size(file) - slice);
fp[file] += slice;
offset += slice;
block -= slice;
Expand All @@ -11641,6 +11652,7 @@ namespace {
}
else
{
TORRENT_ASSERT(fp[file] <= fs.file_size(file) - block);
fp[file] += block;
offset += block_size();
}
Expand Down
2 changes: 1 addition & 1 deletion src/tracker_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ namespace libtorrent::aux {
{
TORRENT_ASSERT(is_single_thread());
m_udp_conns.erase(c->transaction_id());
m_udp_conns[tid] = c;
m_udp_conns[tid] = std::move(c);
}

void tracker_manager::queue_request(
Expand Down
Loading

0 comments on commit baba7ff

Please sign in to comment.