fixes to mapped storage
This commit is contained in:
parent
7e83c3fc51
commit
d334022216
|
@ -187,7 +187,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_files.size() >= m_size && min != m_files.end())
|
if (int(m_files.size()) >= m_size && min != m_files.end())
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(min->references == 0);
|
TORRENT_ASSERT(min->references == 0);
|
||||||
min->file.close();
|
min->file.close();
|
||||||
|
@ -264,6 +264,10 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(offset < m_info->piece_size(slot));
|
TORRENT_ASSERT(offset < m_info->piece_size(slot));
|
||||||
TORRENT_ASSERT(size > 0);
|
TORRENT_ASSERT(size > 0);
|
||||||
|
|
||||||
|
size_type result = -1;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
std::vector<file_slice> slices
|
std::vector<file_slice> slices
|
||||||
= m_info->map_block(slot, offset, size, true);
|
= m_info->map_block(slot, offset, size, true);
|
||||||
|
@ -290,7 +294,7 @@ namespace libtorrent
|
||||||
m_save_path / file_iter->path, std::ios::in
|
m_save_path / file_iter->path, std::ios::in
|
||||||
, file_offset + file_iter->file_base, size, this
|
, file_offset + file_iter->file_base, size, this
|
||||||
, file_iter->size + file_iter->file_base);
|
, file_iter->size + file_iter->file_base);
|
||||||
|
|
||||||
if (!view.valid())
|
if (!view.valid())
|
||||||
{
|
{
|
||||||
m_error = "failed to open file '";
|
m_error = "failed to open file '";
|
||||||
|
@ -298,11 +302,11 @@ namespace libtorrent
|
||||||
m_error += "'for reading";
|
m_error += "'for reading";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
TORRENT_ASSERT(view.const_addr() != 0);
|
||||||
|
|
||||||
int left_to_read = size;
|
int left_to_read = size;
|
||||||
int slot_size = static_cast<int>(m_info->piece_size(slot));
|
|
||||||
int buf_pos = 0;
|
int buf_pos = 0;
|
||||||
size_type result = left_to_read;
|
result = left_to_read;
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -349,6 +353,7 @@ namespace libtorrent
|
||||||
fs::path path = m_save_path / file_iter->path;
|
fs::path path = m_save_path / file_iter->path;
|
||||||
|
|
||||||
file_offset = 0;
|
file_offset = 0;
|
||||||
|
|
||||||
view = m_pool.open_file(path, std::ios::in, file_offset + file_iter->file_base
|
view = m_pool.open_file(path, std::ios::in, file_offset + file_iter->file_base
|
||||||
, left_to_read, this
|
, left_to_read, this
|
||||||
, file_iter->size + file_iter->file_base);
|
, file_iter->size + file_iter->file_base);
|
||||||
|
@ -360,8 +365,16 @@ namespace libtorrent
|
||||||
m_error += "'for reading";
|
m_error += "'for reading";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
TORRENT_ASSERT(view.const_addr() != 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
m_error = e.what();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,6 +408,9 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
TORRENT_ASSERT(file_iter->size > 0);
|
TORRENT_ASSERT(file_iter->size > 0);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
mapped_file_pool::file_view view = m_pool.open_file(
|
mapped_file_pool::file_view view = m_pool.open_file(
|
||||||
m_save_path / file_iter->path, std::ios::in | std::ios::out
|
m_save_path / file_iter->path, std::ios::in | std::ios::out
|
||||||
, file_offset + file_iter->file_base, size, this
|
, file_offset + file_iter->file_base, size, this
|
||||||
|
@ -407,9 +423,9 @@ namespace libtorrent
|
||||||
m_error += "'for writing";
|
m_error += "'for writing";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
TORRENT_ASSERT(view.addr() != 0);
|
||||||
|
|
||||||
int left_to_write = size;
|
int left_to_write = size;
|
||||||
int slot_size = static_cast<int>(m_info->piece_size(slot));
|
|
||||||
int buf_pos = 0;
|
int buf_pos = 0;
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
@ -466,8 +482,15 @@ namespace libtorrent
|
||||||
m_error += "'for reading";
|
m_error += "'for reading";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
TORRENT_ASSERT(view.addr() != 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
m_error = e.what();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue