From c7becb2c7512aaf37c85af62d43cdf94e6f5fdbd Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 25 Dec 2020 22:25:37 -0800 Subject: [PATCH] http: Treat buffer full flush correctly. Unix platforms may fail send with EAGAIN instead of 0 bytes. --- Common/Net/Sinks.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Common/Net/Sinks.cpp b/Common/Net/Sinks.cpp index 2d15de15cf..459f09f16a 100644 --- a/Common/Net/Sinks.cpp +++ b/Common/Net/Sinks.cpp @@ -343,6 +343,10 @@ bool OutputSink::Flush(bool allowBlock) { size_t avail = std::min(BUFFER_SIZE - read_, valid_); int bytes = send(fd_, buf_ + read_, (int)avail, MSG_NOSIGNAL); +#if !PPSSPP_PLATFORM(WINDOWS) + if (bytes == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) + bytes = 0; +#endif AccountDrain(bytes); if (bytes == 0) { @@ -371,6 +375,10 @@ void OutputSink::Drain() { size_t avail = std::min(BUFFER_SIZE - read_, valid_); int bytes = send(fd_, buf_ + read_, (int)avail, MSG_NOSIGNAL); +#if !PPSSPP_PLATFORM(WINDOWS) + if (bytes == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) + bytes = 0; +#endif AccountDrain(bytes); } }