more storage::hash_for_slot fixes

This commit is contained in:
Arvid Norberg 2009-09-05 16:32:54 +00:00
parent 3e77baa9a4
commit 562450f545
1 changed files with 7 additions and 5 deletions

View File

@ -499,8 +499,9 @@ namespace libtorrent
ph.h.update((char const*)bufs[i].iov_base, small_piece_size);
*small_hash = hasher(ph.h).final();
small_hash = 0; // avoid this case again
ph.h.update((char const*)bufs[i].iov_base + small_piece_size
, bufs[i].iov_len - small_piece_size);
if (bufs[i].iov_len > small_piece_size)
ph.h.update((char const*)bufs[i].iov_base + small_piece_size
, bufs[i].iov_len - small_piece_size);
}
else
{
@ -523,13 +524,14 @@ namespace libtorrent
int ret = m_storage->readv(&buf, slot, ph.offset, 1);
if (ret > 0) num_read += ret;
if (small_hash && small_piece_size < block_size)
if (small_hash && small_piece_size <= block_size)
{
if (small_piece_size > 0) ph.h.update((char const*)buf.iov_base, small_piece_size);
*small_hash = hasher(ph.h).final();
small_hash = 0; // avoid this case again
ph.h.update((char const*)buf.iov_base + small_piece_size
, buf.iov_len - small_piece_size);
if (buf.iov_len > small_piece_size)
ph.h.update((char const*)buf.iov_base + small_piece_size
, buf.iov_len - small_piece_size);
}
else
{