Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Jan 13, 2024
1 parent 798fc14 commit 4a46bb0
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/pread_disk_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ struct TORRENT_EXTRA_EXPORT pread_disk_io final
void abort_jobs();
void abort_hash_jobs(storage_index_t storage);

void try_flush_cache(int const target_cache_size
void try_flush_cache(int target_cache_size
, std::unique_lock<std::mutex>& l);
void flush_storage(std::shared_ptr<aux::pread_storage> const& storage);

Expand Down Expand Up @@ -465,7 +465,7 @@ TORRENT_EXPORT std::unique_ptr<disk_interface> pread_disk_io_constructor(
return status_t{};
}

status_t pread_disk_io::do_job(aux::job::write& a, aux::pread_disk_job* j)
status_t pread_disk_io::do_job(aux::job::write&, aux::pread_disk_job*)
{
TORRENT_ASSERT_FAIL();
return status_t{};
Expand Down Expand Up @@ -914,7 +914,6 @@ TORRENT_EXPORT std::unique_ptr<disk_interface> pread_disk_io_constructor(
std::ptrdiff_t const len2 = v2_block ? std::min(default_block_size, piece_size2 - offset) : 0;

hasher256 ph2;
int ret = 0;
char const* buf = blocks[i];
if (buf == nullptr)
{
Expand All @@ -928,12 +927,12 @@ TORRENT_EXPORT std::unique_ptr<disk_interface> pread_disk_io_constructor(
? (j->flags & ~disk_interface::flush_piece)
: j->flags;

ret = j->storage->hash(m_settings, ph, len, a.piece
j->storage->hash(m_settings, ph, len, a.piece
, offset, file_mode, flags, j->error);
}
if (v2_block)
{
ret = j->storage->hash2(m_settings, ph2, len2, a.piece, offset
j->storage->hash2(m_settings, ph2, len2, a.piece, offset
, file_mode, j->flags, j->error);
}
if (j->error) break;
Expand Down Expand Up @@ -1286,7 +1285,7 @@ TORRENT_EXPORT std::unique_ptr<disk_interface> pread_disk_io_constructor(

#if DEBUG_DISK_THREAD
{
piece_index_t piece = piece_index_t(-1);
auto piece = piece_index_t(-1);
std::string blocks_str;
blocks_str.reserve(blocks.size());
for (auto const& blk : blocks)
Expand All @@ -1298,6 +1297,8 @@ TORRENT_EXPORT std::unique_ptr<disk_interface> pread_disk_io_constructor(
TORRENT_ASSERT(piece != piece_index_t(-1));
DLOG("flush_cache_blocks: piece: %d hash_cursor: %d blocks: [%s]\n", int(piece), hash_cursor, blocks_str.c_str());
}
#else
TORRENT_UNUSED(hash_cursor);
#endif

// blocks may be sparse. We need to skip any block entry where write_job is null
Expand All @@ -1323,7 +1324,7 @@ TORRENT_EXPORT std::unique_ptr<disk_interface> pread_disk_io_constructor(
int end_offset = 0;

aux::open_mode_t file_mode;
piece_index_t piece = piece_index_t(-1);
auto piece = piece_index_t(-1);
disk_job_flags_t flags;

std::shared_ptr<aux::pread_storage> storage;
Expand Down Expand Up @@ -1365,7 +1366,7 @@ TORRENT_EXPORT std::unique_ptr<disk_interface> pread_disk_io_constructor(

if (error) {
// if there was a failure, fail the remaining jobs as well
for (std::size_t i = start_idx + count; i < blocks.size(); ++i)
for (int i = start_idx + count; i < blocks.size(); ++i)
{
auto* j2 = be.write_job;
j2->error = error;
Expand Down

0 comments on commit 4a46bb0

Please sign in to comment.