merged unaligned write fix over from RC_0_15

This commit is contained in:
Arvid Norberg 2011-11-02 04:45:22 +00:00
parent 92661b2a71
commit ca9122861a
1 changed files with 5 additions and 2 deletions

View File

@ -1343,12 +1343,13 @@ ret:
TORRENT_ASSERT((aligned_size & size_align) == 0);
size_type actual_file_size = file_handle->get_size(ec);
if (ec) return -1;
if (ec && ec != make_error_code(boost::system::errc::no_such_file_or_directory)) return -1;
// allocate a temporary, aligned, buffer
aligned_holder aligned_buf(aligned_size);
file::iovec_t b = {aligned_buf.get(), aligned_size};
if (aligned_start < actual_file_size) // we have something to read
// we have something to read
if (aligned_start < actual_file_size && !ec)
{
size_type ret = file_handle->readv(aligned_start, &b, 1, ec);
if (ret < 0)
@ -1358,6 +1359,8 @@ ret:
}
}
ec.clear();
// OK, we read the portion of the file. Now, overlay the buffer we're writing
char* write_buf = aligned_buf.get() + start_adjust;