http: Treat buffer full flush correctly.

Unix platforms may fail send with EAGAIN instead of 0 bytes.
This commit is contained in:
Unknown W. Brackets 2020-12-25 22:25:37 -08:00
parent fd1807b4b9
commit c7becb2c75

View file

@ -343,6 +343,10 @@ bool OutputSink::Flush(bool allowBlock) {
size_t avail = std::min(BUFFER_SIZE - read_, valid_); size_t avail = std::min(BUFFER_SIZE - read_, valid_);
int bytes = send(fd_, buf_ + read_, (int)avail, MSG_NOSIGNAL); 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); AccountDrain(bytes);
if (bytes == 0) { if (bytes == 0) {
@ -371,6 +375,10 @@ void OutputSink::Drain() {
size_t avail = std::min(BUFFER_SIZE - read_, valid_); size_t avail = std::min(BUFFER_SIZE - read_, valid_);
int bytes = send(fd_, buf_ + read_, (int)avail, MSG_NOSIGNAL); 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); AccountDrain(bytes);
} }
} }