minor disk_io_job piece_hash cleanup

This commit is contained in:
arvidn 2017-10-22 15:24:12 +02:00 committed by Arvid Norberg
parent 74ecf63906
commit 98effc8d88
3 changed files with 7 additions and 7 deletions

View File

@ -156,7 +156,7 @@ namespace libtorrent {
{
un() {}
// result for hash jobs
char piece_hash[20];
sha1_hash piece_hash;
// this is used for check_fastresume to pass in a vector of hard-links
// to create. Each element corresponds to a file in the file_storage.

View File

@ -60,7 +60,7 @@ namespace libtorrent {
void operator()(disk_io_job::hash_handler& h) const
{
if (!h) return;
h(m_job.piece, sha1_hash(m_job.d.piece_hash), m_job.error);
h(m_job.piece, m_job.d.piece_hash, m_job.error);
}
void operator()(disk_io_job::move_handler& h) const

View File

@ -1792,7 +1792,7 @@ constexpr disk_job_flags_t disk_interface::cache_hit;
if (pe != nullptr && !pe->hashing && pe->hash && pe->hash->offset == piece_size)
{
sha1_hash result = pe->hash->h.final();
std::memcpy(j->d.piece_hash, result.data(), 20);
j->d.piece_hash = result;
pe->hash.reset();
@ -2140,7 +2140,7 @@ constexpr disk_job_flags_t disk_interface::cache_hit;
for (auto i = hash_jobs.iterate(); i.get(); i.next())
{
disk_io_job* hj = i.get();
std::memcpy(hj->d.piece_hash, result.data(), 20);
hj->d.piece_hash = result;
hj->ret = status_t::no_error;
}
@ -2201,7 +2201,7 @@ constexpr disk_job_flags_t disk_interface::cache_hit;
m_disk_cache.free_buffer(iov.data());
sha1_hash piece_hash = h.final();
std::memcpy(j->d.piece_hash, piece_hash.data(), 20);
j->d.piece_hash = piece_hash;
return ret >= 0 ? status_t::no_error : status_t::fatal_disk_error;
}
@ -2237,7 +2237,7 @@ constexpr disk_job_flags_t disk_interface::cache_hit;
{
DLOG("do_hash: (%d) (already done)\n", int(pe->piece));
sha1_hash piece_hash = pe->hash->h.final();
std::memcpy(j->d.piece_hash, piece_hash.data(), 20);
j->d.piece_hash = piece_hash;
pe->hash.reset();
if (pe->cache_state != cached_piece_entry::volatile_read_lru)
pe->hashing_done = 1;
@ -2432,7 +2432,7 @@ constexpr disk_job_flags_t disk_interface::cache_hit;
if (ret == status_t::no_error)
{
sha1_hash piece_hash = ph->h.final();
std::memcpy(j->d.piece_hash, piece_hash.data(), 20);
j->d.piece_hash = piece_hash;
pe->hash.reset();
if (pe->cache_state != cached_piece_entry::volatile_read_lru)