htc: fixes for WriteFileLarge/sending over data channel

This commit is contained in:
Michael Scire 2021-02-16 17:15:57 -08:00 committed by SciresM
parent 7621bd4e13
commit f0ef9fb918
3 changed files with 10 additions and 4 deletions

View File

@ -429,11 +429,13 @@ namespace ams::htcfs {
R_TRY(this->CheckResponseHeader(response, request.packet_type));
/* Check the response body size. */
R_UNLESS(response.body_size > 0, htcfs::ResultUnexpectedResponseBodySize());
R_UNLESS(response.body_size >= 0, htcfs::ResultUnexpectedResponseBodySize());
R_UNLESS(static_cast<size_t>(response.body_size) <= MaxPacketBodySize, htcfs::ResultUnexpectedResponseBodySize());
/* Receive the response body. */
R_TRY(this->ReceiveFromRpcChannel(m_packet_buffer, response.body_size));
if (response.body_size > 0) {
R_TRY(this->ReceiveFromRpcChannel(m_packet_buffer, response.body_size));
}
/* Check that we succeeded. */
R_TRY(ConvertHtcfsResult(response.params[0]));
@ -1332,7 +1334,7 @@ namespace ams::htcfs {
m_header_factory.MakeWriteFileLargeHeader(std::addressof(request), handle, option.value, offset, buffer_size, DataChannelId);
/* Send the request to the host. */
R_TRY(this->SendRequest(request, buffer, buffer_size));
R_TRY(this->SendRequest(request));
/* Receive response from the host. */
R_TRY(this->ReceiveFromRpcChannel(std::addressof(response), sizeof(response)));
@ -1537,4 +1539,5 @@ namespace ams::htcfs {
return ResultSuccess();
}
}

View File

@ -465,6 +465,9 @@ namespace ams::htclow::mux {
/* Set max packet size. */
m_send_buffer.SetMaxPacketSize(max_packet_size);
/* Set our total send size. */
m_total_send_size = buf_size;
}
}

View File

@ -93,7 +93,7 @@ namespace ams::htclow::mux {
/* Determine the sendable size. */
const auto offset = total_send_size - ring_buffer_data_size;
const auto sendable_size = std::min(share - offset, ring_buffer_data_size);
const auto sendable_size = m_flow_control_enabled ? std::min(share - offset, ring_buffer_data_size) : ring_buffer_data_size;
if (sendable_size == 0) {
return false;
}