1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 20:22:30 +01:00

Fixup write_gather (Linux, BSD)

Split iovec into small portions (256 for now)
This commit is contained in:
Nekotekina 2021-03-09 14:02:07 +03:00
parent 19b5b47b26
commit a6350d5dd1

View File

@ -1301,10 +1301,19 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
static_assert(sizeof(iovec) == sizeof(iovec_clone), "Weird iovec size"); static_assert(sizeof(iovec) == sizeof(iovec_clone), "Weird iovec size");
static_assert(offsetof(iovec, iov_len) == offsetof(iovec_clone, iov_len), "Weird iovec::iov_len offset"); static_assert(offsetof(iovec, iov_len) == offsetof(iovec_clone, iov_len), "Weird iovec::iov_len offset");
iovec arg; u64 result = 0;
std::memcpy(&arg, buffers, sizeof(arg));
const auto result = ::writev(m_fd, &arg, buf_count); while (buf_count)
ensure(result != -1); // "file::write_gather" {
iovec arg[256];
const auto count = std::min<u64>(buf_count, 256);
std::memcpy(&arg, buffers, sizeof(iovec) * count);
const auto added = ::writev(m_fd, arg, count);
ensure(added != -1); // "file::write_gather"
result += added;
buf_count -= count;
buffers += count;
}
return result; return result;
} }