From f0ef9fb9183f04941cbc42074d1c407536bd9c63 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 16 Feb 2021 17:15:57 -0800 Subject: [PATCH] htc: fixes for WriteFileLarge/sending over data channel --- .../libstratosphere/source/htcfs/htcfs_client_impl.cpp | 9 ++++++--- .../source/htclow/mux/htclow_mux_channel_impl.cpp | 3 +++ .../source/htclow/mux/htclow_mux_send_buffer.cpp | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libraries/libstratosphere/source/htcfs/htcfs_client_impl.cpp b/libraries/libstratosphere/source/htcfs/htcfs_client_impl.cpp index 67404632d..fbeacf55c 100644 --- a/libraries/libstratosphere/source/htcfs/htcfs_client_impl.cpp +++ b/libraries/libstratosphere/source/htcfs/htcfs_client_impl.cpp @@ -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(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(); } + } diff --git a/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl.cpp b/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl.cpp index b465eeadf..cbe7fed79 100644 --- a/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl.cpp +++ b/libraries/libstratosphere/source/htclow/mux/htclow_mux_channel_impl.cpp @@ -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; } } diff --git a/libraries/libstratosphere/source/htclow/mux/htclow_mux_send_buffer.cpp b/libraries/libstratosphere/source/htclow/mux/htclow_mux_send_buffer.cpp index a7add6b21..4336d8d17 100644 --- a/libraries/libstratosphere/source/htclow/mux/htclow_mux_send_buffer.cpp +++ b/libraries/libstratosphere/source/htclow/mux/htclow_mux_send_buffer.cpp @@ -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; }