Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mmap error when reading empty file during resume check on Linux #7808

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
enhance test_checking with large files (to trigger mmap)
Doekin committed Dec 10, 2024

Verified

This commit was signed with the committer’s verified signature.
Adam- Adam
commit b98b8c7f3072a912720c3439ad118287058633e3
6 changes: 3 additions & 3 deletions test/test_checking.cpp
Original file line number Diff line number Diff line change
@@ -113,7 +113,7 @@ void test_checking(int const flags)
auto const file_sizes = (flags & single_file)
? std::vector<int>{500000}
: std::vector<int>{0, 5, 16 - 5, 16000, 17, 10, 8000, 8000, 1,1,1,1,1,100,1,1,1,1,100,1,1,1,1,1,1
,1,1,1,1,1,1,13,65000,34,75,2,30,400,50000,73000,900,43000,400,4300,6, 4 };
,1,1,1,1,1,1,13,65000,34,75,2,30,400,50000,73000,900,43000,400,4300,6, 4, 16384 * 100, 16384 * 200, 16384 * 100};

create_random_files("test_torrent_dir", file_sizes, &fs);

@@ -137,7 +137,7 @@ void test_checking(int const flags)
{
for (std::size_t i = 0; i < file_sizes.size(); ++i)
{
if ((i & 1) == 1) continue;
if ((i % 3) == 2) continue;
char name[1024];
std::snprintf(name, sizeof(name), "test%d", int(i));
char dirname[200];
@@ -147,7 +147,7 @@ void test_checking(int const flags)

std::int64_t const new_len = (flags & extended_files)
? file_sizes[i] + 10
: file_sizes[i] * 2 / 3;
: file_sizes[i] * static_cast<int>(i % 3) / 2;

int const ret = ::truncate(path.c_str(), new_len);
if (ret < 0)